compute: lower binary16 VOP1 rcp, sqrt, exp and rsq #3220

Merged
Leyukaka merged 3 commits from upstream-pr/3220 into main 2026-11-28 03:51:39 +00:00
Leyukaka commented 2026-11-27 22:18:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T22:18:22Z.


Part of #3219 and #2935. Target branch main. Three commits.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl). Direct compute lowers the binary16 VOP1 ops v_rcp_f16, v_sqrt_f16, v_exp_f16 and v_rsq_f16, in the VOP1, VOP3 and SDWA forms. v_log_f16 stays refused, as on main.

  • The lowering:
    • the selected half is widened with legacyF16ToF32;
    • the f32 op is applied: fdiv 1.0 for rcp, then dx.op Sqrt, Exp and Rsqrt;
    • the result is rounded to binary16 with the nearest-even conversion that v_cvt_f16_f32 uses. D[31:16] is kept, or the result is placed per SDWA dst_sel.
  • exp targets the RDNA 2 bound of 0.5 ULP.
    • The shader model 4 exp assembly instruction allows a relative error of 2^-21, which is less than 8 binary32 ULP for a normal result.
    • 70 finite binary16 inputs have an exact 2^x closer than 8 binary32 ULP to a binary16 rounding midpoint. They take their correctly rounded result from a table. The table is generated by tests/f16_exp_midpoints.py from a 90-digit reference, and the test checks it against the C++ array.
    • The exact tie exp2(-25) rounds to +0.
  • rsq targets the RDNA 2 bound of 0.51 ULP. The shader model 4 rsq assembly instruction's relative error of 2^-21 is at most 2^-10 of a binary16 ULP, so the result stays within 0.5 + 2^-10 < 0.51 ULP.
    • Special results are selected from the f16 input bits: a negative nonzero input or a NaN gives a quiet NaN; rsq(+-0) is +-inf and rsq(+inf) is +0.
  • log is left for a follow-up. The shader model 4 log assembly instruction allows an absolute error of 2^-21 on [0.5, 2], which can exceed 0.51 binary16 ULP near 1.
  • The MODE contract of the VOP2 ops applies. DPP and clamp/omod stay refused.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, Release, on main a0b45d43 plus these commits.

  • native_f16_alu_ir/_hardware and native_sdwa_f16_ir/_hardware compare against tests/f16_packed_model.py. The inputs cover +-0, +-inf, NaN, denormals, negative and general values, in the VOP1, VOP3 and SDWA forms.
    • rcp, sqrt and exp are compared bit for bit, except that rcp, sqrt and rsq match NaN by class; an exp NaN must be 0x7e00. For exp this includes all 70 table inputs in VOP1 and VOP3, 0x11c4/0x11c5/0x11c6, and abs/neg modifiers onto 0x11c5.
    • rsq must equal the correctly rounded value. The other neighbouring encoding is accepted only when the exact result is closer than 8 binary32 ULP to a midpoint.
    • The special results are compared exactly. The controls check the v_log_f16 refusal in VOP1 and VOP3.
  • ctest -R "f16|dot2|native_direct_container": 70 of 70 pass. On a full build, native_|startup_compute|compile_dxil|f16 passes 452 of 453; native_scalar_lds_hardware fails as on main.
  • Mutation checks by hand:
    • disabling the table selection fails native_f16_alu_ir and _hardware;
    • changing one table entry fails the generator check and both tests;
    • from the first version: swapping the sqrt and exp ops, and returning +inf for rsq(-0), each fail.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, base and change both on main a0b45d43.

  • Local capture of 2,689 requests: 583 to 591 compile.
  • Requests of one start-up run (2,718): 596 to 604.
  • The 882 requests of #3224: 165 to 166, which adds 478,592 dispatches.
  • No program that compiled before stops compiling.
  • Counts and instruction shape only.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5533821266 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T22:18:22Z. --- Part of #3219 and #2935. Target branch `main`. Three commits. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`). Direct compute lowers the binary16 VOP1 ops `v_rcp_f16`, `v_sqrt_f16`, `v_exp_f16` and `v_rsq_f16`, in the VOP1, VOP3 and SDWA forms. `v_log_f16` stays refused, as on `main`. - The lowering: - the selected half is widened with `legacyF16ToF32`; - the f32 op is applied: `fdiv 1.0` for rcp, then dx.op Sqrt, Exp and Rsqrt; - the result is rounded to binary16 with the nearest-even conversion that `v_cvt_f16_f32` uses. D[31:16] is kept, or the result is placed per SDWA dst_sel. - **exp** targets the RDNA 2 bound of 0.5 ULP. - The shader model 4 `exp` assembly instruction allows a relative error of 2^-21, which is less than 8 binary32 ULP for a normal result. - 70 finite binary16 inputs have an exact 2^x closer than 8 binary32 ULP to a binary16 rounding midpoint. They take their correctly rounded result from a table. The table is generated by `tests/f16_exp_midpoints.py` from a 90-digit reference, and the test checks it against the C++ array. - The exact tie `exp2(-25)` rounds to +0. - **rsq** targets the RDNA 2 bound of 0.51 ULP. The shader model 4 `rsq` assembly instruction's relative error of 2^-21 is at most 2^-10 of a binary16 ULP, so the result stays within 0.5 + 2^-10 < 0.51 ULP. - Special results are selected from the f16 input bits: a negative nonzero input or a NaN gives a quiet NaN; rsq(+-0) is +-inf and rsq(+inf) is +0. - **log** is left for a follow-up. The shader model 4 `log` assembly instruction allows an absolute error of 2^-21 on [0.5, 2], which can exceed 0.51 binary16 ULP near 1. - The MODE contract of the VOP2 ops applies. DPP and clamp/omod stay refused. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, Release, on `main` `a0b45d43` plus these commits. - `native_f16_alu_ir`/`_hardware` and `native_sdwa_f16_ir`/`_hardware` compare against `tests/f16_packed_model.py`. The inputs cover +-0, +-inf, NaN, denormals, negative and general values, in the VOP1, VOP3 and SDWA forms. - rcp, sqrt and exp are compared bit for bit, except that rcp, sqrt and rsq match NaN by class; an exp NaN must be `0x7e00`. For exp this includes all 70 table inputs in VOP1 and VOP3, `0x11c4`/`0x11c5`/`0x11c6`, and abs/neg modifiers onto `0x11c5`. - rsq must equal the correctly rounded value. The other neighbouring encoding is accepted only when the exact result is closer than 8 binary32 ULP to a midpoint. - The special results are compared exactly. The controls check the `v_log_f16` refusal in VOP1 and VOP3. - `ctest -R "f16|dot2|native_direct_container"`: 70 of 70 pass. On a full build, `native_|startup_compute|compile_dxil|f16` passes 452 of 453; `native_scalar_lds_hardware` fails as on `main`. - Mutation checks by hand: - disabling the table selection fails `native_f16_alu_ir` and `_hardware`; - changing one table entry fails the generator check and both tests; - from the first version: swapping the sqrt and exp ops, and returning +inf for rsq(-0), each fail. **Measured** with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests`, base and change both on `main` `a0b45d43`. - Local capture of 2,689 requests: 583 to 591 compile. - Requests of one start-up run (2,718): 596 to 604. - The 882 requests of #3224: 165 to 166, which adds 478,592 dispatches. - No program that compiled before stops compiling. - Counts and instruction shape only. AI-assisted.
