tests: accept 4 ulps for v_log_f32 in the transcendental fixture #2806
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2814"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T11:14:59Z.
Change
startup_gfx2hlsl_float_transcendental_hardwarefailed on an NVIDIA GeForce RTX 4090 becauselog2(0.125)read backc03fffff, 1 ulp above -3.0. This PR letsv_log_f32read up to 4 ulps off its reference. The other five operations (v_rcp_f32,v_rcp_iflag_f32,v_sqrt_f32,v_rsq_f32andv_exp_f32) stay bit-exact.Fixes #2797
Why a tolerance, and why 4: the Direct3D 11.3 functional specification (§22.10.8) bounds
logto 2^-21 relative error. For inputs in [0.5, 2] the bound is 2^-21 absolute instead. For every result in this fixture, both bounds are at least 4 ulps of binary32. The DXIL documentation gives no accuracy forLog. Credit to thepatrickworld's comment on the issue for the spec reference.Shared interface:
tests/startup_gfx2hlsl_lane_alu.pygains an optionalulpsentry in the family dict, mapping a mnemonic to a bound. It defaults to 0, which is exact equality, so the integer families are unchanged and -0.0 and +0.0 stay distinct. A nonzero bound measures distance on the number line, so it accepts -0.0 for +0.0 and the reverse. The runner docstring says so. The renderer still compares exactly. On a mismatch, the runner reads theactual=words from thestartup_flat_param mismatchline and accepts them only if:offscreen_checkexits 1 whether or not the debug layer also logged errors. Without this guard, an in-bound lane could hide a validation failure.The mutated draw must read words within the bound of the mutation and outside the bound of the reference. The controls now require each mutation to be more than twice the bound away from the reference in draw set 0. They also check the ulp distance helper on fixed words, including the #2797 word.
This is not a weakened test. Five operations keep their exact comparison. The
v_log_f32bound comes from the spec, and the mutation (logarithm plus one) is far outside it.Verification
Commit
e29a8c84.offscreen_checkwas built from that commit with thedevpreset. Environment: Windows 10.0.26300.9974, DXC 1.9.2602.17 and FXC from Windows SDK 10.0.26100.0,X2W_TEST_DEBUG_LAYER=1.1414:008c)v_log_f32lane exact10de:2684)v_log_f32draws within the boundThe debug layer was enabled for both adapters and every draw reported
debug_errors=0 debug_warnings=0(72 of 72).RTX 4090
v_log_f32readbacks, the same through FXCps_5_1and DXCps_6_0:The second set (
2^-20, 2, 2^30, 0.5) did not run in the issue. On this card it is also off:2^-20readsc19fffff(1 ulp above -20.0) and0.5readsbf7ffffe(2 ulps above -1.0).Negative controls on the RTX 4090, with the bound edited locally. These two ran with an
offscreen_checkfrom another local build whose renderer code is unchanged:expected=40400000,c0400000,00000000,41200000 actual=40400000,c03fffff,00000000,41200000, as in #2797.40800000,bffffffe,3f800000,41300000.log2(0.125) + 1lands 2 ulps above -2.0, so 1 ulp is too tight even for the mutation.Pure-Python controls pass for all eight families that use the runner:
cvt_alu,cvt_pk_u8,float_alu,float_round,float_transcendental,int3_alu,int_aluandpack_b32_f16.tests/docs_links_check.pypasses.Evidence and follow-up
docs/experiments.mdsection and the fixture docstring now say the results are exactly representable rather than returned exactly, and record the RTX 4090 readings and the controls.log2(1)), which is much tighter than the 2^-21 absolute error the specification allows. WARP, the RX 6600, the RX 9070 XT (reported on the issue) and the RTX 4090 all return 0 there.v_sin_f32andv_cos_f32(unchanged).Checklist
AI-assisted with Claude Code (Claude Opus 5.5). The commands listed were run locally.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:16:57Z.
Review: COMMENTED
Review of head
e29a8c84(comment review, no approval).Justification holds. I read the Direct3D 11.3 functional specification,
loginstruction: "If src0 is [0.5..2], absolute error must be no more than 2^-21. If src0 is (0..0.5) or (2..+INF], relative error must be no more than 2^-21." I worked this out per lane for the fixture inputs8, 0.125, 1, 1024, 2^-20, 2, 2^30, 0.5. The bound in binary32 ulps is 12, 12, (0), 20, 20, 4, 7.5, 8. The smallest nonzero one is 4 (input 2.0, result 1.0, ulp 2^-23), so 4 is the largest bound that every lane is guaranteed to satisfy. It has no margin there, but it is not wider than the spec. The lane with input 1.0 (result 0) is far tighter than the spec; the doc says so.Scope is only
v_log_f32.'ulps': {'v_log_f32': 4}is the only entry. The other five operations default to 0 and still compare exactly (within()returnsgot == list(want), so-0.0and+0.0stay distinct).Mutations still fail. I imported the runner's
within()and fed it the readbacks of wrong lowerings against the reference words of the 8 inputs:log2 + 1(the fixture's own mutation): all 8 lanes far off;The mutated draw is also now required to read words within the bound of the mutation and outside the bound of the reference, and the control requires the mutation to be more than 2x the bound away in draw set 0.
Checks run locally on this head
python3 -B tests/startup_gfx2hlsl_float_transcendental_check.py(controls, including the newulp distancecontrol): rc=0python3 tests/docs_links_check.py: ok (27 files, 541 links)python3 tests/bidi_controls_check.py: okgit diff --check origin/main...HEAD: cleanSmall points, not blockers
order()maps-0.0and+0.0to the same position, sov_log_f32would accept-0.0where+0.0is expected. The PR text says exact equality keeps them distinct; that is true only for bound 0. A one-line note in the docstring would be enough.v_log_f32, so it cannot exercise the tolerance branch; only the controls cover it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:20:59Z.
Review: COMMENTED
Review of head
76a5651a(comment review, no approval). It replaces my earlier review ofe29a8c84.What changed since
e29a8c84: one docstring line intests/startup_gfx2hlsl_lane_alu.py(a nonzero bound accepts -0.0 for +0.0 and back). It answers my signed-zero note. The rest of the diff against main is unchanged: 3 files,docs/experiments.md, the transcendental check, the lane runner.Are the 4 ulps justified by the D3D rules for
log? Yes.log(section 22.10.8), https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm . Quote: "If src0 is [0.5..2], absolute error must be no more than 2^-21. If src0 is (0..0.5) or (2..+INF], relative error must be no more than 2^-21."Logis the same operation (log2in HLSL lowers to it) and the DXIL documentation gives no tighter accuracy, so the D3D11 bound is the one that applies.8, 0.125, 1, 1024, 2^-20, 2, 2^30, 0.5), the spec bound in binary32 ulps of the result is 12, 12, (result 0), 20, 20, 4, 7.5, 8. The smallest is 4 (input 2.0, result 1.0, ulp 2^-23). So 4 is not wider than what the spec lets any adapter return on this fixture. There is no margin on that lane.Scope and mutations
'ulps': {'v_log_f32': 4}. The other five operations stay exact.within()on the 8 inputs: natural log, log10 andlog2 + 1are all rejected; reference +4 raw ulps accepted, +5 rejected. The mutated draw must read words within the bound of the mutation and outside the bound of the reference.Commands run on this head
python3 -B tests/startup_gfx2hlsl_float_transcendental_check.pyrc=0python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: cleanNot reproduced: the RTX 4090 words from #2797 (real-GPU run not available). WARP returns exact
v_log_f32words, so only the controls exercise the tolerance branch.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:17:48Z.
Win2025 WARP receipt for head
a91dd316after updating with main (PR diff unchanged since the reviewed heade29a8c84).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
a91dd316d5338b62606666fd3696f6dc4e132c42:--preset dev):cmake --build --preset dev -- -j 2):0.00s(configure0.00s)ctest --preset dev -R '^startup_gfx2hlsl_float_transcendental_(controls|warp)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (3.22s:startup_gfx2hlsl_float_transcendental_controls0.18s,startup_gfx2hlsl_float_transcendental_warp3.08s)/O2(--preset release):cmake --build --preset release -- -j 2):0.00s(configure0.00s)ctest --preset release -R '^startup_gfx2hlsl_float_transcendental_(controls|warp)$' --parallel 6 --no-tests=error --output-on-failure): 2/2 passed (3.09s:startup_gfx2hlsl_float_transcendental_controls0.18s,startup_gfx2hlsl_float_transcendental_warp2.95s)tests/startup_gfx2hlsl_cvt_alu_check.pyok (0.2s),tests/startup_gfx2hlsl_pack_b32_f16_check.pyok (0.1s)11.6sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:21:07Z.
Win2025 WARP receipt for head
76a5651a(supersedes the receipt fora91dd316).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
76a5651ac743b3daa032cab823d044f7c7bf5b1c:--preset dev):cmake --build --preset dev -- -j 2):0.00s(configure0.00s)ctest --preset dev -R '^startup_gfx2hlsl_float_transcendental_(controls|warp)$' --parallel 3 --no-tests=error --output-on-failure): 2/2 passed (3.50s:startup_gfx2hlsl_float_transcendental_controls0.18s,startup_gfx2hlsl_float_transcendental_warp3.36s)/O2(--preset release):cmake --build --preset release -- -j 2):0.00s(configure0.00s)ctest --preset release -R '^startup_gfx2hlsl_float_transcendental_(controls|warp)$' --parallel 3 --no-tests=error --output-on-failure): 2/2 passed (3.23s:startup_gfx2hlsl_float_transcendental_controls0.19s,startup_gfx2hlsl_float_transcendental_warp3.09s)tests/startup_gfx2hlsl_float_transcendental_check.pyok (0.2s)sccache: 0/3 hits; wall12.8sAI-assisted; commands listed were executed locally.