Shaders: round half-precision fused multiply-add once #2623

Open
github-bot wants to merge 4 commits from github-bot/gh-2623 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:02 UTC · original
andrewpozdnakov7-jpg:codex2/half-fma-rounding → main · +214 −16 · 2 files · 4 commits · open

After #1387, the scalar nearest-even V_FMA_F16 path already rounds once. V_FMAC_F16 and the toward-zero fused forms still use an f32 intermediate that can land on the wrong side of a half boundary.

This PR uses the shared fma_f16 helper for both fused instructions. The product of two finite halves is exact in f32, and TwoSum recovers the addition tail. Nearest-even keeps the midpoint logic from #1387. For toward-zero conversion the helper steps inward one f32 value only when the ordered tail comparison shows that f32 rounding moved outward. Clamp follows that correction. NaN tails fail the ordered comparison, so a genuine infinity is preserved.

Validation

  • On the same RX 6750 XT (driver 32.0.21045.29003), the earlier bcdaee6 head failed one of five targeted tests in both hardware runs. Exact head 17a4e0d passed all five in both runs. The tester's RGA disassembly of the toward-zero compute fixture shows the former float saturate folded into the integer subtract's clamp modifier. The ordered comparisons on the current head avoid that fold. Failure report, passing hardware rerun, disassembly comparison.
  • On main after #1387, the nearest-even FMA control passes, the nearest-even FMAC fixture returns 0x6400 instead of 0x6401, and the toward-zero FMA fixture returns 0x6800 instead of 0x67ff. The same fixtures pass with this PR. Paired WARP results.
  • To model the reported AMD predicate behavior, the old PR was compiled with ONE changed to UNE at the residual comparison. The same WARP fixture then returned 0x7bff instead of positive infinity (0x7c00) in toward-zero mode. The updated head passes all 24 non-finite FMA/FMAC cases and five clamp cases. Review.
  • Fresh local rerun on exact 17a4e0d over main 63bcca4. App-local WARP 1.0.22 (SM 6.6), Agility SDK 1.620.2 and DXIL validation. All five half_f cases passed in both targeted runs. All 40 VALU, 34 semantics (one ignored), and 33 lowerer tests passed. Strict shader Clippy in default and all-feature configurations and the asset policy passed. GitHub CI.

Coordination claim.

If you cherry-pick or rebase the fix or tests, please retain the Git author. If folding them into another commit, please add the trailer Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 17:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623) `andrewpozdnakov7-jpg:codex2/half-fma-rounding` → `main` · +214 −16 · 2 files · 4 commits · open After #1387, the scalar nearest-even V_FMA_F16 path already rounds once. V_FMAC_F16 and the toward-zero fused forms still use an f32 intermediate that can land on the wrong side of a half boundary. This PR uses the shared fma_f16 helper for both fused instructions. The product of two finite halves is exact in f32, and TwoSum recovers the addition tail. Nearest-even keeps the midpoint logic from #1387. For toward-zero conversion the helper steps inward one f32 value only when the ordered tail comparison shows that f32 rounding moved outward. Clamp follows that correction. NaN tails fail the ordered comparison, so a genuine infinity is preserved. **Validation** - On the same RX 6750 XT (driver `32.0.21045.29003`), the earlier `bcdaee6` head failed one of five targeted tests in both hardware runs. Exact head `17a4e0d` passed all five in both runs. The tester's RGA disassembly of the toward-zero compute fixture shows the former float saturate folded into the integer subtract's clamp modifier. The ordered comparisons on the current head avoid that fold. [Failure report](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623), [passing hardware rerun](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623), [disassembly comparison](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623). - On main after #1387, the nearest-even FMA control passes, the nearest-even FMAC fixture returns 0x6400 instead of 0x6401, and the toward-zero FMA fixture returns 0x6800 instead of 0x67ff. The same fixtures pass with this PR. [Paired WARP results](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623). - To model the reported AMD predicate behavior, the old PR was compiled with ONE changed to UNE at the residual comparison. The same WARP fixture then returned 0x7bff instead of positive infinity (0x7c00) in toward-zero mode. The updated head passes all 24 non-finite FMA/FMAC cases and five clamp cases. [Review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623). - Fresh local rerun on exact `17a4e0d` over `main` `63bcca4`. App-local WARP 1.0.22 (SM 6.6), Agility SDK 1.620.2 and DXIL validation. All five `half_f` cases passed in both targeted runs. All 40 VALU, 34 semantics (one ignored), and 33 lowerer tests passed. Strict shader Clippy in default and all-feature configurations and the asset policy passed. [GitHub CI](https://github.com/Marvisak/VIctory/actions/runs/45790447366/job/139807809347). [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). If you cherry-pick or rebase the fix or tests, please retain the Git author. If folding them into another commit, please add the trailer `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:34 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 17:38 UTC · original

Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5).

  • Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), VICTORY_D3D12_WARP=1 and VICTORY_WARP=1 (software WARP only; VICTORY_WARP=1 is what makes the shader test harness skip its "hardware" adapter pass).
  • origin/main = 13f91caee2
  • PR head: c230c6bb35 (based on the main tip; merges cleanly)

Results

  • cargo test -p victory-shader --lib --locked valu_tests -- --test-threads=1: 33 passed, 0 failed, 0 ignored (includes the 3 new half_fma* / half_fmac* tests). No "device ... skipped" lines.
  • Negative control: with lower.rs reset to origin/main and the PR's tests kept, all 3 new tests FAIL (case 0); with the PR's lower.rs they pass.
  • Full cargo test -p victory-shader --lib --locked -- --test-threads=1: 270 passed, 3 failed, 3 ignored. The same 3 fail on origin/main (267 passed, 3 failed, 3 ignored); all are cross-lane tests (gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out, a_mask_joined_with_data_at_a_uniform_loop_is_its_number) that assume 32-lane waves, which WARP does not provide. So +3 passes, no new failures.
  • cargo clippy -p victory-shader --all-targets --locked: no warnings.

