fix: implement v_rndne_f32 in integer HLSL to avoid NVIDIA Round_ne f… #260
No reviewers
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!260
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/260/head"
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?
@pandolfipedro on GitHub · 2026-11-25 22:16 UTC · original
pandolfipedro:fix/hlsl-rndne-f32-nvidia→main· +47 −1 · 3 files · 1 commits · merged 2026-11-26 00:15 UTC…olding bug
Fixes #227. On NVIDIA driver 621.xx (measured on RTX 4060 Laptop 621.14 and reported on RTX 5070 Ti 621.40), DXIL Round_ne(2.5) after a barrier is constant-folded to 3.0 (round half away from zero) instead of 2.0 (ties to even), and NaN payloads are replaced with 0x7FFFFFFF (while WARP leaves signalling NaNs unquieted). Computing RndneF32 in integer bit operations matches the reference interpreter bit for bit on NVIDIA, Intel UHD, and WARP.
Change
Linked issue: Fixes # / Refs #
Verification
Oracle and test data
Checklist
E_NOTIMPL), never a fake success.test_readme_sync.pychecks it).AGENTS.mdallows (names, slots, argument shapes, flag values, HRESULTs, IIDs, counts), with how they were obtained; no address or RVA.THIRD_PARTY.md.@Cai-piroska on GitHub · 2026-11-25 22:38 UTC · original
AI use: tests run, regression located and variant written with Claude Code (Claude Opus 5.5) on my machine.
This fixes the RTX 3080 Ti, but it breaks
test_extended_alu_matches_interpreter_on_gpuon an RX 9070 XT (RDNA 4). This is the same AMD driver problem as the first version of #160: the earlyreturns inRndneF32make the driver miscompile the neighbouringv_bfrev_b32. A single-return form of the same integer algorithm passes on all three adapters.Setup: Windows 11 26300, dxc 1.9.2602.17 (Windows SDK 10.0.26100), C++ runtime built from
main9a06443with VS 2022 Build Tools. Trees: this head4d459a4(baseaffaf15), andmain9a06443as the control. Command:python -m pytest tests/test_rdna2*.py, 2 runs per adapter. The totals differ becausemainalso hastests/test_rdna2_exec_ds_addtid.pyfrom #248, which this branch's base does not.main9a064434d459a4return(below)mainon the RTX 3080 Ti is thev_rndne_f32tie from #227, which this PR fixes.test_extended_alu_matches_interpreter_on_gpuin both runs.v_rndne_f32itself is right there. The wrong word is thev_bfrev_b32result (v13, stored in slot 9): on all 32 lanes the GPU returns0x60c04080and the interpreter0x20c04080, with bit 30 set. Your newtest_v_rndne_f32_ties_to_even_and_specials_on_gpupasses there.returns. 855e527 fixed it by computing the result and choosing it at the end, and addedtest_rndne_helper_has_a_single_return. #160 was closed for a conflict, so neither the fix nor that test is onmain.The variant I ran keeps your algorithm and only replaces the early
returns with selects:shiftis held at 1 outside the range where it is used, so the shifts stay defined. With it, bothv_rndne_f32tests and thev_bfrev_b32word match on all three adapters. Bringing back #160'stest_rndne_helper_has_a_single_returnwould keep this from coming back.@KainanP on GitHub · 2026-11-25 23:42 UTC · original
Setup: Windows 11 26200, dxc 1.8.2502.11 (Windows SDK 10.0.26100.0), Python 3.12.10, C++ runtime built from
main3e258c8. Adapters: RTX 4060 Laptop (driver 32.0.16.1047, i.e. 610.47; default adapter), Intel UHD 8086:a78b (31.0.101.5445,ANYXBOXX_GPU=Intel, 16 lanes, no FP64), WARP 10.0.26100.9818 (ANYXBOXX_GPU=warp). Trees:main3e258c8; this PR merged onto it (clean merge); the same plus the single-returnRndneF32from Cai-piroska's comment, pasted verbatim.mainpython -m pytesttests/test_rdna2*.pytests/test_rdna2*.pytests/test_rdna2_alu_parity.py(test_extended_alu_matches_interpreter_on_gpuand your new test) was run a second time on each adapter and tree, with the same results.test_extended_alu_matches_interpreter_on_gpupasses onmainwith this driver, so that test alone does not show the bug here. Your new test does. I ran its body onmainwithout theuint RndneF32(text check:v_rndne_f32of the 2.5, -2.5 and 0.5 literals after the ballot gives 3.0, -3.0 and 1.0 on lanes 10-31 (22 of 32), and all five NaN inputs come back as0x7FFFFFFF. Onmain, Intel UHD shows no difference, and WARP returns only the two signalling NaNs unquieted (0x7F800001where the interpreter gives0x7FC00001). With this PR or the variant there are no differences on any of the three adapters.mainthe new test fails on all three adapters, but on WARP and Intel only because of theuint RndneF32(text check.test_rndne_helper_has_a_single_returnseems the safe choice.a | 0x400000), as the interpreter does inbits_float, and gives a signed zero for subnormals and|x| <= 0.5, like_round_even. No refusal changes.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.