R0Y00 commented 2026-11-27 22:33:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T22:33:30Z.

Review: CHANGES_REQUESTED


Rebasing exact head d5c37380 over main c1de64a5 conflicts in tests/native_f16_alu_check.py. Keep both interpreter arms in _exec: main's unaryBits.i32(i32 33, ...) for the merged scalar FMA tests (#3187) and this PR's unary.f32 arm for exp/log/sqrt/rsq.

The test helper also needs to survive the rebase. After resolving only the text conflict, native_fma_f16_ir fails with AttributeError: module 'native_f16_alu_check' has no attribute 'same_binary16' because native_fma_f16_check.py still calls it. Please preserve the existing exact same_binary16 comparator for that caller, including signed zero and NaN-by-class behavior. The unary tests can continue to use their own one-ULP comparison where appropriate.

I reproduced the failure with ctest --test-dir <build> --no-tests=error -j1 -V -R '^(native_f16_alu_ir|native_sdwa_f16_ir|native_fma_f16_(ir|controls)|native_packed_f16_controls)$'. Keeping both interpreter arms and restoring the exact comparator gave 5/5 in my Debug trial (e33bee58). The resolution is local; no branch was pushed.

Follow-up on the same local resolution: the five controls passed in both Debug and Release /O2. The separate CTest selection ^native_(f16_alu|fma_f16|sdwa_f16)_hardware$ also passed 3/3 in each build. RTX 4060 Laptop, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. These receipts are for the local merge resolution, not the current PR head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093980838 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#pullrequestreview-6093980838). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T22:33:30Z. **Review:** CHANGES_REQUESTED --- Rebasing exact head `d5c37380` over `main` `c1de64a5` conflicts in `tests/native_f16_alu_check.py`. Keep both interpreter arms in `_exec`: main's `unaryBits.i32(i32 33, ...)` for the merged scalar FMA tests (#3187) and this PR's `unary.f32` arm for exp/log/sqrt/rsq. The test helper also needs to survive the rebase. After resolving only the text conflict, `native_fma_f16_ir` fails with `AttributeError: module 'native_f16_alu_check' has no attribute 'same_binary16'` because `native_fma_f16_check.py` still calls it. Please preserve the existing exact `same_binary16` comparator for that caller, including signed zero and NaN-by-class behavior. The unary tests can continue to use their own one-ULP comparison where appropriate. I reproduced the failure with `ctest --test-dir <build> --no-tests=error -j1 -V -R '^(native_f16_alu_ir|native_sdwa_f16_ir|native_fma_f16_(ir|controls)|native_packed_f16_controls)$'`. Keeping both interpreter arms and restoring the exact comparator gave 5/5 in my Debug trial (`e33bee58`). The resolution is local; no branch was pushed. Follow-up on the same local resolution: the five controls passed in both Debug and Release /O2. The separate CTest selection ^native_(f16_alu|fma_f16|sdwa_f16)_hardware$ also passed 3/3 in each build. RTX 4060 Laptop, driver 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. These receipts are for the local merge resolution, not the current PR head.
pigalot commented 2026-11-27 22:39:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:39:01Z.


