tests: classify mad() fusion from the thread-dependent mac_f32 words (#2883) #2892
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2892"
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-26T16:47:11Z.
On a GPU that fuses
FMad,compute_store_aot_mac_f32_hardwarefailed in the fusion probe that #2844 added. This changes only the test. The translator, the lowering and the reference models stay as they are.Cause
mac_f32_mad_fusion()told the fused and unfused models apart at word 0, which is4097 * 4097 - 16785408. Every operand of word 0 is a constant, so DXC folds itsmad()at compile time to the unfused+0. The thread-dependent words remain run-timeFMad. An RTX 4090 fuses those, so the mutated readback had word 0 unfused and word 2 fused, and matched neither model. #2883 has the details.Change
Probe model. The probe's fused model is now
mac_f32_words(fused=True)with word 0 set to its folded, unfused value. Word 3 is exact in both models. The two models now differ only at the thread-dependent words 2, 10, 18, …, and an assert checks that the first difference is at word 2.mac_f32_words(fused=True)itself is unchanged, so the "fused FMA instead of unfused MAC" reference control still checks word 0.Error message. A "neither model" failure now names each model's first mismatch. The renderer prints only the first one.
Simulated controls.
mac_f32_controls()runs the probe against a simulated renderer. It runs at the start of everycompute_store_check.pymode.unfusedfusedneither model alonefailed (exit 3)After each run that returns a result, the case file again holds the expected model.
Docs. The
docs/experiments.mdparagraph on this probe now describes the folded word 0.Evidence
Commit
cc207f9aonmainb505c32b.Environment
devpreset.dxcompiler.dll1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.10de:2684), driver 32.0.16.1088.1414:008c), 10.0.26100.9818.debug_errors=0 debug_warnings=0.Before the change (
b505c32b):The unmutated draw matched (
compared_words=320 mismatches=0), then the probe failed:After the change:
I ran the RTX 4090 test and the WARP test one at a time.
compute_store_aot_mac_f32_hardware(RTX 4090)compared_words=320 mismatches=0, thenmac_f32: mad() fusion probe (hardware): fused. The strict check then ran and caught the "fused mad() instead of unfused multiply+add" mutation. If it had not, the test would have raisedescaped detection.compute_store_aot_mac_f32_warpcompared_words=320 mismatches=0. Themad()mutation runs only on the hardware backend, so WARP runs the four reference controls and the other two mutations, as before.docs_links,bidi_controlsBoth
mac_f32runs also ran the new simulated controls inmac_f32_controls(), and they passed.git diff --checkis clean. No test returned 77.Negative control for the fix. I ran the new
mac_f32_controls()with the oldmac_f32_mad_fusion()fromb505c32bin its place. The folded fused readback failed with the sameneither model alone: {'fused': False, 'unfused': False}error as the RTX 4090.Not run
unfusedpath (the RX 5700 XT in #2730) is covered only by the simulated control. That path is unchanged: the unfused model is stillexpected, and the probe's fused model still differs from it, at word 2.binarymode oftests/compute_store_check.pyand the Linux CI job. Both needllvm-mc, which this machine doesn't have.mac_f32_controls()also runs in those modes.Limitation. The probe assumes that DXC folds word 0 unfused, as DXC 1.9.2602.17 does. If a DXC leaves word 0 to the driver, a fusing GPU would read back neither model, and the test would fail with the first-mismatch detail rather than pass.
Fixes #2883
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T17:05:51Z.
Independent AMD RDNA 4 result on
cc207f9a: the probe classifies an unfused adapter, and the word-0 fold is pinned without a fusing cardEnvironment
1002:7550, gfx1201), driver 32.0.32029.2010dxcompiler.dll1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.0devpreset, hardware backend,debug_layer=unavailabledocs/experiments.mdandtests/compute_store_check.pyonly), so both runs below use the sameoffscreen_check.exe; the A/B is on the fixture alone.tests/compute_store_check.pyatcc207f9a: sha2560930552b33b0fcbebf843c85bc2ea28c526596ffbddc927462bc3fce05d2d7c2(CRLF checkout on Windows).Commands
Observed — parent
b505c32band headcc207f9aBoth exit 0, and these lines are identical on the two trees; the logs differ only by the timing field:
So an adapter that already classified
unfusedis unaffected by the change — the case you could not check on a 4090.The reported failure reproduces on the CPU-only path
Feeding both fixture versions the readback #2883 describes (thread-dependent words fused, word 0 at the folded
+0):40400004/40400003is the pair your issue quotes at word 2. This is a reproduction, not an independent oracle: the injected readback is built from the samemac_f32_words(fused=True)table the probe compares against, so on the head the fused model matches itself. What it establishes is thatb505c32bcannot classify the shape from #2883 andcc207f9acan, on any machine. The independent evidence that a fusing GPU reads back that shape is the DXIL below plus your 4090 run.The fold is pinned by a CPU control
Removing only
fused[0::4] = expected[0::4](line 3781) and running the same entry: exit 8 after 0.92 s, with no draw at all:Restored with
git checkout --, tracked tree clean, entry green again (3.23 s). That mutant is notb505c32b: it removes only the fold and keeps the new simulated controls, so it pins the fold, not the original bug —b505c32bis covered by the runs above. It dies at the first simulated probe (3751), on the== 2invariant insidemac_f32_mad_fusion()(line 3782 at the head; 3781 in the mutant, where that line is gone), so the fold is pinned by a CPU control even on an adapter that never fuses FMad.DXIL
dxc -dumpbinon the mutated shader compiled by the fixture itself, with the fixture's own flags: two run-timedx.op.tertiary.f32, and the store line your report quotes verbatim, with word 0 folded to the literali32 0:This dump is the only link in the chain that the Python model does not manufacture.
Regression
^compute_store_aot_at the head:Total Tests: 180,100% tests passed out of 180, none skipped. That run, not the single-entry A/B, is what shows the new control is safe:controls()at line 9979 runsmac_f32_controls()before the mode dispatch, so it now executes on every invocation of the fixture, and the other 179 entries stayed green.Limits
fusion == "unfused"here, so the strict branch — afused mad()mutant that must be caught: appended only forhardwareat 3832-3837, probed and abandoned at 3845-3853 — is not exercised on this card. Nothing here says anything about the fusing path on hardware.debug_layer=unavailable, so no validation output.probe()compiles nothing: the fold is asserted, not measured. The fix encodes the behaviour of DXC 1.9.2602.17; a DXC that leaves word 0 to the driver would make the head fail where the base passed, as the docstring at 3778 notes.2 (mod 8); that the whole set agrees is not asserted.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T17:33:23Z.
I'll check this on a second card that may fuse
FMad: an RTX 3070 (Ampere, desktop) plus WARP, with the debug layer on. I'll runcompute_store_aot_mac_f32_hardwareon main6ee878d8and oncc207f9a(sameoffscreen_check.exe, only the fixture changes), and run thebinarymode with LLVM 15llvm-mc. Results will follow here.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T18:18:56Z.
NVIDIA result on
cc207f9a: this adapter fusesmad(), and the PR fixes the failure from #2883 here.Environment: Windows 11 25H2 (26200), MSVC 19.42,
devpreset, freshout/pe-env, NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 621.35 (32.0.16.2135), D3D12 debug layer on (0 errors, 0 warnings). The PR changes onlytests/compute_store_check.pyand docs, so both runs use the same build; only the fixture file differs.Command
Head
cc207f9a(2 runs): 2/2 passed, ctest exit 0 both times.Negative control, fixture from the parent
b505c32b:compute_store_aot_mac_f32_hardwarefails, ctest exit 8 (WARP passes):So with the old probe a fusing NVIDIA card matches neither model; with the new classification it reads
fusedand the test passes. I did not run thebinarymode withllvm-mc.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T18:33:27Z.
Independent review of head
cc207f9a42d79da5a6ba610930b2f4e59be4f54d: PASS, on an NVIDIA Ampere desktop card that fusesFMad. The other fusing results in this thread are both Ada (the RTX 4090 in #2883 and the RTX 4070 Ti above). I also read back all 320 words of the mutated shader without the fixture's model; see below.Environment
10de:2484), driver 32.0.16.2101; WARP 10.0.26100.9818devpresetdxcompiler.dll1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.0, the same build as in #2883debug_errors=0 debug_warnings=0.offscreen_checkwas built separately from each tree. Tests ran serially (-j 1) on an otherwise idle machine.Before: main
6ee878d8tests/compute_store_check.pyon main is byte-identical to the PR's parentb505c32b.compared_words=320 mismatches=0). The probe then fails withmad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}, which is #2883 on Ampere as well as on Ada.compute_store_aot_mac_f32_warp: passed.^compute_store_aot_family: 179/180. The only red iscompute_store_aot_mac_f32_hardware.After:
cc207f9amac_f32: mad() fusion probe (hardware): fused, then the strict check ran the "fused mad() instead of unfused multiply+add" mutation.compute_store_aot_mac_f32_warp: passed.^compute_store_aot_: 180/180.docs_links,bidi_controls: passed.git merge-tree).A full readback of the mutated shader, without the fixture's model
The probe asserts only the first word where the two models differ, and the renderer reports only the first differing word. To check the whole buffer:
mad()mutation with the same DXC.offscreen_check --compute-store-case, each time setting the reported word to the value read back, until all 320 words matched. That took 33 runs on the RTX 3070 and 1 on WARP.mac_f32_words(). Unfused: the product rounded to f32, then the add. Fused: the exact rationala*b + c, rounded once to f32.00000000), all 6440400003, word 1040400009)40400004,40400008)This is exactly the head's fused model,
mac_f32_words(fused=True)with[0::4]taken from the unfused one, on all 320 words. It also shows that DXC folds the constant word in all 64 threads, not just thread 0, which is what the[0::4]slice assumes.dxc -dumpbinof the same mutated shader shows two run-timedx.op.tertiary.f32(i32 46, …)(FMad) calls. The store has word 0 as the literali32 0, the same line as in #2883.binarymodeI said earlier that I would run it with LLVM 15
llvm-mc. I couldn't: on Windows I don't have alibLLVM-15for the library argument. The PR's own CI run did run it with the real tools: in the "Assemble and translate gfx1013 fixtures" job (merge7127a6cofcc207f9aintob505c32b),tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1reportsok(117.8 s). Its startupcontrols()includes the newmac_f32_controls().Not covered
No changes requested.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:24:40Z.
Review: COMMENTED
tests: classify mad() fusion from the thread-dependent mac_f32 words
Well-reasoned test-only fix. The root cause is clear: word 0 has constant operands that DXC folds at compile time, making the fused and unfused models converge there. Moving the probe to word 3 (thread-dependent) restores the separation needed to distinguish GPU behavior.
Observations
mac_f32_controls()helper correctly simulates both unfused and folded-fused readbacksNotes
Verdict: Clean fix. Ready for final review pass — this should be a quick approve.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:47:01Z.
Review: APPROVED
Independent review of
cc207f9aintegrated withmainf5204690(5e75c126locally). The changed fusion classifier keeps the compiler-folded first word in the unfused form and distinguishes the two runtime models at thread-dependent words. The existing instruction result and fused-FMA control retain the original reference model.I rebuilt
offscreen_checkand ranctest --preset <dev|release> --no-tests=error -V -R '^compute_store_aot_mac_f32_(warp|hardware)$'. Debug and Release/O2each passed 2/2 with no skips. Both hardware runs classified the RTX 4060 Laptop as fused, directly exercising #2883’s affected path. WARP also passed. Windows 11 build 26200.9974, RTX driver 32.0.16.1656, WARP 10.0.26100.9818, SDK 10.0.26100 DXC. The test uses the offscreen renderer's default debug settings. Hosted Windows, Linux Python and gfx1013 fixture checks passed. The hosted/O2job skipped and the local/O2retest passed.