Review: Knuth's branch-free TwoSum on the f32 sum of an exact f16 product, then round-to-odd (move the low bit toward the residual's sign when the sum's low bit is even and the residual is nonzero) before the f16 conversion. 24 >= 2*11+2, so odd rounding followed by the conversion is a single correct rounding. The ordered ONE compare leaves NaN/inf on the old path. v_mad_f16/v_mac_f16 correctly keep the unfused path. No issues found.

Not tested: any physical GPU or driver. The TwoSum relies on the driver not reassociating or contracting the plain f32 add/sub chain (the tests show only that WARP's compiler does not), so one run on real hardware is worth it. No retail title.

**@⁠oni-swr** on GitHub · 2026-11-25 17:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7169782720) Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5). - Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1` (software WARP only; `VICTORY_WARP=1` is what makes the shader test harness skip its "hardware" adapter pass). - `origin/main` = 13f91caee25f2fdf2c062be5f7a27f058e51cbca - PR head: c230c6bb35b9e9670c0b57cb1e40cc29a08dc032 (based on the main tip; merges cleanly) **Results** - `cargo test -p victory-shader --lib --locked valu_tests -- --test-threads=1`: 33 passed, 0 failed, 0 ignored (includes the 3 new `half_fma*` / `half_fmac*` tests). No "device ... skipped" lines. - Negative control: with `lower.rs` reset to `origin/main` and the PR's tests kept, all 3 new tests FAIL (`case 0`); with the PR's `lower.rs` they pass. - Full `cargo test -p victory-shader --lib --locked -- --test-threads=1`: 270 passed, 3 failed, 3 ignored. The same 3 fail on `origin/main` (267 passed, 3 failed, 3 ignored); all are cross-lane tests (`gathers_at_a_level_match_the_hardware`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`, `a_mask_joined_with_data_at_a_uniform_loop_is_its_number`) that assume 32-lane waves, which WARP does not provide. So +3 passes, no new failures. - `cargo clippy -p victory-shader --all-targets --locked`: no warnings. **Review**: Knuth's branch-free TwoSum on the f32 sum of an exact f16 product, then round-to-odd (move the low bit toward the residual's sign when the sum's low bit is even and the residual is nonzero) before the f16 conversion. 24 >= 2*11+2, so odd rounding followed by the conversion is a single correct rounding. The ordered `ONE` compare leaves NaN/inf on the old path. `v_mad_f16`/`v_mac_f16` correctly keep the unfused path. No issues found. **Not tested**: any physical GPU or driver. The TwoSum relies on the driver not reassociating or contracting the plain f32 add/sub chain (the tests show only that WARP's compiler does not), so one run on real hardware is worth it. No retail title.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:43 UTC · original

Thanks for the independent A/B run. I disassembled the nearest-even fixture from exact head c230c6b with DXC. The separate product and the full TwoSum residual use unflagged fmul, fsub and fadd, and the residual comparison is an unflagged fcmp. DXIL gives those instructions precise semantics when their fast-math flags are unset. DXIL precise qualifier

The original sum is an explicit FMad operation. For finite half operands the product is exact in f32, so the fused and separate forms have the same rounded f32 sum. A physical-driver run remains a separate runtime check.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7169900766) Thanks for the independent A/B run. I disassembled the nearest-even fixture from exact head c230c6b with DXC. The separate product and the full TwoSum residual use unflagged fmul, fsub and fadd, and the residual comparison is an unflagged fcmp. DXIL gives those instructions precise semantics when their fast-math flags are unset. [DXIL precise qualifier](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#precise-qualifier) The original sum is an explicit FMad operation. For finite half operands the product is exact in f32, so the fused and separate forms have the same rounded f32 sum. A physical-driver run remains a separate runtime check.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:49 UTC · original

Reviewed: this is the Boldo–Melquiond round-to-odd construction — compute the exact f32 sum, reconstruct both residuals (lost_product/lost_addend), and bump the mantissa to odd only when the sum is even AND inexact AND ordered (NaN residual keeps the old path). Splitting v_fma/v_fmac (fused, single rounding) from v_mad/v_mac (two roundings, stays on fmad) matches GCN semantics. Tests cover the tie-to-even and midpoint-plus-tail cases. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7170049171) Reviewed: this is the Boldo–Melquiond round-to-odd construction — compute the exact f32 sum, reconstruct both residuals (`lost_product`/`lost_addend`), and bump the mantissa to odd only when the sum is even AND inexact AND ordered (NaN residual keeps the old path). Splitting `v_fma`/`v_fmac` (fused, single rounding) from `v_mad`/`v_mac` (two roundings, stays on `fmad`) matches GCN semantics. Tests cover the tie-to-even and midpoint-plus-tail cases. CI green.
Author
Owner