I tried to review d5c37380 over main e9d1d6a0, but the trial merge conflicts in tests/native_f16_alu_check.py. On the main side the conflicting change comes from d6912f58 (#3187, v_fma_f16 / v_fmac_f16 / v_fmamk_f16 / v_fmaak_f16), which landed after this branch's base e582a9a4. The two source files and the other test files merge cleanly.

git fetch origin main "pull/3220/head:review/3220"
git merge-tree --write-tree --name-only origin/main review/3220

Could you merge or rebase onto current main and keep both sets of cases in the test? I'll review the new head after that. I haven't built or run anything at d5c37380 yet, so this isn't a verdict on the change.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7229503798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7229503798). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:39:01Z. --- I tried to review `d5c37380` over `main` `e9d1d6a0`, but the trial merge conflicts in `tests/native_f16_alu_check.py`. On the `main` side the conflicting change comes from `d6912f58` (#3187, `v_fma_f16` / `v_fmac_f16` / `v_fmamk_f16` / `v_fmaak_f16`), which landed after this branch's base `e582a9a4`. The two source files and the other test files merge cleanly. ```powershell git fetch origin main "pull/3220/head:review/3220" git merge-tree --write-tree --name-only origin/main review/3220 ``` Could you merge or rebase onto current `main` and keep both sets of cases in the test? I'll review the new head after that. I haven't built or run anything at `d5c37380` yet, so this isn't a verdict on the change. This reply was AI-assisted.
KelboLive commented 2026-11-27 23:42:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:42:50Z.

Review: APPROVED


Review of PR #3220 — compute: lower binary16 VOP1 rcp, sqrt, exp, rsq and log

Summary

This PR adds support for lowering binary16 unary operations (v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16) in the direct compute path, plus extends SDWA support to these new operations.

Changes reviewed

  • src/gfx1013_direct_compute.inl: New binary16_unary() function; extended lowering for unary ops with proper special-case handling (rsq/log edge cases); updated comment about what's supported.
  • tests/native_f16_alu_check.py: Comprehensive test additions for all new unary operations.
  • tests/native_sdwa_f16_check.py: SDWA support for unary ops, including special result enforcement.
  • tests/f16_packed_model.py: CPU model updates for the new operations.
  • docs/experiments/f16-alu-direct.md: Documentation update.

Assessment

The implementation is thorough and correct:

  • The special-case handling for rsq/log (enforcing RDNA2's exact special results) correctly addresses that D3D Rsqrt doesn't guarantee -infinity for -0, so explicit selection based on source bits is used.
  • SDWA support properly handles the unary instruction encoding difference (VOP1 vs VOP2).
  • Test coverage includes all five new operations with various input patterns including edge cases (zeros, infinities, NaNs).

Verdict: Approve

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6094368459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#pullrequestreview-6094368459). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T23:42:50Z. **Review:** APPROVED --- ## Review of PR #3220 — compute: lower binary16 VOP1 rcp, sqrt, exp, rsq and log ### Summary This PR adds support for lowering binary16 unary operations (`v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`) in the direct compute path, plus extends SDWA support to these new operations. ### Changes reviewed - **`src/gfx1013_direct_compute.inl`**: New `binary16_unary()` function; extended lowering for unary ops with proper special-case handling (rsq/log edge cases); updated comment about what's supported. - **`tests/native_f16_alu_check.py`**: Comprehensive test additions for all new unary operations. - **`tests/native_sdwa_f16_check.py`**: SDWA support for unary ops, including special result enforcement. - **`tests/f16_packed_model.py`**: CPU model updates for the new operations. - **`docs/experiments/f16-alu-direct.md`**: Documentation update. ### Assessment The implementation is thorough and correct: - The special-case handling for rsq/log (enforcing RDNA2's exact special results) correctly addresses that D3D Rsqrt doesn't guarantee -infinity for -0, so explicit selection based on source bits is used. - SDWA support properly handles the unary instruction encoding difference (VOP1 vs VOP2). - Test coverage includes all five new operations with various input patterns including edge cases (zeros, infinities, NaNs). ### Verdict: Approve
Leyukaka commented 2026-11-28 00:25:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T00:25:51Z.


Rebased on main b1e92256; head is now ece04c8b. Both of your points are in:

  • _exec in tests/native_f16_alu_check.py keeps both interpreter arms: main's unaryBits.i32(i32 33, ...) for the scalar FMA tests (#3187), then this PR's unary.f32 arm for exp, log, sqrt and rsq.
  • same_binary16 is back, with main's exact logic (docstring extended): bit equality and NaN by class, so signed zeros stay distinct. tests/native_fma_f16_check.py still uses it. The unary results keep their own comparison through same_half / f16_packed_model.same_half_result, which allows one binary16 ULP for exp, rsq and log.

On this head (RTX 5080, Release, Windows SDK 10.0.26100 DXC):

  • your selection ctest --no-tests=error -j1 -R '^(native_f16_alu_ir|native_sdwa_f16_ir|native_fma_f16_(ir|controls)|native_packed_f16_controls)$' passes 5/5;
  • -R "native_f16|native_sdwa_f16|native_fma_f16|native_cvt_f16|native_packed|native_pk|native_direct_container|native_frexp|native_dpp" passes 41/41, including the _hardware tests.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230904880 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7230904880). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T00:25:51Z. --- Rebased on `main` `b1e92256`; head is now `ece04c8b`. Both of your points are in: - `_exec` in `tests/native_f16_alu_check.py` keeps both interpreter arms: `main`'s `unaryBits.i32(i32 33, ...)` for the scalar FMA tests (#3187), then this PR's `unary.f32` arm for exp, log, sqrt and rsq. - `same_binary16` is back, with `main`'s exact logic (docstring extended): bit equality and NaN by class, so signed zeros stay distinct. `tests/native_fma_f16_check.py` still uses it. The unary results keep their own comparison through `same_half` / `f16_packed_model.same_half_result`, which allows one binary16 ULP for exp, rsq and log. On this head (RTX 5080, Release, Windows SDK 10.0.26100 DXC): - your selection `ctest --no-tests=error -j1 -R '^(native_f16_alu_ir|native_sdwa_f16_ir|native_fma_f16_(ir|controls)|native_packed_f16_controls)$'` passes 5/5; - `-R "native_f16|native_sdwa_f16|native_fma_f16|native_cvt_f16|native_packed|native_pk|native_direct_container|native_frexp|native_dpp"` passes 41/41, including the `_hardware` tests. AI-assisted.
akimfomin commented 2026-11-28 01:24:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T01:24:09Z.


For the rebased ece04c8b unary coverage, VIctory #3609 has an independently checked v_exp_f16 discriminator: binary16 input 0x11c5 must give 0x3c01 rather than 0x3c00. This exercises exp lowering separately from the rebased FMA interpreter arms. If the standalone test already has a midpoint lane, report that lane's hex result on hardware and WARP separately; the full donor sweep doesn't establish this branch's result.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231640944 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7231640944). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:24:09Z. --- For the rebased `ece04c8b` unary coverage, [VIctory #3609](https://github.com/Marvisak/VIctory/pull/3609) has an independently checked `v_exp_f16` discriminator: binary16 input `0x11c5` must give `0x3c01` rather than `0x3c00`. This exercises exp lowering separately from the rebased FMA interpreter arms. If the standalone test already has a midpoint lane, report that lane's hex result on hardware and WARP separately; the full donor sweep doesn't establish this branch's result.
Leyukaka commented 2026-11-28 01:30:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T01:30:42Z.


Rebased on main 8007a539 (head 8027ad6e). The only conflict was next to #3236: DPP8 stays refused on binary16, and DPP16 stays refused on these VOP1 forms. The same 41-test selection plus the new DPP8 tests passes (49/49, RTX 5080, Release).

@akimfomin, I checked that midpoint lane with a one-off readback through this branch's direct path on the RTX 5080 (Release):

input result correctly rounded
0x11c4 0x3c00 0x3c00
0x11c5 0x3c00 0x3c01
0x11c6 0x3c01 0x3c01

So 0x11c5 comes out one ULP low. The exact result is only about 0.11 f32 ULP above the binary16 midpoint 1 + 2^-11. So the f32 intermediate lands on or below that midpoint, even when it is correctly rounded, and the nearest-even step picks 0x3c00. It is a double-rounding case. The test allows one binary16 ULP for exp, rsq and log, which is why it passes. WARP cannot run this check: its compute path has no 32-lane waves, so it reports the capability skip.

I would rather try to make these three ops round exactly than keep the tolerance. A second f32 transcendental on the inverse would not be enough, for the same reason. The decision at a binary16 midpoint would need exact comparisons, for example against per-input thresholds, or an exact compare where the inverse allows it, as 1/m^2 does for rsq. If that works out, the test can compare bit-exact, with 0x11c5 among its inputs. Until then, the current tolerance is the honest bound for this PR. Say if a one-ULP bound is acceptable here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231716533 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7231716533). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T01:30:42Z. --- Rebased on `main` `8007a539` (head `8027ad6e`). The only conflict was next to #3236: DPP8 stays refused on binary16, and DPP16 stays refused on these VOP1 forms. The same 41-test selection plus the new DPP8 tests passes (49/49, RTX 5080, Release). @akimfomin, I checked that midpoint lane with a one-off readback through this branch's direct path on the RTX 5080 (Release): | input | result | correctly rounded | |---|---|---| | `0x11c4` | `0x3c00` | `0x3c00` | | `0x11c5` | `0x3c00` | `0x3c01` | | `0x11c6` | `0x3c01` | `0x3c01` | So `0x11c5` comes out one ULP low. The exact result is only about 0.11 f32 ULP above the binary16 midpoint `1 + 2^-11`. So the f32 intermediate lands on or below that midpoint, even when it is correctly rounded, and the nearest-even step picks `0x3c00`. It is a double-rounding case. The test allows one binary16 ULP for exp, rsq and log, which is why it passes. WARP cannot run this check: its compute path has no 32-lane waves, so it reports the capability skip. I would rather try to make these three ops round exactly than keep the tolerance. A second f32 transcendental on the inverse would not be enough, for the same reason. The decision at a binary16 midpoint would need exact comparisons, for example against per-input thresholds, or an exact compare where the inverse allows it, as `1/m^2` does for rsq. If that works out, the test can compare bit-exact, with `0x11c5` among its inputs. Until then, the current tolerance is the honest bound for this PR. Say if a one-ULP bound is acceptable here. AI-assisted.
akimfomin commented 2026-11-28 01:36:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T01:36:29Z.


