Repository navigation
Conversation
The reference kept a signalling NaN through mul:2 / mul:4 / div:2, while the translator's OpFMul quiets it, so a later v_cmp_class_f32 differed (seed 202, program 53: v_ldexp_f32 v5, -|v18|, v1 mul:2 with v18 = 0x7f800001, then a class test on bit 0). What the hardware does is not measured, so the program is now skipped as "output modifier on a signalling NaN", like the clamp of a NaN. Quiet NaNs and sNaNs without an omod are judged as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Reviewed head bf891c2.
python -I -m pytest tests/test_fmisc_diff.py -q-> 19 passed, 43 subtests.git diff --checkclean.
The guard inspects the pre-omod result (is_nan(w) and not (w & 0x400000)), and v_ldexp_f32 passes NaN through, so the new Uncertain fires for an sNaN while a qNaN result with omod is still judged and the no-omod sNaN case still returns SNAN. The docs sentence matches the skip reason. No blockers.
|
Tested bf891c2 merged with main 561b65a (PR already based on it) on Linux WSL2, Python 3.12.16: pass tests/test_fmisc_diff.py: 20 run, 20 passed, 0 failed. tests/test_docs_*.py: 33 run, 33 passed. tools/fmisc_diff.py --programs 300 --seed 1 (translator oracle, no GPU) runs to completion. Negative control: with tools/fmisc_diff.py restored to upstream/main, tests/test_fmisc_diff.py runs 20 tests with 1 failure (omod on an sNaN: Uncertain not raised). The doc and docstring sentences agree with the new out_mods() check (a signalling NaN is NaN with bit 22 clear; the hardware behaviour is stated as not measured, and I did not measure it either). No issue found. |
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean, minimal fix for the unmeasured sNaN + omod mismatch in tools/fmisc_diff.py. The binary32 quiet-bit check (om and is_nan(w) and not w & 0x400000) accurately distinguishes signalling NaNs of either sign from quiet NaNs before out_mods runs, and skipping with Uncertain("output modifier on a signalling NaN") is the right conservative behavior until hardware behavior is measured. Unit tests in tests/test_fmisc_diff.py cover all three boundaries (sNaN + omod skipped, sNaN without omod preserved, qNaN + omod still judged), and docs/shader_validation.md is updated in sync. Locally verified: tests/test_fmisc_diff.py (19 passed) and git diff --check clean. No game files. AI-assisted review (Gemini).
Claimed in #5361.
What and why
tools/fmisc_diff.pyreported a mismatch on main 3faac55 (seed 202, program 53):The reference returns 0 and the translator returns 1.0. The reference keeps the signalling NaN through the output modifier (class bit 0). The translator's omod is an
OpFMul, which quiets it, so the result reads as class bit 1. I probed the pattern withmul:2,div:2andmul:4on an sNaN result and it is the same for all three. Without an omod, both sides keep the sNaN, with or withoutneg/abs.Nobody has measured what RDNA2 does for an omod on a signalling NaN. So this PR does not pick a side. The reference raises
Uncertain("output modifier on a signalling NaN"), and the program counts as a skip with that reason, the same way the clamp of a NaN is handled. Quiet NaNs, and sNaNs without an omod, are judged as before.tools/fmisc_diff.py: the check inout_mods, plus a line in the "Not judged" docstring.tests/test_fmisc_diff.py: an omod on an sNaN raisesUncertain. Without an omod the sNaN is kept. An omod on a quiet NaN still gives a NaN.docs/shader_validation.md: the fmisc_diff paragraph lists the new not-judged case.Tested
Linux, Python 3.13 and 3.14, CPU only (the
spirv_mini_interpbackend), no GPU needed. AI-assisted.python3 -I tools/fmisc_diff.py --programs 3000 --seed 202: before (main, Python 3.13 on the rig host), 2675 pass, 1 mismatch, 324 skipped, exit 1. After (Python 3.14.4), 2669 pass, 0 mismatch, 331 skipped, 8 of themoutput modifier on a signalling NaN.Seeds 201, 203 and 204 (3000 programs each) were already clean on main. This change only adds skips.
pytest tests/test_fmisc_diff.py tests/test_docs_*.py: 49 passed, 49 subtests passed.Merges cleanly with the other open PRs that touch
tools/fmisc_diff.py: fmisc_diff: v_fract_f32 passes a NaN through and gives 0xffc00000 for +-inf, as measured on gfx1036 #4629, cf_diff, mem_diff, shader_diff, fmisc_diff: exit 2 when every program was skipped, not 0 (as #4365, #4376) #4448 and hw_oracle: state the float MODE explicitly and add a strict mode check #4354.No game data, keys or decryption changes.
🤖 Generated with Claude Code