@⁠Mericas77 on GitHub · 2026-11-25 18:27 UTC · original

Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head c230c6b against main 13f91ca.

  • half_fma_rounds_once_to_nearest_even, half_fmac_rounds_once_to_nearest_even, half_fma_rounds_once_toward_zero: 3/3 pass, through run_cases, so on the NVIDIA hardware adapter as well as WARP (no skipped line).
  • The other f16 tests (f16 filter, 12 tests, including f16_arithmetic_rounds_once): 12/12 on both main and this PR.
  • cargo test -p victory-shader --lib --locked (with --skip heap_direct_texture_reads_mark_their_heap_index, which crashes the process on main here, #2571): main 266 passed / 3 failed / 3 ignored, this PR 269 / 3 / 3. The 3 failures are the known NVIDIA ones on main (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware) and are the same.

So the round-to-odd intermediate gives the expected bits on NVIDIA hardware too, no regression. (Why it matters here: on #2594 the 4070's hardware results differed from WARP's in the same kind of rounding edge case.) No game data; the title was not run.

AI-assisted.

**@⁠Mericas77** on GitHub · 2026-11-25 18:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7170938518) Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head `c230c6b` against `main` `13f91ca`. - `half_fma_rounds_once_to_nearest_even`, `half_fmac_rounds_once_to_nearest_even`, `half_fma_rounds_once_toward_zero`: **3/3 pass**, through `run_cases`, so on the NVIDIA hardware adapter as well as WARP (no `skipped` line). - The other f16 tests (`f16` filter, 12 tests, including `f16_arithmetic_rounds_once`): 12/12 on both `main` and this PR. - `cargo test -p victory-shader --lib --locked` (with `--skip heap_direct_texture_reads_mark_their_heap_index`, which crashes the process on `main` here, #2571): `main` 266 passed / 3 failed / 3 ignored, this PR 269 / 3 / 3. The 3 failures are the known NVIDIA ones on `main` (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`) and are the same. So the round-to-odd intermediate gives the expected bits on NVIDIA hardware too, no regression. (Why it matters here: on #2594 the 4070's hardware results differed from WARP's in the same kind of rounding edge case.) No game data; the title was not run. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:19 UTC · original · edited 2026-11-26 03:19 UTC

Automated triage for the maintainers.

Verdict: merge candidate (kept). Re-reviewed at bcdaee6, which merges cleanly into main. Both review points are addressed. The separate fmad_half helper and its pred::ONE compare are gone. v_fma_f16 and v_fmac_f16 now both go through the existing Lower::fma_f16 in crates/victory-shader/src/emit/lower.rs. In toward-zero mode (mode16 == Some(3)) it steps the f32 sum one ulp inward only when the sign-adjusted TwoSum tail is negative (pred::OLT). That compare is ordered, so a NaN tail from an infinite sum leaves the sum as it is. No f32 value lies strictly between the stepped sum and the exact result, so the later truncation to f16 is correct. Clamp is applied after the correction. v_mad_f16 / v_mac_f16 keep the unfused fmad path.

An AMD hardware run of the new valu_tests cases would still be welcome.

CI: passing. Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7176224964) · edited 2026-11-26 03:19 UTC <!-- victory-triage v1 head=bcdaee6bcbcd8e22ea91b774e801516065137124 verdict=merge-candidate at=2026-11-26T03:19:07Z --> Automated triage for the maintainers. **Verdict: merge candidate (kept).** Re-reviewed at `bcdaee6`, which merges cleanly into `main`. Both review points are addressed. The separate `fmad_half` helper and its `pred::ONE` compare are gone. `v_fma_f16` and `v_fmac_f16` now both go through the existing `Lower::fma_f16` in `crates/victory-shader/src/emit/lower.rs`. In toward-zero mode (`mode16 == Some(3)`) it steps the f32 sum one ulp inward only when the sign-adjusted TwoSum tail is negative (`pred::OLT`). That compare is ordered, so a NaN tail from an infinite sum leaves the sum as it is. No f32 value lies strictly between the stepped sum and the exact result, so the later truncation to f16 is correct. Clamp is applied after the correction. `v_mad_f16` / `v_mac_f16` keep the unfused `fmad` path. An AMD hardware run of the new `valu_tests` cases would still be welcome. CI: passing. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 22:37 UTC · original

I reran the three PR fixtures on current main f3578e3 and with this PR applied on top of it. Both runs used the same app-local WARP SM 6.6 setup with the DXIL validator active.

  • V_FMA_F16 nearest-even passed on both. #1387 now covers that case.
  • V_FMA_F16 toward zero failed on main (0x6800 vs. expected 0x67ff) and passed with this PR.
  • V_FMAC_F16 nearest-even failed on main (0x6400 vs. expected 0x6401) and passed with this PR.

The integrated build at local 64bcbd0 also passed all 39 VALU tests. The last two cases still exercise the behavior this PR adds.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 22:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7176586311) I reran the three PR fixtures on current main `f3578e3` and with this PR applied on top of it. Both runs used the same app-local WARP SM 6.6 setup with the DXIL validator active. - `V_FMA_F16` nearest-even passed on both. #1387 now covers that case. - `V_FMA_F16` toward zero failed on main (`0x6800` vs. expected `0x67ff`) and passed with this PR. - `V_FMAC_F16` nearest-even failed on main (`0x6400` vs. expected `0x6401`) and passed with this PR. The integrated build at local `64bcbd0` also passed all 39 VALU tests. The last two cases still exercise the behavior this PR adds.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:42 UTC · original