Thanks @Leyukaka. I independently recomputed that midpoint in a 60-digit CPU reference: rounding once gives 0x3c01, and an intermediate f32 rounds to the exact midpoint before f16 produces 0x3c00. The two neighboring lanes and the WARP capability skip in your RTX 5080 receipt make the distinction clear. VIctory #3609 has a narrow exp-only control at this input. It can be reviewed separately from rsq/log and from the PR's broader one-ULP tolerance. I'll record the measured mismatch and its attribution in PortBridge.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7231787941 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7231787941). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:36:29Z. --- Thanks @Leyukaka. I independently recomputed that midpoint in a 60-digit CPU reference: rounding once gives `0x3c01`, and an intermediate f32 rounds to the exact midpoint before f16 produces `0x3c00`. The two neighboring lanes and the WARP capability skip in your [RTX 5080 receipt](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7231716533) make the distinction clear. [VIctory #3609](https://github.com/Marvisak/VIctory/pull/3609) has a narrow exp-only control at this input. It can be reviewed separately from rsq/log and from the PR's broader one-ULP tolerance. I'll record the measured mismatch and its attribution in PortBridge.
akimfomin commented 2026-11-28 02:25:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T02:25:29Z.


Your 0x11c5 result is now covered by an apply-ready patch. I checked it against both the reported 8027ad6e and current eceb81af; the 340-case upstream CPU model passed on the newly patched head. The fix selects 0x3c01 after input modifiers and checks the two neighboring encodings plus the preserved destination half exactly. Native IR and physical GPU remain to run for the patched head. Would you prefer this exp-only change here or separately? PortBridge evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232352630 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7232352630). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T02:25:29Z. --- Your `0x11c5` result is now covered by an [apply-ready patch](https://github.com/akimfomin/PortBridge/blob/562b74c2156882a5e630c7c58e4994b64126e82e/audit/evidence/decision-followthrough/result-pass-2026-11-28/xbox-exp2-midpoint.patch). I checked it against both the reported `8027ad6e` and current `eceb81af`; the 340-case upstream CPU model passed on the newly patched head. The fix selects `0x3c01` after input modifiers and checks the two neighboring encodings plus the preserved destination half exactly. Native IR and physical GPU remain to run for the patched head. Would you prefer this exp-only change here or separately? [PortBridge evidence](https://github.com/akimfomin/PortBridge/blob/562b74c2156882a5e630c7c58e4994b64126e82e/audit/evidence/decision-followthrough/result-pass-2026-11-28/README.md).
Leyukaka commented 2026-11-28 02:30:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T02:30:35Z.


Thanks for checking it on both heads. I would rather not special-case 0x11c5 alone, though.

I counted over every finite binary16 input, against a 70-digit exp2 reference:

  • With a correctly rounded f32 intermediate, 0x11c5 is the only input that rounds to the wrong binary16 value.

  • The host's f32 exp2 does not have to be correctly rounded, though. Several inputs have an exact result close to a binary16 midpoint, counted in f32 ULPs at the result:

    Distance to the midpoint Inputs
    under 0.5 ULP 4 (0x11c5, 0xa86d, 0x36b6, 0xb8a5)
    under 2 ULP 10
    under 4 ULP 26
    under 8 ULP 70
  • A host exp2 that is off by E ULP can round the wrong way any input closer than E ULP to a midpoint; for 2 ULP that is 10 inputs. A select on 0x11c5 only fixes the correctly rounded case. My RTX 5080 readback covered 0x11c4 to 0x11c6 only, not the other three inputs under 0.5 ULP.

Two options I can implement here:

  1. A small table of every input whose exact result lies within the host's exp2 error bound of a midpoint, returning the correctly rounded binary16 for each. The result is then exact on any host within that bound. The bound has to be chosen, for example 8 ULP, which gives 70 entries. This covers exp only; rsq and log keep the one-ULP comparison for now.
  2. Keep the current comparison, which accepts one binary16 ULP on nonzero finite results of exp, rsq and log.

I'll wait for the maintainer's choice. Either way it stays in this PR.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232409263 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7232409263). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T02:30:35Z. --- Thanks for checking it on both heads. I would rather not special-case `0x11c5` alone, though. I counted over every finite binary16 input, against a 70-digit `exp2` reference: - With a correctly rounded f32 intermediate, `0x11c5` is the only input that rounds to the wrong binary16 value. - The host's f32 `exp2` does not have to be correctly rounded, though. Several inputs have an exact result close to a binary16 midpoint, counted in f32 ULPs at the result: | Distance to the midpoint | Inputs | |---|---| | under 0.5 ULP | 4 (`0x11c5`, `0xa86d`, `0x36b6`, `0xb8a5`) | | under 2 ULP | 10 | | under 4 ULP | 26 | | under 8 ULP | 70 | - A host `exp2` that is off by E ULP can round the wrong way any input closer than E ULP to a midpoint; for 2 ULP that is 10 inputs. A select on `0x11c5` only fixes the correctly rounded case. My RTX 5080 readback covered `0x11c4` to `0x11c6` only, not the other three inputs under 0.5 ULP. Two options I can implement here: 1. A small table of every input whose exact result lies within the host's `exp2` error bound of a midpoint, returning the correctly rounded binary16 for each. The result is then exact on any host within that bound. The bound has to be chosen, for example 8 ULP, which gives 70 entries. This covers `exp` only; `rsq` and `log` keep the one-ULP comparison for now. 2. Keep the current comparison, which accepts one binary16 ULP on nonzero finite results of `exp`, `rsq` and `log`. I'll wait for the maintainer's choice. Either way it stays in this PR. AI-assisted.
R0Y00 commented 2026-11-28 02:39:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:39:51Z.


