RDNA2 GPU parity: 1-byte mismatch between interpreter and GPU on RTX 5070 Ti (passes on WARP) #227

Closed
opened 2026-11-26 05:38:46 +00:00 by github-bot · 1 comment
Owner

@⁠PeppeBeard on GitHub · 2026-11-25 19:24 UTC · original

Summary

tests/test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu fails with a 1-byte difference between the reference interpreter (expected) and a D3D12 GPU run (actual) on an NVIDIA RTX 5070 Ti. The same test passes when forced through WARP (ANYXBOXX_GPU=warp), which suggests the translated shader is logically correct and the divergence happens only in native execution on this particular 50-series driver.

Environment

  • GPU: NVIDIA GeForce RTX 5070 Ti, 16 GB (Blackwell)
  • Driver: 621.40 (KMD 621.40, CUDA UMD 13.5), WDDM model
  • OS: Windows 11, build 10.0.26200
  • Build: current main of this repository, cloned and built 2026-11-25
  • Python 3.12 venv, all steps from AGENTS.md setup followed (C++ runtime built, Rust workspace built, TomBox DLLs built)

Reproduction

.venv\Scripts\python.exe -m pytest tests\test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu -q
# → FAILED, 1 failed

Then forcing WARP:

set ANYXBOXX_GPU=warp
.venv\Scripts\python.exe -m pytest tests\test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu -q
# → PASSED, 1 passed

Full suite otherwise: 1263 passed, 2 skipped, 1 failed (this test only).

Failure detail

assert actual == expected
At index 129282 diff: b'@' != b'\x00'

Index 129282 of the compared output buffer: the GPU run produced 0x40 where the interpreter expected 0x00. Single byte out of the full compared buffer — every other byte matches. Obtained by running the test as written; no code modified, no debug layer enabled during this run (can re-run with VICTORY_D3D12_DEBUG=1 equivalents if that helps).

Interpretation (best guess, correct me if wrong)

  • WARP agreement rules out a pure translation bug in the affected path, since WARP executes the same translated DXIL correctly against the interpreter.
  • The README documents wave64 compute pipeline refusals on NVIDIA 40-series, and this test predates concern about 50-series. This looks like new silicon behaving differently on wave/ALU semantics rather than a pipeline refusal (the test completes and produces near-identical output rather than refusing to run).
  • Possibly related to the wave64-on-32-lane-host emulation path (#70), or to a specific ALU op in the extended-ALU parity set. I have not bisected which individual op diverges.

Notes

  • Not attaching any files; all info here is from public test code and my own hardware run.
  • Happy to run extra diagnostics (-v pytest diff, per-op bisection, DRED, a different driver branch) on request — this card is available for it.
  • If useful as a datapoint: this is, as far as I can tell, the first 50-series (Blackwell) consumer-GPU report for this test; the README currently documents measurements only from 3070/4070-class cards.
**@⁠PeppeBeard** on GitHub · 2026-11-25 19:24 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/227) ## Summary `tests/test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu` fails with a 1-byte difference between the reference interpreter (expected) and a D3D12 GPU run (actual) on an NVIDIA RTX 5070 Ti. The same test **passes** when forced through WARP (`ANYXBOXX_GPU=warp`), which suggests the translated shader is logically correct and the divergence happens only in native execution on this particular 50-series driver. ## Environment - GPU: NVIDIA GeForce RTX 5070 Ti, 16 GB (Blackwell) - Driver: 621.40 (KMD 621.40, CUDA UMD 13.5), WDDM model - OS: Windows 11, build 10.0.26200 - Build: current `main` of this repository, cloned and built 2026-11-25 - Python 3.12 venv, all steps from AGENTS.md setup followed (C++ runtime built, Rust workspace built, TomBox DLLs built) ## Reproduction ```powershell .venv\Scripts\python.exe -m pytest tests\test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu -q # → FAILED, 1 failed ``` Then forcing WARP: ```powershell set ANYXBOXX_GPU=warp .venv\Scripts\python.exe -m pytest tests\test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpu -q # → PASSED, 1 passed ``` Full suite otherwise: 1263 passed, 2 skipped, 1 failed (this test only). ## Failure detail ``` assert actual == expected At index 129282 diff: b'@' != b'\x00' ``` Index 129282 of the compared output buffer: the GPU run produced `0x40` where the interpreter expected `0x00`. Single byte out of the full compared buffer — every other byte matches. Obtained by running the test as written; no code modified, no debug layer enabled during this run (can re-run with `VICTORY_D3D12_DEBUG=1` equivalents if that helps). ## Interpretation (best guess, correct me if wrong) - WARP agreement rules out a pure translation bug in the affected path, since WARP executes the same translated DXIL correctly against the interpreter. - The README documents wave64 compute pipeline refusals on NVIDIA 40-series, and this test predates concern about 50-series. This looks like new silicon behaving differently on wave/ALU semantics rather than a pipeline refusal (the test completes and produces near-identical output rather than refusing to run). - Possibly related to the wave64-on-32-lane-host emulation path (#70), or to a specific ALU op in the extended-ALU parity set. I have not bisected which individual op diverges. ## Notes - Not attaching any files; all info here is from public test code and my own hardware run. - Happy to run extra diagnostics (`-v` pytest diff, per-op bisection, DRED, a different driver branch) on request — this card is available for it. - If useful as a datapoint: this is, as far as I can tell, the first 50-series (Blackwell) consumer-GPU report for this test; the README currently documents measurements only from 3070/4070-class cards.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:38:46 +00:00
Author
Owner