Code review and RTX 5090 + WARP + DXIL verification at head c230c6bb35b9 merged cleanly onto main (63bcca43c6a0; emit/lower.rs = 522,237 B, 2,051 B under the 512 KiB cap):

  • Correctness blocker on AMD D3D12 (crates/victory-shader/src/emit/lower.rs:6825):
    • let inexact = self.s.m.cmp(c, pred::ONE, residual, zero_f); emits pred::ONE.
    • As documented in crates/victory-shader/src/emit/bitcode.rs:106-109 (// Not emitted: the AMD D3D12 driver treats it as UNE, so v_cmp_lg lowers as OLT | OGT instead.), AMD's D3D12 driver evaluates pred::ONE as UNE. When a * b + c is ±Inf or NaN, residual becomes NaN, so UNE(NaN, 0.0) returns true. For +Inf (0x7F80_0000, which has an even mantissa LSB), even && inexact fires and odd = bits + delta corrupts +Inf into sNaN (0x7F80_0001) or FLT_MAX (0x7F7F_FFFF).
    • Replacing pred::ONE with pred::OLT | pred::OGT (matching v_cmp_lg at lower.rs:7962-7963) avoids the AMD driver hazard.
  • Deduplication / lower.rs budget note:
    • main (63bcca43) already has fma_f16 (lower.rs:2300-2374) for RNE v_fma_f16 (and #2884 extends that helper to packed v_pk_fma_f16/v_pk_fmac_f16). Merging #2623 as-is leaves two separate single-rounded f16 FMA implementations in lower.rs with only 2,051 B left under the 512 KiB policy limit. Unifying on one helper (potentially in a submodule) would avoid the duplication and save space in lower.rs.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, dxil.dll 10.0.26100.0, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo clippy (default + --features diagnostics): 0 warnings; cargo test -p xtask --locked: 6/6 passed
    • valu_tests (3 new half FMA/FMAC tests + existing v_fma_f16_rounds_once_and_preserves_other_half): passed on both RTX 5090 and WARP; emit::lower::tests 33/33; emit::semantics_tests 34/34 (1 ignored).
**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7179038186) Code review and RTX 5090 + WARP + DXIL verification at head `c230c6bb35b9` merged cleanly onto `main` (`63bcca43c6a0`; `emit/lower.rs` = `522,237` B, `2,051` B under the 512 KiB cap): - **Correctness blocker on AMD D3D12 (`crates/victory-shader/src/emit/lower.rs:6825`)**: - `let inexact = self.s.m.cmp(c, pred::ONE, residual, zero_f);` emits `pred::ONE`. - As documented in `crates/victory-shader/src/emit/bitcode.rs:106-109` (`// Not emitted: the AMD D3D12 driver treats it as UNE, so v_cmp_lg lowers as OLT | OGT instead.`), AMD's D3D12 driver evaluates `pred::ONE` as **`UNE`**. When `a * b + c` is `±Inf` or `NaN`, `residual` becomes `NaN`, so `UNE(NaN, 0.0)` returns `true`. For `+Inf` (`0x7F80_0000`, which has an even mantissa LSB), `even && inexact` fires and `odd = bits + delta` corrupts `+Inf` into `sNaN` (`0x7F80_0001`) or `FLT_MAX` (`0x7F7F_FFFF`). - Replacing `pred::ONE` with `pred::OLT | pred::OGT` (matching `v_cmp_lg` at `lower.rs:7962-7963`) avoids the AMD driver hazard. - **Deduplication / `lower.rs` budget note**: - `main` (`63bcca43`) already has `fma_f16` (`lower.rs:2300-2374`) for RNE `v_fma_f16` (and `#2884` extends that helper to packed `v_pk_fma_f16`/`v_pk_fmac_f16`). Merging `#2623` as-is leaves two separate single-rounded f16 FMA implementations in `lower.rs` with only `2,051` B left under the 512 KiB policy limit. Unifying on one helper (potentially in a submodule) would avoid the duplication and save space in `lower.rs`. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `dxil.dll` 10.0.26100.0, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo clippy` (default + `--features diagnostics`): 0 warnings; `cargo test -p xtask --locked`: 6/6 passed - `valu_tests` (3 new half FMA/FMAC tests + existing `v_fma_f16_rounds_once_and_preserves_other_half`): passed on both RTX 5090 and WARP; `emit::lower::tests` 33/33; `emit::semantics_tests` 34/34 (1 ignored).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 01:06 UTC · original

Addressed the residual predicate and duplication review in bcdaee6.

Both fused scalar forms now share the existing fma_f16 helper and its TwoSum residual. The toward-zero branch uses an ordered less-than comparison and clamps after correcting the sum. The separate fmad_half helper and its ONE predicate are gone.

On the old PR merged with current main, temporarily substituting UNE for ONE reproduced the reported failure on WARP: positive infinity narrowed to 0x7bff instead of 0x7c00 in the toward-zero fixture. The same test passes on the updated head for all 24 FMA/FMAC exceptional cases. All five clamp cases and 40 project VALU tests also pass with verified app-local WARP SM 6.6 and active DXIL validation. This control models the predicate behavior on software WARP. An AMD hardware rerun is still useful.

Checked clean merges with live main and with the current #2884, #2917, #2825 and #2938 heads individually. The integrated lower.rs remains below the 512 KiB cap in each case.

Please retain the Git author if cherry-picking the change or tests. If they are folded into another commit, please add the trailer Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 01:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7179443959) Addressed [the residual predicate and duplication review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623) in [bcdaee6](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/bcdaee6bcbcd8e22ea91b774e801516065137124). Both fused scalar forms now share the existing fma_f16 helper and its TwoSum residual. The toward-zero branch uses an ordered less-than comparison and clamps after correcting the sum. The separate fmad_half helper and its ONE predicate are gone. On the old PR merged with current main, temporarily substituting UNE for ONE reproduced the reported failure on WARP: positive infinity narrowed to 0x7bff instead of 0x7c00 in the toward-zero fixture. The same test passes on the updated head for all 24 FMA/FMAC exceptional cases. All five clamp cases and 40 project VALU tests also pass with verified app-local WARP SM 6.6 and active DXIL validation. This control models the predicate behavior on software WARP. An AMD hardware rerun is still useful. Checked clean merges with live main and with the current #2884, #2917, #2825 and #2938 heads individually. The integrated lower.rs remains below the 512 KiB cap in each case. Please retain the Git author if cherry-picking the change or tests. If they are folded into another commit, please add the trailer `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 05:13 UTC · original · approved these changes

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):

  • cargo test -p victory-shader --lib emit::valu_tests::half_f: 5 passed, 0 failed (RTX 5090 hardware + WARP).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#pullrequestreview-6068878058) · **approved these changes** Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, `dxil.dll` validator active): - `cargo test -p victory-shader --lib emit::valu_tests::half_f`: **5 passed, 0 failed** (RTX 5090 hardware + WARP). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 08:36 UTC · original

AMD hardware run of bcdaee6, as requested. RX 6750 XT (RDNA2), driver 32.0.21045.29003, Windows 11, Rust 1.98.1.

cargo test -p victory-shader --lib -- half_f --test-threads=1: 4 passed, 1 failed, two runs out of two. half_fma_toward_zero_clamps_after_correcting_the_sum fails on the hardware adapter only, at clamped case 3 (+inf: 0x7C00, want 0x3C00); WARP passes.

It is wider than +inf. In toward-zero mode the clamp is not applied at all on this GPU: 2, 65504, -1, -inf and NaN come back as 0x4000, 0x7BFF, 0xBC00, 0xFC00 and 0x7E00. Nearest mode is right for all of them. Cases 0 to 2 of the current test pass without any clamp (they end at or below 1.0 anyway), so only the infinity cases catch it.