Please target the documented RDNA 2 accuracy for this path. The ISA lists 0.5 ULP for V_EXP_F16 and 0.51 ULP for V_RSQ_F16 and V_LOG_F16. The measured 0x11c5 double rounding already crosses the exp bound. A one-encoding-step comparison alone also cannot establish the other two numeric error bounds. RDNA 2 ISA, VOP1 instructions 86–88.

Of the two choices, please pursue the bounded exp correction. Use a documented host error bound for any midpoint table, generate the entries from a high-precision reference, and test 0x11c4/0x11c5/0x11c6 and the other close midpoints with exact GPU bits. Keep the mode, destination-half and special-value controls. If a host bound cannot be established, leave exp refused until the implementation covers the required precision. The same principle applies to rsq/log: keep them in the patch when their actual absolute ULP bound is covered, or carry them in a follow-up so rcp/sqrt can progress independently. This avoids relying on a per-device exception for one observed input.

Independent regression receipt for eceb81af on main fdb6faaa, integrated tree 855194f4c009c36a64ea032d557e367b056e47f5: 12/12 in Debug and Release /O2, zero skips. Both scalar FMA IR controls now pass, including the existing binary16 equality helper. RTX 4060 Laptop 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Commands:

ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^(native_(f16_alu|fma_f16|sdwa_f16(_scalar)?|cvt_f16|dpp8)_(ir|controls|hardware)|native_fma_f16_opsel_ir|native_direct_container)$"

This addresses my earlier rebase/helper report. The numerical question above is independent of the passing one-step-tolerance fixture.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232513116 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7232513116). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T02:39:51Z. --- Please target the documented RDNA 2 accuracy for this path. The ISA lists 0.5 ULP for V_EXP_F16 and 0.51 ULP for V_RSQ_F16 and V_LOG_F16. The measured 0x11c5 double rounding already crosses the exp bound. A one-encoding-step comparison alone also cannot establish the other two numeric error bounds. [RDNA 2 ISA, VOP1 instructions 86–88](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). Of the two choices, please pursue the bounded exp correction. Use a documented host error bound for any midpoint table, generate the entries from a high-precision reference, and test 0x11c4/0x11c5/0x11c6 and the other close midpoints with exact GPU bits. Keep the mode, destination-half and special-value controls. If a host bound cannot be established, leave exp refused until the implementation covers the required precision. The same principle applies to rsq/log: keep them in the patch when their actual absolute ULP bound is covered, or carry them in a follow-up so rcp/sqrt can progress independently. This avoids relying on a per-device exception for one observed input. Independent regression receipt for eceb81af on main fdb6faaa, integrated tree 855194f4c009c36a64ea032d557e367b056e47f5: 12/12 in Debug and Release /O2, zero skips. Both scalar FMA IR controls now pass, including the existing binary16 equality helper. RTX 4060 Laptop 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Commands: ``` ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^(native_(f16_alu|fma_f16|sdwa_f16(_scalar)?|cvt_f16|dpp8)_(ir|controls|hardware)|native_fma_f16_opsel_ir|native_direct_container)$" ``` This addresses my earlier rebase/helper report. The numerical question above is independent of the passing one-step-tolerance fixture.
pigalot commented 2026-11-28 02:52:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T02:52:22Z.

