RDNA2 GPU parity: 1-byte mismatch between interpreter and GPU on RTX 5070 Ti (passes on WARP) #227
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX#227
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@PeppeBeard on GitHub · 2026-11-25 19:24 UTC · original
Summary
tests/test_rdna2_alu_parity.py::test_extended_alu_matches_interpreter_on_gpufails 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
mainof this repository, cloned and built 2026-11-25Reproduction
Then forcing WARP:
Full suite otherwise: 1263 passed, 2 skipped, 1 failed (this test only).
Failure detail
Index 129282 of the compared output buffer: the GPU run produced
0x40where the interpreter expected0x00. 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 withVICTORY_D3D12_DEBUG=1equivalents if that helps).Interpretation (best guess, correct me if wrong)
Notes
-vpytest diff, per-op bisection, DRED, a different driver branch) on request — this card is available for it.@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)store_laneofv24The diffs are 32 consecutive dwords (one per lane):
expected=0x40000000(2.0) vsactual=0x40400000(3.0). That is exactly the tie caserndne(2.5).Root cause
emu/rdna2_hlsl_ops.pyline 196 emits forv_rndne_f32:HLSL's
round()is defined as ties away from zero (round(2.5) = 3.0), while AMD'sv_rndne_f32is IEEE-754 round-nearest-even (2.5 → 2.0) — and the reference interpreter implements ties-to-even (_round_eveninrdna2_exec_ops.py). On my driver the GPU executes the emitted HLSL as specified (ties-away), WARP'sround()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:
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 sameround()pattern may exist for the f16/f64 variants (v_rndne_f16,v_rndne_f64— the f64 one uses a different path inrdna2_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.