The DXIL is right: DXC's disassembly of the toward-zero shader has Saturate on bitcast(sub i32 bits, zext(olt)) and its result is used. On this driver the clamp is lost when its operand is that integer step. What I measured, all in toward-zero mode, hardware adapter:

  • Saturate on the bitcast integer step (this PR): clamp lost. The same with a float select as the operand, and with FMax/FMin in place of Saturate.
  • Saturate applied to the float sum before the bit step: works. Saturate after a float multiply by 1+2^-23 that the compiler cannot remove: works.
  • Clamp by ordered compares and selects: works.

That fits a driver folding the float clamp into the instruction that made the value, but I have not seen the ISA, so please read it as a pattern and not a proven cause.

A change that avoids it, used at the two clamp sites in fma_f16:

fn clamp01(&mut self, f: V) -> V {
    let c = self.cur;
    let m = &mut self.s.m;
    let (zero, one) = (m.f32(0), m.f32(0x3F80_0000));
    let positive = m.cmp(c, pred::OGT, f, zero);
    let low = m.select(c, positive, f, zero);
    let below = m.cmp(c, pred::OLT, low, one);
    m.select(c, below, low, one)
}

NaN still gives 0, +inf gives 1. With it: all 13 inputs I tried are right on the hardware adapter in both modes, the whole victory-shader suite is 307 passed, 0 failed, 3 ignored (two runs), cargo clippy -p victory-shader --all-targets -- -D warnings is clean, and lower.rs grows by 497 bytes (521,831).

Suggested test additions: 2.0 -> 0x3C00, 0x7BFF -> 0x3C00 and -1.0 -> 0 among the clamped cases. They fail here without the change and do not depend on infinity.

Feel free to take any of this. Unit tests only, no game files.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 08:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7186793414) AMD hardware run of bcdaee6, as requested. RX 6750 XT (RDNA2), driver 32.0.21045.29003, Windows 11, Rust 1.98.1. `cargo test -p victory-shader --lib -- half_f --test-threads=1`: 4 passed, 1 failed, two runs out of two. `half_fma_toward_zero_clamps_after_correcting_the_sum` fails on the hardware adapter only, at `clamped case 3` (+inf: 0x7C00, want 0x3C00); WARP passes. It is wider than +inf. In toward-zero mode the clamp is not applied at all on this GPU: 2, 65504, -1, -inf and NaN come back as 0x4000, 0x7BFF, 0xBC00, 0xFC00 and 0x7E00. Nearest mode is right for all of them. Cases 0 to 2 of the current test pass without any clamp (they end at or below 1.0 anyway), so only the infinity cases catch it. The DXIL is right: DXC's disassembly of the toward-zero shader has `Saturate` on `bitcast(sub i32 bits, zext(olt))` and its result is used. On this driver the clamp is lost when its operand is that integer step. What I measured, all in toward-zero mode, hardware adapter: - Saturate on the bitcast integer step (this PR): clamp lost. The same with a float `select` as the operand, and with `FMax`/`FMin` in place of Saturate. - Saturate applied to the float sum before the bit step: works. Saturate after a float multiply by 1+2^-23 that the compiler cannot remove: works. - Clamp by ordered compares and selects: works. That fits a driver folding the float clamp into the instruction that made the value, but I have not seen the ISA, so please read it as a pattern and not a proven cause. A change that avoids it, used at the two clamp sites in `fma_f16`: ```rust fn clamp01(&mut self, f: V) -> V { let c = self.cur; let m = &mut self.s.m; let (zero, one) = (m.f32(0), m.f32(0x3F80_0000)); let positive = m.cmp(c, pred::OGT, f, zero); let low = m.select(c, positive, f, zero); let below = m.cmp(c, pred::OLT, low, one); m.select(c, below, low, one) } ``` NaN still gives 0, +inf gives 1. With it: all 13 inputs I tried are right on the hardware adapter in both modes, the whole `victory-shader` suite is 307 passed, 0 failed, 3 ignored (two runs), `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean, and lower.rs grows by 497 bytes (521,831). Suggested test additions: 2.0 -> 0x3C00, 0x7BFF -> 0x3C00 and -1.0 -> 0 among the clamped cases. They fail here without the change and do not depend on infinity. Feel free to take any of this. Unit tests only, no game files.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 09:16 UTC · original

@⁠wwwwwwww3333333 thank you for the AMD run — that is exactly the case the WARP control could not model.

Implemented your clamp at both sites in fma_f16, in 17a4e0d on codex2/half-fma-rounding:

fn clamp01_ordered(&mut self, value: V) -> V {
    let c = self.cur;
    let m = &mut self.s.m;
    let (zero, one) = (m.f32(0), m.f32(0x3F80_0000));
    let positive = m.cmp(c, pred::OGT, value, zero);
    let low = m.select(c, positive, value, zero);
    let below_one = m.cmp(c, pred::OLT, low, one);
    m.select(c, below_one, low, one)
}

Saturate no longer sits on the integer step in toward-zero mode, and neither mode clamps through it. NaN maps to zero and negative zero to positive zero, as before.

Tests: the fixture now covers 2.0 -> 0x3C00, -1.0 -> 0, 65504 -> 0x3C00 and NaN -> 0 in both rounding modes, which is what you suggested.

Verification here (app-local WARP SM 6.6, DXIL validator active):

  • the extended test passes on 17a4e0d;
  • the same fixture with only lower.rs reverted to 63bcca4 fails, so the clamp is what changes the result;
  • cargo clippy -p victory-shader --all-targets -- -D warnings is clean;
  • the whole VALU set is 37 passed, 3 failed both before and after the change on this machine, so no regression — the three are pre-existing here.

Could you rerun cargo test -p victory-shader --lib -- half_f --test-threads=1 on the same RX 6750 XT? The interesting cases are the toward-zero clamps: 2, 65504, -1, -inf and NaN. If the driver still folds the compares away, the next step is the float multiply by 1+2^-23 that you found works, but I would rather not add it without the ISA evidence.