Review: APPROVED


I reviewed eceb81af merged over main fdb6faaa. The merge is clean (tree 855194f4) and git diff --cached --check is clean. It also merges cleanly over 4d7265c0, which only touches startup tests. I first ran everything below on 8027ad6e over 50e4f763. The rebase to eceb81af changes only _exec and refusal_programs in tests/native_f16_alu_check.py; the source and the other files are the same, so I reran the tests but not the mutants.

R0Y00's changes request on d5c37380.

  • _exec keeps all three interpreter arms, in this order: main's unaryBits.i32(i32 33, ...), #3239's unary.f32(i32 7, ...) saturate, then this PR's unary.f32 arm. That last arm only fullmatches opcodes 21/23/24/25.
  • same_binary16 is back with the exact comparator, and native_fma_f16_ir and native_fma_f16_controls pass (in the run below).
  • The formal sign-off is still R0Y00's.

What I traced. binary16_unary joins half_alu in decode and the shared binary16 lowering in DirectCompute, so the MODE contract, clamp/omod and op_sel refusals carry over. The source half is widened with legacyF16ToF32, then:

  • rcp is fdiv 1.0, x;
  • sqrt/rsq/log/exp are dx.op 24/25/23/21;
  • the result is rounded with packed_half_rne, and the high half is kept, or SDWA placement is applied.

For rsq and log, the special-value selects run on the modified source bits, in this order:

  1. ugt 0x7c00 → quiet NaN, which covers positive NaNs and every negative encoding;
  2. +inf → rsq +0, log +inf;
  3. ±0 → rsq source | 0x7c00 (signed infinity), log -inf;
  4. log(1) → +0.

-0 is selected last, so it overrides the NaN select. VOP1 DPP16 and DPP8 are refused in decode.

What I ran. I built native_compute_ir_dump native_store_replay compile_dxil offscreen_check in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R 'native_(f16|sdwa_f16|fma_f16|cvt_f16|packed|pk|frexp|dpp|dot2)|native_direct_container' -E '_hardware'
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '(native_(f16|sdwa_f16|fma_f16|cvt_f16|packed|pk|frexp|dpp|dot2)|native_direct_container).*_hardware'
  • Results: 30/30 non-hardware and 26/26 hardware tests pass in both Debug and Release /O2, with no skips.
    • This includes R0Y00's five-test selection.
    • It includes #3239's native_packed_dot2_f16_*, which shares the _exec interpreter.
    • It includes #3240's native_sdwa_f16_scalar_ir/_hardware, which reuse this file's program/group_offsets with the new STRIDE of 512.
  • Negative control: on main 4d7265c0, the PR's native_f16_alu_check.py ir fails with "direct DXIL lowering for v_rcp_f16". The PR's native_sdwa_f16_check.py ir fails with "unimplemented direct SDWA operand profile".
  • Interaction with #3240: #3240 lets SGPR and inline-constant sources reach these SDWA unary forms, and no test here covers them. I ran a one-off probe of all five ops with SGPR sources (WORD_0 -0, WORD_1 -1, DWORD) and inline 2.0/1.0, with PAD and PRESERVE. All 25 cases match half_op in the IR, and all 50 GPU words match on the RTX 5090.

Mutants. These ran on 8027ad6e. For each, I rebuilt in dev and ran native_(f16_alu|sdwa_f16)_(ir|hardware):

Mutant Result
rsq(±0) always +inf killed (IR and hardware)
sqrt and exp opcodes swapped killed
log(±0) gives NaN killed
rcp numerator 2.0 killed
log(+inf) gives +0 killed
VOP1 DPP16 accepted killed (unsupported v_rcp_f16 DPP form expected, got "unsupported DPP arithmetic")
VOP1 DPP8 accepted (dpp8 limited to VOP2) survives in native_(f16_alu|sdwa_f16|sdwa_f16_scalar|*dpp*)_(ir|controls)

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking.

  1. The VOP1 DPP8 refusal has no test. The description says DPP8 stays refused on these forms, and the code refuses it. But a vop1(op, 3, 233) entry next to the DPP16 refusals would pin it.
  2. A stale comment in #3240's test. native_sdwa_f16_scalar_check.py still says group records start at DWORDs 8 and 136. With STRIDE 512 they start at 8 and 520. The code uses group_offsets, so only the comment is off.
  3. Tolerance. The one-ULP allowance for exp, rsq and log is documented, and so is the exp double-rounding discussion in the thread. rcp and sqrt are compared bit-exact, and they match bit-exact on this NVIDIA driver too. Whether real gfx1013 v_rcp_f16/v_sqrt_f16 are correctly rounded is not measured here.