@⁠PeppeBeard on GitHub · 2026-11-25 20:46 UTC · original

Update — root cause found and a candidate fix validated on the same hardware. (Follow-up to my original report; everything below comes from public test code in this repo and my own runs.)

Bisect result

Removing any one of three instructions from the test program clears all 32 diff bytes — they are one dependency chain, not 32 independent failures:

  • v_mov_b32 v15, 2.5f (the input)
  • v_rndne_f32 v24, v15 (the op)
  • the store_lane of v24

The diffs are 32 consecutive dwords (one per lane): expected=0x40000000 (2.0) vs actual=0x40400000 (3.0). That is exactly the tie case rndne(2.5).

Root cause

emu/rdna2_hlsl_ops.py line 196 emits for v_rndne_f32:

asuint(round(asfloat({a})))

HLSL's round() is defined as ties away from zero (round(2.5) = 3.0), while AMD's v_rndne_f32 is IEEE-754 round-nearest-even (2.5 → 2.0) — and the reference interpreter implements ties-to-even (_round_even in rdna2_exec_ops.py). On my driver the GPU executes the emitted HLSL as specified (ties-away), WARP's round() evidently behaves ties-to-even, so only real-hardware runs diverge. The interpreter is right; the emission chooses the wrong HLSL primitive.

Candidate fix (validated on RTX 5070 Ti, driver 621.40)

Replacing the emission with an explicit ties-to-even expression:

(floor(x) + (frac(x) > 0.5 ? 1.0 : 0.0)
          + (frac(x) == 0.5 ? (fmod(floor(x), 2.0) != 0.0 ? 1.0 : 0.0) : 0.0))

With this patched emission, the minimal repro and the inputs 2.5, 3.5, 1.5, 2.0, −2.5, 4.5, 10.0 all match the interpreter byte-for-byte on hardware. The full parity test should follow once applied at the emission site.

Two caveats for whoever implements it properly: the frac()-based formula relies on exact fraction representation near the tie (fine in f32 for the tested values, but worth checking against the interpreter's denormal/negative-zero conventions), and the same round() pattern may exist for the f16/f64 variants (v_rndne_f16, v_rndne_f64 — the f64 one uses a different path in rdna2_exec_wide.py), so a fix should cover those or confirm they don't share the emission.

Happy to test a formal patch on this card.

**@⁠PeppeBeard** on GitHub · 2026-11-25 20:46 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/227#issuecomment-7174178240) Update — root cause found and a candidate fix validated on the same hardware. (Follow-up to my original report; everything below comes from public test code in this repo and my own runs.) ## Bisect result Removing any one of three instructions from the test program clears all 32 diff bytes — they are one dependency chain, not 32 independent failures: - `v_mov_b32 v15, 2.5f` (the input) - `v_rndne_f32 v24, v15` (the op) - the `store_lane` of `v24` The diffs are 32 consecutive dwords (one per lane): `expected=0x40000000` (2.0) vs `actual=0x40400000` (3.0). That is exactly the tie case `rndne(2.5)`. ## Root cause `emu/rdna2_hlsl_ops.py` line 196 emits for `v_rndne_f32`: ```hlsl asuint(round(asfloat({a}))) ``` HLSL's `round()` is defined as *ties away from zero* (round(2.5) = 3.0), while AMD's `v_rndne_f32` is IEEE-754 *round-nearest-even* (2.5 → 2.0) — and the reference interpreter implements ties-to-even (`_round_even` in `rdna2_exec_ops.py`). On my driver the GPU executes the emitted HLSL as specified (ties-away), WARP's `round()` evidently behaves ties-to-even, so only real-hardware runs diverge. The interpreter is right; the emission chooses the wrong HLSL primitive. ## Candidate fix (validated on RTX 5070 Ti, driver 621.40) Replacing the emission with an explicit ties-to-even expression: ```hlsl (floor(x) + (frac(x) > 0.5 ? 1.0 : 0.0) + (frac(x) == 0.5 ? (fmod(floor(x), 2.0) != 0.0 ? 1.0 : 0.0) : 0.0)) ``` With this patched emission, the minimal repro and the inputs 2.5, 3.5, 1.5, 2.0, −2.5, 4.5, 10.0 all match the interpreter byte-for-byte on hardware. The full parity test should follow once applied at the emission site. Two caveats for whoever implements it properly: the `frac()`-based formula relies on exact fraction representation near the tie (fine in f32 for the tested values, but worth checking against the interpreter's denormal/negative-zero conventions), and the same `round()` pattern may exist for the f16/f64 variants (`v_rndne_f16`, `v_rndne_f64` — the f64 one uses a different path in `rdna2_exec_wide.py`), so a fix should cover those or confirm they don't share the emission. Happy to test a formal patch on this card.
This discussion has been locked. Commenting is limited to contributors.
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/LooperSalty--AnyXboxX#227
No description provided.