Repository navigation
rdna2spirv: RDNA2 rounds the BVH box slab toward zero; BOX16 and the game's descriptor measured - #4957
rdna2spirv: RDNA2 rounds the BVH box slab toward zero; BOX16 and the game's descriptor measured#4957shelbykb2 wants to merge 2 commits into
Conversation
…RDNA2 The subtract and the multiply of (plane - origin) * inverse direction are each rounded toward zero (TwoSum / Dekker error terms over nearest-even f32 ops, as in PR ItsNotRexed#3567's head 35f19f4): exact except for f32 subnormal operands or results. Measured on an RX 6800 (gfx1030, AMD 26.11.2, Windows 11, tools/hw_oracle, 2026-11-23): 38 rows whose inputs round (24 BOX32, 14 BOX16) fit only this of ten pre-registered arithmetics; round-to-nearest fits 2 of 24 BOX32 rows. The rows are a separately attributed block in test_image_bvh_box_hw.py; 6 of them also need the inclusive extent compare (ItsNotRexed#4750) and run only on a translator that has it. ItsNotRexed#3567's 241 rows still pass; unmodified main fails 24 of the 32 active new rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bits in the Ray tracing row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent CPU + SPIRV-Tools verification on Linux (Python 3.13.5,
Looks good to merge. |
Independent review at 64508b3 (Windows, CPU only)I ran the new semantic test on Windows 11 x64 with CPython 3.13.0: The measured-rounding rows pass, and the translator change does what the PR describes. I did not have an AMD GPU here, so this is not an independent hardware measurement. One correctness issue in
|
|
Tested 64508b3 on AMD Radeon 610M (RADV RAPHAEL_MENDOCINO, subgroup 32..64, Mesa 26.2.6), CachyOS Linux: pass.
This runs the translated box tests on a gfx1036 iGPU; it does not re-measure the RX 6800 rounding rows. AI-assisted. |
|
Tested Result: pass, with no change against
Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Independent check of Environment: Windows 11, CPython 3.15.2, no GPU/game files — the expected words are the ones measured on native RDNA2 (RX 6900 XT) that the test file documents.
The skip is the separately-attributed RX6800_ROUNDING block's expected-data gate, not a failure. AI-assisted (Devin). |
kacper-serewis
left a comment
There was a problem hiding this comment.
BUILD-1504 CPU integration with #4750 (256eedcb) at 64508b3c: ran all 38 emitted cases unconditionally. All 152 ordered child IDs matched the published RX 6800 observations, including the six extent-boundary cases that differ on this PR alone. The translator merged cleanly. Combining the test groups and both contract notes required two conflict resolutions. All five combined module tests passed, including the separate 36-case extent test. The broader suite retained three loop-ballot failures and two errors also reproduced on #4957 alone. AI-assisted CPU interpretation, no additional GPU measurement.
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Tested locally: test_docs_design_rows.py passes 4/4, test_image_bvh_box_hw.py passes 4 (1 skipped), and git diff --check is clean. One small internal count mismatch in the added Ray tracing text: the first sentence states "38 rows whose inputs round, 24 BOX32 and 14 BOX16", while the "Not measured:" sentence at the end still says "BOX16 rounding beyond 3 rows". Could you reconcile those two numbers (14 vs 3)? Clean-room OK. AI-assisted review + local test run.
|
Tested
|
|
@tupacfan04, confirmed, and thanks: the RX 6900 XT (gfx1030), AMD driver 26.11.2,
So RDNA2 flushes subnormals to zero (sign kept) in every input and in both slab results, rather than keeping or rounding them. The fix flushes the inputs and both results, and steps toward zero only when the product is normal. That is also the guard you suggested, so the stepped zero can't happen. With #5887 all 21 match bit for bit; @shelbykb2, for this PR: rebasing on #5887 (or taking its two helper changes) should be enough. Your "exact except for float32 subnormal operands or results" caveat can then go, since the subnormal behaviour is now measured and emulated. AI-assisted (Claude Code). |
Claimed in #4683 (comment). Related: #4945 (the same rounding seen on real nodes), #4750 (extent rule), #4202 (triangle rule). cc @controldebils — this agrees with the rounding rows on your #3567 head.
What and why
Three measurements on an AMD Radeon RX 6800 (gfx1030, AMD driver 26.11.2, Windows 11,
tools/hw_oracle, 2026-11-23), all with inputs that are not exact binary fractions, which no earlier row onmainhad:main's round-to-nearest fits 2 of the 24 BOX32 rows. Four of the rows replicate rows measured on an RX 6900 XT for rdna2spirv: BVH box test as measured on RDNA2: NaN planes skipped, near/far by direction sign (SHADER-650) #3567's head; they agree.The translator change, and its cost
The box slab now rounds toward zero, using the helpers from #3567's head. It is exact except for float32 subnormal operands or results. It is large: one
image_bvhsite goes from 923 to 3,539 SPIR-V instructions (+2,616); over the game's 716 sites that is about 1.9M instructions in 64 shaders. Maintainers may reasonably prefer the rows and docs without this change (the rows would then need to be marked expected-different); say so and I will split it. WhetherRoundingModeRTZ(SPV_KHR_float_controls) could do the same for free where a driver supports it was not tried.Triangles are not changed. The triangle rounding rows fit no candidate registered before the run (toward zero gets words 0, 2, 3 and every hit/miss, but word 1 is off by 1-15 ulp on 17 of 30 rows). A form fitted afterwards — everything toward zero and word 1 = (rz(k·U) + rz(k·V)) + rz(k·W) — fits all 30 and every earlier single-lane triangle row, and #4945's real-node run found the same form independently. It still needs a registered confirmation run and depends on #4202, so it is left as a note.
Tested (64508b3 on
3faac557)python -m unittest discover -s tests/semantic -p "test_image_bvh*.py": 15 tests OK, 1 skipped. The 38 rows are a separately attributed block intest_image_bvh_box_hw.py; 6 of them sit on the extent boundary and skip until rdna2spirv: BVH box extent test as measured on RDNA2: max(tnear, 0) <= extent (SHADER-835) #4750 lands (checked on a scratch tree with rdna2spirv: BVH box extent test as measured on RDNA2: max(tnear, 0) <= extent (SHADER-835) #4750: all pass). rdna2spirv: BVH box test as measured on RDNA2: NaN planes skipped, near/far by direction sign (SHADER-650) #3567's 241 rows still pass. A descriptor test checks the three w3 values give the same words.main, 24 of the 32 active new rows fail.tests/test_docs_*.py,test_ci_registration.py,test_text_encoding.py,test_text_write_line_endings.py: 46 passed.run_gpu_tests.py --filter bvhon the RX 6800: 2/2, expected words unchanged.Not measured
Box nodes through the 64-bit form (it needed a structural kernel change, dropped), more BOX16 rounding rows, big_page on memory without large pages, float32 subnormals in the slab, gfx1013 (the console).
No game files involved. AI-assisted (Claude Code; an Opus worker prepared and ran the probes, I reviewed each kernel before it ran and re-ran the tests).
🤖 Generated with Claude Code