Verdict: approve on eceb81af. R0Y00's changes request still needs his own sign-off, so I'm not merging.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32 replay; I did not check the debug-layer status.
CI: Build and test on Windows passes on eceb81af.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095273393 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#pullrequestreview-6095273393). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T02:52:22Z. **Review:** APPROVED --- I reviewed `eceb81af` merged over `main` `fdb6faaa`. The merge is clean (tree `855194f4`) and `git diff --cached --check` is clean. It also merges cleanly over `4d7265c0`, which only touches startup tests. I first ran everything below on `8027ad6e` over `50e4f763`. The rebase to `eceb81af` changes only `_exec` and `refusal_programs` in `tests/native_f16_alu_check.py`; the source and the other files are the same, so I reran the tests but not the mutants. **R0Y00's changes request on `d5c37380`.** - `_exec` keeps all three interpreter arms, in this order: `main`'s `unaryBits.i32(i32 33, ...)`, #3239's `unary.f32(i32 7, ...)` saturate, then this PR's `unary.f32` arm. That last arm only `fullmatch`es opcodes 21/23/24/25. - `same_binary16` is back with the exact comparator, and `native_fma_f16_ir` and `native_fma_f16_controls` pass (in the run below). - The formal sign-off is still R0Y00's. **What I traced.** `binary16_unary` joins `half_alu` in decode and the shared binary16 lowering in `DirectCompute`, so the MODE contract, clamp/omod and op_sel refusals carry over. The source half is widened with `legacyF16ToF32`, then: - rcp is `fdiv 1.0, x`; - sqrt/rsq/log/exp are dx.op 24/25/23/21; - the result is rounded with `packed_half_rne`, and the high half is kept, or SDWA placement is applied. For rsq and log, the special-value selects run on the modified source bits, in this order: 1. `ugt 0x7c00` → quiet NaN, which covers positive NaNs and every negative encoding; 2. `+inf` → rsq `+0`, log `+inf`; 3. `±0` → rsq `source | 0x7c00` (signed infinity), log `-inf`; 4. log(1) → `+0`. `-0` is selected last, so it overrides the NaN select. VOP1 DPP16 and DPP8 are refused in decode. **What I ran.** I built `native_compute_ir_dump native_store_replay compile_dxil offscreen_check` in `dev` and `release`, then ran: ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R 'native_(f16|sdwa_f16|fma_f16|cvt_f16|packed|pk|frexp|dpp|dot2)|native_direct_container' -E '_hardware' python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '(native_(f16|sdwa_f16|fma_f16|cvt_f16|packed|pk|frexp|dpp|dot2)|native_direct_container).*_hardware' ``` - **Results:** 30/30 non-hardware and 26/26 hardware tests pass in both Debug and Release `/O2`, with no skips. - This includes R0Y00's five-test selection. - It includes #3239's `native_packed_dot2_f16_*`, which shares the `_exec` interpreter. - It includes #3240's `native_sdwa_f16_scalar_ir`/`_hardware`, which reuse this file's `program`/`group_offsets` with the new `STRIDE` of 512. - **Negative control:** on `main` `4d7265c0`, the PR's `native_f16_alu_check.py ir` fails with "direct DXIL lowering for v_rcp_f16". The PR's `native_sdwa_f16_check.py ir` fails with "unimplemented direct SDWA operand profile". - **Interaction with #3240:** #3240 lets SGPR and inline-constant sources reach these SDWA unary forms, and no test here covers them. I ran a one-off probe of all five ops with SGPR sources (WORD_0 `-0`, WORD_1 `-1`, DWORD) and inline `2.0`/`1.0`, with PAD and PRESERVE. All 25 cases match `half_op` in the IR, and all 50 GPU words match on the RTX 5090. **Mutants.** These ran on `8027ad6e`. For each, I rebuilt in `dev` and ran `native_(f16_alu|sdwa_f16)_(ir|hardware)`: | Mutant | Result | |---|---| | rsq(±0) always `+inf` | killed (IR and hardware) | | sqrt and exp opcodes swapped | killed | | log(±0) gives NaN | killed | | rcp numerator 2.0 | killed | | log(+inf) gives `+0` | killed | | VOP1 DPP16 accepted | killed (`unsupported v_rcp_f16 DPP form` expected, got "unsupported DPP arithmetic") | | VOP1 DPP8 accepted (`dpp8` limited to VOP2) | **survives** in `native_(f16_alu\|sdwa_f16\|sdwa_f16_scalar\|*dpp*)_(ir\|controls)` | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** 1. **The VOP1 DPP8 refusal has no test.** The description says DPP8 stays refused on these forms, and the code refuses it. But a `vop1(op, 3, 233)` entry next to the DPP16 refusals would pin it. 2. **A stale comment in #3240's test.** `native_sdwa_f16_scalar_check.py` still says group records start at DWORDs 8 and 136. With `STRIDE` 512 they start at 8 and 520. The code uses `group_offsets`, so only the comment is off. 3. **Tolerance.** The one-ULP allowance for exp, rsq and log is documented, and so is the `exp` double-rounding discussion in the thread. rcp and sqrt are compared bit-exact, and they match bit-exact on this NVIDIA driver too. Whether real gfx1013 `v_rcp_f16`/`v_sqrt_f16` are correctly rounded is not measured here. **Verdict:** approve on `eceb81af`. R0Y00's changes request still needs his own sign-off, so I'm not merging. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32 replay; I did not check the debug-layer status. CI: `Build and test on Windows` passes on `eceb81af`. This reply was AI-assisted.
Leyukaka commented 2026-11-28 03:19:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T03:19:04Z.


Done as you asked: bounded exp, rsq kept, log moved out. Pushed 41d79706 (rebased on main a0b45d43, where it was measured; it also merges cleanly on the current 0fe4cebc). Only the third commit is new, on top of the two earlier ones, so pigalot's approval of eceb81af covers the first two and updated the description.

  • The documented host bound. The Microsoft Learn pages for the shader model 4 exp and rsq instructions give "The maximum relative error is 2-21" (2^-21). log gives an absolute error of 2^-21 on [0.5, 2] and a relative 2^-21 outside it. For a normal binary32 result, 2^-21 relative is less than 8 binary32 ULP.
  • exp. The 70 finite binary16 inputs whose exact 2^x lies closer than 8 binary32 ULP to a binary16 midpoint take their correctly rounded result from a table. tests/f16_exp_midpoints.py generates the table from a 90-digit reference and checks the C++ array. The exact tie exp2(-25) rounds to +0. On the RTX 5080, exact GPU bits are checked for every table input (0x11c4/0x11c5/0x11c6 included) and for all other exp cases. The mode, destination-half and special-value controls are unchanged.
  • rsq. It stays in this PR. A 2^-21 relative error is at most 2^-10 of a binary16 ULP, so the result is within 0.5 + 2^-10 < 0.51 ULP. The test now requires the correctly rounded value, and accepts the other neighbour only within the 8-ULP midpoint window.
  • log. It is refused again, as on main. Near an input of 1, the absolute bound of 2^-21 can exceed 0.51 binary16 ULP, so it needs another approach in a follow-up.

