fmisc_diff: do not judge the class bits of a NaN whose quiet bit is unmodelled #1659
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1659
Loading…
Reference in a new issue
No description provided.
Delete branch "snan-fma-cmpclass"
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?
Pull request successfully merged and closed
Fuzz-campaign follow-up (coordination issue #14; its comment thread is at the cap so context lives here):
fmisc_diffreported a divergence where an sNaN throughv_fmamk_f32flipped thev_cmp_class_f32result bit on both AMD gfx1036 and NVIDIA RTX 4070 SUPER.Root cause is not the translator: hardware itself does not deterministically preserve the NaN quiet bit — measured on gfx1036 under the game'''s MODE (IEEE off, denormal flush), an sNaN operand mostly passes through
v_fmamk_f32unchanged but is quieted in edge cases. The translator'''s output matched what the hardware produces on both GPUs; the fuzzer'''s reference model simply had no way to express "this NaN'''s quiet bit is unknown".What
tools/fmisc_diff.pygainsst["nanf"]— a set of VGPRs holding a computed NaN whose quiet bit is not modelled. It is set whenv_fmamk_f32sees a signalling-NaN (or already-fuzzy NaN) operand and propagates through the pass-through ops (v_fract_f32,v_frexp_mant_f32,v_frexp_exp_i32_f32,v_ldexp_f32, theNAN_PASSTHROUGHset) andv_mov_b32/v_cndmask_b32_e64; it clears on any fully-modelled result.v_cmp_class_f32on ananfregister raisesUncertain(aSkipsubclass) instead of producing a false mismatch.docs/shader_validation.mdrecords the measurement and the conclusion.Verification
tests/test_fmisc_diff.py: 35 tests pass, including the newtest_class_of_a_computed_nan(sNaN→fmamk→class raisesUncertain; fuzzy NaN surviving a pass-through still raises; quiet-NaN and exact-sNaN cases are still judged — guards against over-skipping).tools/fmisc_diff.py --programs 3000 --seed 11 --max-ops 8(translator oracle): 2512 pass, 0 mismatch, 488 skipped; a targeted 2000-program run produced 4 skips with the new reason and 0 mismatches.Independent review: APPROVE —
nanfcoverage is complete for the ops this fuzzer models (v_fmamk_f32is the only NaN-minting op in its set; other producers raiseRefError),Uncertainflows through the skip path correctly, and the tests fail without the fix. Non-blocking notes left for a possible follow-up:v_cmp_classcould skip only whenmask & 3is exactly one of the NaN class bits (masks00/11are deterministic either way), and one copy/cndmaskpropagation case could be added to the test.AI-assisted (Devin).
Claimed in the coordination issue as: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7259693905
Tested
36f2621aeon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain3f81d46ac(Python differential tool; no GPU run):tests/test_fmisc_diff.py: 35 passed, 49 subtests passed at this head.main: 1 failed (Reference::test_class_of_a_computed_nan), 34 passed, 49 subtests — that is the sNaN class-bit judgement the PR changes; the rest of the file is unchanged.AI-assisted; synthetic fixtures only, no game data.
Rebased cleanly onto current main (
db1a22d29) asfc3342fd2to refresh the stale CI baseline; no conflicts. The branch is unchanged:fmisc_diffno longer judges the class bits of a NaN whose quiet bit the translator does not model. AI-assisted with Devin.Hi @whoalin1, thanks for this pull request.
CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post
claiming: <ID>there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.
Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.
AI-assisted (Claude Code, Claude Opus 5.5).
#1659 | head fc3342fd218fe6d73065e08fc937b9d50c8c3873 (merged cleanly with main 1bc055e6c2) |
python -I tests/test_fmisc_diff.py+python -I tools/fmisc_diff.py --programs 500 --seed 7| red on main:FAILED (failures=1)(Reference.test_class_of_a_computed_nandid not raiseUncertainwhenv_fmamk_f32with an sNaN operand fedv_cmp_class_f32) | green on PR+main:35 tests OK+500 programs: 456 pass, 0 mismatch, 44 skipped| Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited rebased head
fc3342fd21acrosstools/fmisc_diff.py,tests/test_fmisc_diff.py, anddocs/shader_validation.mdon Windows 11, verifyingst["nanf"]tracking for unmodelled quiet bits fromv_fmamk_f32(including survival acrossNAN_PASSTHROUGHops andv_mov_b32/v_cndmask_b32, in-place destination aliasing safety, and exact preservation of quiet-NaN and pure pass-through sNaNv_cmp_class_f32checks). Also verifiedtests/test_docs_encoding.py(1 OK),tests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Tested
fc3342fd2merged (no commit) withmain829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_fmisc_diff.py, 35 tests pass.tools/fmisc_diff.pyback tomain, 1 failure (Uncertain not raised).No blocker from my side.
AI-assisted (Claude Code).
Tested green here earlier on this same head (see my comment above). The only thing missing for a merge is your claim in the coordination issue #2570.
AI-assisted (Claude Code).
Added the missing coordination-issue claim and linked it in the PR body: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7259693905. No code changes.
Tested
fc3342fd2merged (no commit) withmain4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.python -I tests/test_fmisc_diff.pygives 35 OK.tools/fmisc_diff.pyback tomain:FAILED (failures=1).8db8335d2).AI-assisted (Claude Code).
The implementation claim is in the current coordination issue here: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7259693905. I also added the corresponding
done:entry linking it back to this PR: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7260636580.Rebased onto current
mainasac58ddc50to refresh the stale CI baseline; the single-commit branch reapplied cleanly with no conflicts. Validation after rebase:pytest tests/test_fmisc_diff.pypasses 35 tests + 49 subtests under Python 3.12;py_compileandgit diff --checkare clean.Verified by MoonEyes (another person than the author) on head
ac58ddc50merged withmain501b3e6c5: Windows 11, Python 3.14, no GPU and no SPIR-V tools used beyond what the tests find here.tests/test_fmisc_diff.py35 OK; withtools/fmisc_diff.pyback tomain, 1 failure. I read the diff: the tool and its test (and a docs line for #1659), nothing the game's build uses.AI-assisted (Claude Code).
Merging. Head
ac58ddc50merges cleanly withmain653f60d37and does not force a rebase of #2566. CI green on this head and on main. I ran it on main + PR (Windows, Python 3.14): 35 tests OK, 1 failure without the change. A validation tool, its test and a docs line. Merged by MoonEyes.AI-assisted (Claude Code).