Git author and the Co-authored-by trailer are as stated above if this is folded into another commit.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 09:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7187709770) @⁠wwwwwwww3333333 thank you for the AMD run — that is exactly the case the WARP control could not model. Implemented your clamp at both sites in `fma_f16`, in [17a4e0d](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/17a4e0d76b8143a030a15609d708b5a7d6665a2f) on `codex2/half-fma-rounding`: ```rust fn clamp01_ordered(&mut self, value: V) -> V { let c = self.cur; let m = &mut self.s.m; let (zero, one) = (m.f32(0), m.f32(0x3F80_0000)); let positive = m.cmp(c, pred::OGT, value, zero); let low = m.select(c, positive, value, zero); let below_one = m.cmp(c, pred::OLT, low, one); m.select(c, below_one, low, one) } ``` `Saturate` no longer sits on the integer step in toward-zero mode, and neither mode clamps through it. NaN maps to zero and negative zero to positive zero, as before. Tests: the fixture now covers `2.0 -> 0x3C00`, `-1.0 -> 0`, `65504 -> 0x3C00` and `NaN -> 0` in both rounding modes, which is what you suggested. Verification here (app-local WARP SM 6.6, DXIL validator active): - the extended test passes on `17a4e0d`; - the same fixture with only `lower.rs` reverted to `63bcca4` fails, so the clamp is what changes the result; - `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean; - the whole VALU set is 37 passed, 3 failed both before and after the change on this machine, so no regression — the three are pre-existing here. Could you rerun `cargo test -p victory-shader --lib -- half_f --test-threads=1` on the same RX 6750 XT? The interesting cases are the toward-zero clamps: `2`, `65504`, `-1`, `-inf` and `NaN`. If the driver still folds the compares away, the next step is the float multiply by `1+2^-23` that you found works, but I would rather not add it without the ISA evidence. Git author and the `Co-authored-by` trailer are as stated above if this is folded into another commit.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 09:22 UTC · original

Reran 17a4e0d on the same RX 6750 XT (RDNA2, driver 32.0.21045.29003, Windows 11, Rust 1.98.1): cargo test -p victory-shader --lib -- half_f --test-threads=1 gives 5 passed, 0 failed on the hardware adapter, two runs out of two (it was 4 passed, 1 failed on bcdaee6). cargo clippy -p victory-shader --all-targets -- -D warnings is clean. So the ordered-compare clamp is enough here and the 1+2^-23 multiply is not needed. The cause on the driver side is still unproven: I have no ISA output, only that the same input clamps correctly through compares and selects and not through saturate on the integer step.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 09:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7187866852) Reran 17a4e0d on the same RX 6750 XT (RDNA2, driver 32.0.21045.29003, Windows 11, Rust 1.98.1): `cargo test -p victory-shader --lib -- half_f --test-threads=1` gives 5 passed, 0 failed on the hardware adapter, two runs out of two (it was 4 passed, 1 failed on bcdaee6). `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean. So the ordered-compare clamp is enough here and the 1+2^-23 multiply is not needed. The cause on the driver side is still unproven: I have no ISA output, only that the same input clamps correctly through compares and selects and not through saturate on the integer step.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 09:30 UTC · original

I got the ISA for the toward-zero fma from the installed driver (32.0.21045.29003) with Radeon GPU Analyzer 2.15 (-s dx12, gfx1031, the DXIL dumped from bcdaee6 and from the ordered-compare version). On bcdaee6 the driver folds the float saturate into the integer subtract at the end of the sign step: v_sub_co_ci_u32_e64 v0, vcc_lo, v1, 0, vcc_lo clamp. On an integer VALU op the clamp bit clamps the integer result, not a float to [0, 1], so the float clamp is lost, which matches 2, 65504, -1, -inf and NaN coming back unclamped. With the ordered-compare clamp (17a4e0d) there is no clamp bit on that op; the clamp is v_cmp_lt_f32/v_cndmask_b32 and v_cmp_gt_f32/v_cndmask_b32. So the cause is a driver fold of a float saturate on a bitcast integer result into an integer clamp modifier, and the ordered compares avoid it. This is from a standalone compute pipeline of the test shader, toward-zero mode only; I did not disassemble nearest mode or the game's own pipelines.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 09:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7188079495) I got the ISA for the toward-zero fma from the installed driver (32.0.21045.29003) with Radeon GPU Analyzer 2.15 (-s dx12, gfx1031, the DXIL dumped from bcdaee6 and from the ordered-compare version). On bcdaee6 the driver folds the float saturate into the integer subtract at the end of the sign step: `v_sub_co_ci_u32_e64 v0, vcc_lo, v1, 0, vcc_lo clamp`. On an integer VALU op the clamp bit clamps the integer result, not a float to [0, 1], so the float clamp is lost, which matches 2, 65504, -1, -inf and NaN coming back unclamped. With the ordered-compare clamp (17a4e0d) there is no clamp bit on that op; the clamp is v_cmp_lt_f32/v_cndmask_b32 and v_cmp_gt_f32/v_cndmask_b32. So the cause is a driver fold of a float saturate on a bitcast integer result into an integer clamp modifier, and the ordered compares avoid it. This is from a standalone compute pipeline of the test shader, toward-zero mode only; I did not disassemble nearest mode or the game's own pipelines.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 09:33 UTC · original · reviewed

Verified 17a4e0d7 locally on Windows 11 x64 (dxil.dll 10.0.26100.0):

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean (2.37s / 2.21s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.35s).
  • cargo test -p victory-shader --lib --locked half_f -- --test-threads=1: 5 passed, 0 failed on both RTX 5090 + WARP (4.19s) and VICTORY_WARP=1 (0.12s).
  • emit/lower.rs is 521,936 bytes (2,352 bytes under the 524,288-byte policy cap).