The new mutants and the same-SHA counts are in the description: +8 on the local capture and +1 on the 882 requests.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232975412 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7232975412). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-28T03:19:04Z. --- Done as you asked: bounded exp, rsq kept, log moved out. Pushed `41d79706` (rebased on `main` `a0b45d43`, where it was measured; it also merges cleanly on the current `0fe4cebc`). Only the third commit is new, on top of the two earlier ones, so pigalot's approval of `eceb81af` covers the first two and updated the description. - **The documented host bound.** The Microsoft Learn pages for the shader model 4 `exp` and `rsq` instructions give "The maximum relative error is 2-21" (2^-21). `log` gives an absolute error of 2^-21 on [0.5, 2] and a relative 2^-21 outside it. For a normal binary32 result, 2^-21 relative is less than 8 binary32 ULP. - **exp.** The 70 finite binary16 inputs whose exact 2^x lies closer than 8 binary32 ULP to a binary16 midpoint take their correctly rounded result from a table. `tests/f16_exp_midpoints.py` generates the table from a 90-digit reference and checks the C++ array. The exact tie `exp2(-25)` rounds to +0. On the RTX 5080, exact GPU bits are checked for every table input (`0x11c4`/`0x11c5`/`0x11c6` included) and for all other exp cases. The mode, destination-half and special-value controls are unchanged. - **rsq.** It stays in this PR. A 2^-21 relative error is at most 2^-10 of a binary16 ULP, so the result is within 0.5 + 2^-10 < 0.51 ULP. The test now requires the correctly rounded value, and accepts the other neighbour only within the 8-ULP midpoint window. - **log.** It is refused again, as on `main`. Near an input of 1, the absolute bound of 2^-21 can exceed 0.51 binary16 ULP, so it needs another approach in a follow-up. The new mutants and the same-SHA counts are in the description: +8 on the local capture and +1 on the 882 requests. AI-assisted.
akimfomin commented 2026-11-28 03:47:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-28T03:47:27Z.


I compared the exact 70 C++ table entries at 41d79706 with an independent 96-digit CPU reference. All 70 input/output pairs match. With the 2^-21 relative band, 62 of those finite interior inputs need coverage; the conservative table covers them. The exact underflow tie and the runtime results are separate. Reproduction.

I updated PortBridge #155 so an AMD or Intel volunteer can run the existing exact-bit hardware target on this head. A second adapter receipt would complement your RTX result.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7233385268 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#issuecomment-7233385268). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T03:47:27Z. --- I compared [the exact 70 C++ table entries at `41d79706`](https://github.com/R0Y00/Xbox2Windows/commit/41d79706aa9f024dff5b77d6cbc9d2598fb1434d) with an independent 96-digit CPU reference. All 70 input/output pairs match. With the `2^-21` relative band, 62 of those finite interior inputs need coverage; the conservative table covers them. The exact underflow tie and the runtime results are separate. [Reproduction](https://github.com/akimfomin/PortBridge/blob/8231537a0bed74bced65a91b926988660e43e8df/audit/evidence/external-adoption-2026-11-28/verify_exp2_table.py). I updated [PortBridge #155](https://github.com/akimfomin/PortBridge/issues/155) so an AMD or Intel volunteer can run the existing exact-bit hardware target on this head. A second adapter receipt would complement your RTX result.
R0Y00 commented 2026-11-28 03:51:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T03:51:31Z.

Review: APPROVED


The precision change addresses my earlier review. The generated table covers the finite exp2 inputs near a half rounding midpoint, including 0x11c5. The revised fixture checks the neighboring inputs and exact bits, the rsqrt comparison uses the numeric bound, and the logarithm stays refused. I corrected my earlier wording about the exp limit: the current RDNA 2 guide lists 0.51 ULP. The correctly rounded exp target is within that limit. AMD RDNA 2 ISA, Microsoft Exp, Microsoft Rsq.

At 41d79706 plus main a166a753, Debug and Release /O2 each gave 12/12, including scalar/SDWA binary16, packed FMA and DPP8 regression checks. After #3270, Release /O2 on main fdba6e15 (tree f1c049e3) passed all five focused cases:

ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R '^(native_f16_alu_(ir|hardware)|native_sdwa_f16_(ir|hardware)|native_direct_container)$'

No skips. Windows 11 26200.9974, RTX 4060 Laptop 32.0.16.1656, SDK/DXC 10.0.26100.0, standalone replay without the debug layer.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095572689 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3220#pullrequestreview-6095572689). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T03:51:31Z. **Review:** APPROVED --- The precision change addresses my earlier review. The generated table covers the finite exp2 inputs near a half rounding midpoint, including `0x11c5`. The revised fixture checks the neighboring inputs and exact bits, the rsqrt comparison uses the numeric bound, and the logarithm stays refused. I corrected my earlier wording about the exp limit: the current RDNA 2 guide lists 0.51 ULP. The correctly rounded exp target is within that limit. [AMD RDNA 2 ISA](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content), [Microsoft Exp](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/exp--sm4---asm-), [Microsoft Rsq](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/rsq--sm4---asm-). At `41d79706` plus main `a166a753`, Debug and Release /O2 each gave 12/12, including scalar/SDWA binary16, packed FMA and DPP8 regression checks. After #3270, Release /O2 on main `fdba6e15` (tree `f1c049e3`) passed all five focused cases: ```powershell ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R '^(native_f16_alu_(ir|hardware)|native_sdwa_f16_(ir|hardware)|native_direct_container)$' ``` No skips. Windows 11 26200.9974, RTX 4060 Laptop 32.0.16.1656, SDK/DXC 10.0.26100.0, standalone replay without the debug layer.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3220
No description provided.