Replacing both Saturate calls with clamp01_ordered (pred::OGT / pred::OLT + select) gives the expected endpoint and signed-zero/NaN behavior in both RNE and RTZ modes (neither clamped endpoint is a half midpoint in RNE, so the TwoSum residual cannot move it), and the expanded half_fma_clamps_in_both_rounding_modes fixture now covers finite out-of-range inputs (2.0, 65504.0, -1.0) alongside ±Inf and NaN. Pending confirmation on the RX 6750 XT that reproduced the bcdaee6 clamp drop, this looks ready.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#pullrequestreview-6071624729) · **reviewed** Verified `17a4e0d7` locally on Windows 11 x64 (`dxil.dll` 10.0.26100.0): - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean (`2.37s` / `2.21s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.35s`). - `cargo test -p victory-shader --lib --locked half_f -- --test-threads=1`: 5 passed, 0 failed on both RTX 5090 + WARP (`4.19s`) and `VICTORY_WARP=1` (`0.12s`). - `emit/lower.rs` is `521,936` bytes (`2,352` bytes under the 524,288-byte policy cap). Replacing both `Saturate` calls with `clamp01_ordered` (`pred::OGT` / `pred::OLT` + `select`) gives the expected endpoint and signed-zero/NaN behavior in both RNE and RTZ modes (neither clamped endpoint is a half midpoint in RNE, so the TwoSum residual cannot move it), and the expanded `half_fma_clamps_in_both_rounding_modes` fixture now covers finite out-of-range inputs (`2.0`, `65504.0`, `-1.0`) alongside `±Inf` and `NaN`. Pending confirmation on the RX 6750 XT that reproduced the `bcdaee6` clamp drop, this looks ready.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 09:57 UTC · original

@⁠fuzeofficlal the AMD rerun requested in your review is in. Current head 17a4e0d passed all five half_f tests in both runs on the same RX 6750 XT with driver 32.0.21045.29003.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 09:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7188717946) @⁠fuzeofficlal the [AMD rerun requested in your review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623) is in. Current head `17a4e0d` passed all five `half_f` tests in both runs on the same RX 6750 XT with driver `32.0.21045.29003`.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-26 14:25 UTC · original

A hardware result from AMD, where this fails. Head 17a4e0d merged onto main 63bcca4 (a clean merge), cargo test -p victory-shader --lib --locked on an RX 7900 XTX (RDNA3, Windows 11): 303 passed, 2 failed. Both failures are emit::semantics_tests::f16_arithmetic_rounds_once and sixteen_bit_floats_match_the_hardware, on the same case:

v_mov_b32 v5, v3; v_fmac_f16 v5, v1, v2: 143 inputs, model mismatches ["hardware 6", "warp 0"], hardware/warp differ on 6
  hardware: in [7e000001, fc00fc00, 56405152, 5a5a3c3e] want [5640fc00] got [5640fe00]

In the low half that's 0x0001 (the smallest f16 subnormal) × 0xfc00 (−inf) + 0x5152. The expected result is −inf (fc00, which WARP returns). The AMD hardware returns a NaN (fe00), as if the subnormal were flushed to zero before the multiply (0 × inf = NaN). Every other case in both tests matches on hardware and WARP, including v_fma_f16 and v_pk_fmac_f16. On main 63bcca4 the same two tests pass on this card. So the new v_fmac_f16 path through the shared fma_f16 helper seems to let the host flush an f16 subnormal operand on AMD, at least for this inf case. That's 6 of 143 inputs; I only printed the first.

**@⁠zed6000** on GitHub · 2026-11-26 14:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7194807958) A hardware result from AMD, where this fails. Head `17a4e0d` merged onto `main` `63bcca4` (a clean merge), `cargo test -p victory-shader --lib --locked` on an **RX 7900 XTX** (RDNA3, Windows 11): 303 passed, **2 failed**. Both failures are `emit::semantics_tests::f16_arithmetic_rounds_once` and `sixteen_bit_floats_match_the_hardware`, on the same case: ``` v_mov_b32 v5, v3; v_fmac_f16 v5, v1, v2: 143 inputs, model mismatches ["hardware 6", "warp 0"], hardware/warp differ on 6 hardware: in [7e000001, fc00fc00, 56405152, 5a5a3c3e] want [5640fc00] got [5640fe00] ``` In the low half that's `0x0001` (the smallest f16 subnormal) × `0xfc00` (−inf) + `0x5152`. The expected result is −inf (`fc00`, which WARP returns). The AMD hardware returns a NaN (`fe00`), as if the subnormal were flushed to zero before the multiply (0 × inf = NaN). Every other case in both tests matches on hardware and WARP, including `v_fma_f16` and `v_pk_fmac_f16`. On `main` `63bcca4` the same two tests pass on this card. So the new `v_fmac_f16` path through the shared `fma_f16` helper seems to let the host flush an f16 subnormal operand on AMD, at least for this inf case. That's 6 of 143 inputs; I only printed the first.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:56 UTC · original

Thanks, @⁠zed6000. I added your exact 0001 × fc00 + 5152 input to the non-finite VALU fixture, along with signed subnormals, true zero, conflicting infinities and signed-zero controls. The expanded fixture passes on WARP 1.0.22 on both 17a4e0d and the candidate.

The candidate uses the original FP32 FMad operation for the sum and keeps the separate FP32 product for the TwoSum residual. Two finite FP16 operands have an exact FP32 product, so the rounding correction still sees the same mathematical sum. For the reported infinite product, the candidate tests whether routing the sum through the operation that passed on main is enough. Candidate on top of 17a4e0d

On WARP, both builds pass all five half_f tests and both semantics tests named in your report. The candidate also passes all 40 VALU tests, strict Clippy and policy. The RX 7900 XTX result is still open. Could you rerun the same two semantics tests and the expanded half_fused_nonfinite_results_survive_rounding test on that card with a67da51? That will tell us whether to bring the candidate into this PR.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 14:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7195546360) Thanks, @⁠zed6000. I added your exact `0001 × fc00 + 5152` input to the non-finite VALU fixture, along with signed subnormals, true zero, conflicting infinities and signed-zero controls. The expanded fixture passes on WARP 1.0.22 on both `17a4e0d` and the candidate. The candidate uses the original FP32 `FMad` operation for the sum and keeps the separate FP32 product for the TwoSum residual. Two finite FP16 operands have an exact FP32 product, so the rounding correction still sees the same mathematical sum. For the reported infinite product, the candidate tests whether routing the sum through the operation that passed on main is enough. [Candidate on top of `17a4e0d`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/a67da51e9ae4e9ef32a5d9e599dd94d8551277fc) On WARP, both builds pass all five `half_f` tests and both semantics tests named in your report. The candidate also passes all 40 VALU tests, strict Clippy and policy. The RX 7900 XTX result is still open. Could you rerun the same two semantics tests and the expanded `half_fused_nonfinite_results_survive_rounding` test on that card with `a67da51`? That will tell us whether to bring the candidate into this PR. AI-assisted with Codex.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:01 UTC · original

@⁠zed6000 Thanks for checking the same fixtures on main and 17a4e0d. I am taking the RX 7900 XTX regression. I will reduce the reported subnormal × infinity input to a directed test and check it alongside the finite rounding and clamp cases. If you still have the driver version or the other five failing rows, those would help pin down the hardware comparison. I'll post the exact follow-up SHA for a rerun.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 15:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7195667063) @⁠zed6000 Thanks for checking the same fixtures on `main` and `17a4e0d`. I am taking the RX 7900 XTX regression. I will reduce the reported subnormal × infinity input to a directed test and check it alongside the finite rounding and clamp cases. If you still have the driver version or the other five failing rows, those would help pin down the hardware comparison. I'll post the exact follow-up SHA for a rerun.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:10 UTC · original

@⁠zed6000 a756f0f is now the PR head. Scalar FMA and FMAC convert signed half subnormals from their bits before the fused operation. The finite rounding and clamp paths are unchanged.

The directed test covers the reported row, swapped operands, both infinity signs, a normal-input control, a finite subnormal product and addend, and a true zero-times-infinity control. It checks 28 results across FMA/FMAC and nearest-even/toward-zero on WARP with DXIL validation. Default WARP passed before and after. In a separate test-only run that forces signed half subnormals to zero at the legacy conversion, 17a4e0d reproduced your fe00 versus fc00 result and a756f0f passed all 28. The VALU, semantics and lowerer suites passed 41, 34 and 33 tests respectively, with one ignored semantics test. Strict shader Clippy and the asset-policy check passed.

Could you rerun fused_half_keeps_subnormal_operands, f16_arithmetic_rounds_once and sixteen_bit_floats_match_the_hardware on the RX 7900 XTX at exact a756f0f? That will check whether the fix covers the failure on the adapter itself.

Please retain the Git author on cherry-pick or rebase. If folding the fix or tests into another commit, use Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 15:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7195881446) @⁠zed6000 [`a756f0f`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/a756f0f66f77485e112eaaf90e114f9f9b73c371) is now the PR head. Scalar FMA and FMAC convert signed half subnormals from their bits before the fused operation. The finite rounding and clamp paths are unchanged. The directed test covers the reported row, swapped operands, both infinity signs, a normal-input control, a finite subnormal product and addend, and a true zero-times-infinity control. It checks 28 results across FMA/FMAC and nearest-even/toward-zero on WARP with DXIL validation. Default WARP passed before and after. In a separate test-only run that forces signed half subnormals to zero at the legacy conversion, `17a4e0d` reproduced your `fe00` versus `fc00` result and `a756f0f` passed all 28. The VALU, semantics and lowerer suites passed 41, 34 and 33 tests respectively, with one ignored semantics test. Strict shader Clippy and the asset-policy check passed. Could you rerun `fused_half_keeps_subnormal_operands`, `f16_arithmetic_rounds_once` and `sixteen_bit_floats_match_the_hardware` on the RX 7900 XTX at exact `a756f0f`? That will check whether the fix covers the failure on the adapter itself. Please retain the Git author on cherry-pick or rebase. If folding the fix or tests into another commit, use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-26 16:13 UTC · original

@⁠andrewpozdnakov7-jpg Retested a756f0f on the same RX 7900 XTX (RDNA3, Windows 11, Adrenalin driver 32.0.32029.2010): merged onto main 63bcca4 (fast-forward), cargo test -p victory-shader --lib --locked gives 308 passed, 0 failed (3 ignored). Both f16_arithmetic_rounds_once and the expanded non-finite fixture now pass on AMD hardware.

**@⁠zed6000** on GitHub · 2026-11-26 16:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7197347251) @⁠andrewpozdnakov7-jpg Retested `a756f0f` on the same RX 7900 XTX (RDNA3, Windows 11, Adrenalin driver 32.0.32029.2010): merged onto `main` `63bcca4` (fast-forward), `cargo test -p victory-shader --lib --locked` gives **308 passed, 0 failed** (3 ignored). Both `f16_arithmetic_rounds_once` and the expanded non-finite fixture now pass on AMD hardware.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 16:19 UTC · original

Thanks for rerunning the exact head, @⁠zed6000. The same-card RX 7900 XTX retest resolves the six earlier v_fmac_f16 mismatches: both f16_arithmetic_rounds_once and the expanded non-finite fixture pass on a756f0f, and the shader suite reports 308 passed, 0 failed, 3 ignored. The PR check passed on the same head. This is ready for maintainer review.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2623#issuecomment-7197481222) Thanks for rerunning the exact head, @⁠zed6000. The [same-card RX 7900 XTX retest](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2623) resolves the six earlier `v_fmac_f16` mismatches: both `f16_arithmetic_rounds_once` and the expanded non-finite fixture pass on `a756f0f`, and the shader suite reports 308 passed, 0 failed, 3 ignored. The [PR check](https://github.com/Marvisak/VIctory/actions/runs/45846291846/job/140000723965) passed on the same head. This is ready for maintainer review.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2623/head:github-bot/gh-2623'
git switch 'github-bot/gh-2623'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2623'
git switch 'github-bot/gh-2623'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2623'
git switch 'github-bot/gh-2623'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2623'
git switch 'main'
git merge --squash 'github-bot/gh-2623'
git switch 'main'
git merge --ff-only 'github-bot/gh-2623'
git switch 'main'
git merge 'github-bot/gh-2623'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2623
No description provided.