tests: classify mad() fusion from the thread-dependent mac_f32 words (#2883) #2892

Merged
Not-Saii merged 1 commit from upstream-pr/2892 into main 2026-11-27 06:47:26 +00:00
Not-Saii commented 2026-11-26 16:47:11 +00:00 (Migrated from github.com)

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_hardware failed 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 is 4097 * 4097 - 16785408. Every operand of word 0 is a constant, so DXC folds its mad() at compile time to the unfused +0. The thread-dependent words remain run-time FMad. 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 every compute_store_check.py mode.

    Simulated mutated readback Expected result
    Unfused model (no fusion, as on the RX 5700 XT in #2730) unfused
    Fused threads with word 0 folded unfused (as on the RTX 4090) fused
    Fully fused model raises neither model alone
    Renderer exit 3 raises failed (exit 3)

    After each run that returns a result, the case file again holds the expected model.

  • Docs. The docs/experiments.md paragraph on this probe now describes the folded word 0.

Evidence

Commit cc207f9a on main b505c32b.

Environment

  • Windows 11 build 26300.9974, dev preset.
  • DXC dxcompiler.dll 1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.
  • Hardware: NVIDIA GeForce RTX 4090 (10de:2684), driver 32.0.16.1088.
  • WARP: Microsoft Basic Render Driver (1414:008c), 10.0.26100.9818.
  • The test enabled the debug layer on both adapters and reported debug_errors=0 debug_warnings=0.

Before the change (b505c32b):

ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' --output-on-failure

The unmutated draw matched (compared_words=320 mismatches=0), then the probe failed:

AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}

After the change:

ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' -V
ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_warp$' -V
ctest --preset dev --no-tests=error -R '^(docs_links|bidi_controls)$'

I ran the RTX 4090 test and the WARP test one at a time.

Test Result Output
compute_store_aot_mac_f32_hardware (RTX 4090) Passed compared_words=320 mismatches=0, then mac_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 raised escaped detection.
compute_store_aot_mac_f32_warp Passed compared_words=320 mismatches=0. The mad() mutation runs only on the hardware backend, so WARP runs the four reference controls and the other two mutations, as before.
docs_links, bidi_controls Passed

Both mac_f32 runs also ran the new simulated controls in mac_f32_controls(), and they passed. git diff --check is clean. No test returned 77.

Negative control for the fix. I ran the new mac_f32_controls() with the old mac_f32_mad_fusion() from b505c32b in its place. The folded fused readback failed with the same neither model alone: {'fused': False, 'unfused': False} error as the RTX 4090.

Not run

  • RDNA 1 hardware. The unfused path (the RX 5700 XT in #2730) is covered only by the simulated control. That path is unchanged: the unfused model is still expected, and the probe's fused model still differs from it, at word 2.
  • The binary mode of tests/compute_store_check.py and the Linux CI job. Both need llvm-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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5513939332 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T16:47:11Z. --- On a GPU that fuses `FMad`, `compute_store_aot_mac_f32_hardware` failed 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 is `4097 * 4097 - 16785408`. Every operand of word 0 is a constant, so DXC folds its `mad()` at compile time to the unfused `+0`. The thread-dependent words remain run-time `FMad`. 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 every `compute_store_check.py` mode. | Simulated mutated readback | Expected result | |---|---| | Unfused model (no fusion, as on the RX 5700 XT in #2730) | `unfused` | | Fused threads with word 0 folded unfused (as on the RTX 4090) | `fused` | | Fully fused model | raises `neither model alone` | | Renderer exit 3 | raises `failed (exit 3)` | After each run that returns a result, the case file again holds the expected model. - **Docs.** The `docs/experiments.md` paragraph on this probe now describes the folded word 0. ## Evidence Commit `cc207f9a` on `main` `b505c32b`. **Environment** - Windows 11 build 26300.9974, `dev` preset. - DXC `dxcompiler.dll` 1.9.2602.17 (`21d28f727`), from Windows SDK 10.0.26100. - Hardware: NVIDIA GeForce RTX 4090 (`10de:2684`), driver 32.0.16.1088. - WARP: Microsoft Basic Render Driver (`1414:008c`), 10.0.26100.9818. - The test enabled the debug layer on both adapters and reported `debug_errors=0 debug_warnings=0`. **Before the change** (`b505c32b`): ```powershell ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' --output-on-failure ``` The unmutated draw matched (`compared_words=320 mismatches=0`), then the probe failed: ```text AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False} ``` **After the change:** ```powershell ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' -V ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_warp$' -V ctest --preset dev --no-tests=error -R '^(docs_links|bidi_controls)$' ``` I ran the RTX 4090 test and the WARP test one at a time. | Test | Result | Output | |---|---|---| | `compute_store_aot_mac_f32_hardware` (RTX 4090) | Passed | `compared_words=320 mismatches=0`, then `mac_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 raised `escaped detection`. | | `compute_store_aot_mac_f32_warp` | Passed | `compared_words=320 mismatches=0`. The `mad()` mutation runs only on the hardware backend, so WARP runs the four reference controls and the other two mutations, as before. | | `docs_links`, `bidi_controls` | Passed | | Both `mac_f32` runs also ran the new simulated controls in `mac_f32_controls()`, and they passed. `git diff --check` is clean. No test returned 77. **Negative control for the fix.** I ran the new `mac_f32_controls()` with the old `mac_f32_mad_fusion()` from `b505c32b` in its place. The folded fused readback failed with the same `neither model alone: {'fused': False, 'unfused': False}` error as the RTX 4090. **Not run** - RDNA 1 hardware. The `unfused` path (the RX 5700 XT in #2730) is covered only by the simulated control. That path is unchanged: the unfused model is still `expected`, and the probe's fused model still differs from it, at word 2. - The `binary` mode of `tests/compute_store_check.py` and the Linux CI job. Both need `llvm-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).
thepatrickworld commented 2026-11-26 17:05:51 +00:00 (Migrated from github.com)

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 card

Environment

  • AMD Radeon RX 9070 XT (1002:7550, gfx1201), driver 32.0.32029.2010
  • Windows 10.0.26200.9974
  • DXC dxcompiler.dll 1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.0
  • dev preset, hardware backend, debug_layer=unavailable
  • The PR touches no C++ (docs/experiments.md and tests/compute_store_check.py only), so both runs below use the same offscreen_check.exe; the A/B is on the fixture alone. tests/compute_store_check.py at cc207f9a: sha256 0930552b33b0fcbebf843c85bc2ea28c526596ffbddc927462bc3fce05d2d7c2 (CRLF checkout on Windows).

Commands

ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' -V
ctest --preset dev --no-tests=error -R '^compute_store_aot_' -j4 --timeout 300

Observed — parent b505c32b and head cc207f9a

Both exit 0, and these lines are identical on the two trees; the logs differ only by the timing field:

adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550
driver=32.0.32029.2010
groups=1 compared_words=320 mismatches=0
mac_f32: mad() fusion probe (hardware): unfused
mac_f32: mutation 'fused mad() instead of unfused multiply+add' is inapplicable on this adapter: mad() reads back the unfused model on all 320 words
1/1 Test #1888: compute_store_aot_mac_f32_hardware ...   Passed    3.62 sec

So an adapter that already classified unfused is 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):

word0 folded=00000000 fused=3f800000 unfused=00000000
word2 folded=40400003 unfused=40400004
base b505c32b: raises "mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}"
head cc207f9a: returns 'fused'

40400004/40400003 is the pair your issue quotes at word 2. This is a reproduction, not an independent oracle: the injected readback is built from the same mac_f32_words(fused=True) table the probe compares against, so on the head the fused model matches itself. What it establishes is that b505c32b cannot classify the shape from #2883 and cc207f9a can, 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:

File "compute_store_check.py", line 9979, in <module>           controls()
File "compute_store_check.py", line 373,  in controls           mac_f32_controls()
File "compute_store_check.py", line 3751, in mac_f32_controls   assert probe(expected) == "unfused"
File "compute_store_check.py", line 3781, in mac_f32_mad_fusion assert next(...) == 2
AssertionError

Restored with git checkout --, tracked tree clean, entry green again (3.23 s). That mutant is not b505c32b: it removes only the fold and keeps the new simulated controls, so it pins the fold, not the original bug — b505c32b is covered by the runs above. It dies at the first simulated probe (3751), on the == 2 invariant inside mac_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 -dumpbin on the mutated shader compiled by the fixture itself, with the fixture's own flags: two run-time dx.op.tertiary.f32, and the store line your report quotes verbatim, with word 0 folded to the literal i32 0:

call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle %1, i32 %9, i32 undef, i32 0, i32 %6, i32 %8, i32 -1072693248, i8 15)

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 runs mac_f32_controls() before the mode dispatch, so it now executes on every invocation of the fixture, and the other 179 entries stayed green.

Limits

  • One adapter, one driver, one DXC build. fusion == "unfused" here, so the strict branch — a fused mad() mutant that must be caught: appended only for hardware at 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.
  • The assert pins only the first differing word (2). After the fold the two models differ at 32 of the 320 words, all 2 (mod 8); that the whole set agrees is not asserted.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7198495085 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#issuecomment-7198495085). Originally posted by [thepatrickworld](https://github.com/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 card** ### Environment - AMD Radeon RX 9070 XT (`1002:7550`, gfx1201), driver 32.0.32029.2010 - Windows 10.0.26200.9974 - DXC `dxcompiler.dll` 1.9.2602.17 (`21d28f727`), from Windows SDK 10.0.26100.0 - `dev` preset, hardware backend, `debug_layer=unavailable` - The PR touches no C++ (`docs/experiments.md` and `tests/compute_store_check.py` only), so both runs below use the same `offscreen_check.exe`; the A/B is on the fixture alone. `tests/compute_store_check.py` at `cc207f9a`: sha256 `0930552b33b0fcbebf843c85bc2ea28c526596ffbddc927462bc3fce05d2d7c2` (CRLF checkout on Windows). ### Commands ``` ctest --preset dev --no-tests=error -R '^compute_store_aot_mac_f32_hardware$' -V ctest --preset dev --no-tests=error -R '^compute_store_aot_' -j4 --timeout 300 ``` ### Observed — parent `b505c32b` and head `cc207f9a` Both exit 0, and these lines are identical on the two trees; the logs differ only by the timing field: ``` adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550 driver=32.0.32029.2010 groups=1 compared_words=320 mismatches=0 mac_f32: mad() fusion probe (hardware): unfused mac_f32: mutation 'fused mad() instead of unfused multiply+add' is inapplicable on this adapter: mad() reads back the unfused model on all 320 words 1/1 Test #1888: compute_store_aot_mac_f32_hardware ... Passed 3.62 sec ``` So an adapter that already classified `unfused` is 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`): ``` word0 folded=00000000 fused=3f800000 unfused=00000000 word2 folded=40400003 unfused=40400004 base b505c32b: raises "mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}" head cc207f9a: returns 'fused' ``` `40400004`/`40400003` is the pair your issue quotes at word 2. This is a reproduction, not an independent oracle: the injected readback is built from the same `mac_f32_words(fused=True)` table the probe compares against, so on the head the fused model matches itself. What it establishes is that `b505c32b` cannot classify the shape from #2883 and `cc207f9a` can, 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: ``` File "compute_store_check.py", line 9979, in <module> controls() File "compute_store_check.py", line 373, in controls mac_f32_controls() File "compute_store_check.py", line 3751, in mac_f32_controls assert probe(expected) == "unfused" File "compute_store_check.py", line 3781, in mac_f32_mad_fusion assert next(...) == 2 AssertionError ``` Restored with `git checkout --`, tracked tree clean, entry green again (3.23 s). That mutant is not `b505c32b`: it removes only the fold and keeps the new simulated controls, so it pins the fold, not the original bug — `b505c32b` is covered by the runs above. It dies at the first simulated probe (3751), on the `== 2` invariant inside `mac_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 -dumpbin` on the mutated shader compiled by the fixture itself, with the fixture's own flags: two run-time `dx.op.tertiary.f32`, and the store line your report quotes verbatim, with word 0 folded to the literal `i32 0`: ``` call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle %1, i32 %9, i32 undef, i32 0, i32 %6, i32 %8, i32 -1072693248, i8 15) ``` 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 runs `mac_f32_controls()` before the mode dispatch, so it now executes on every invocation of the fixture, and the other 179 entries stayed green. ### Limits - One adapter, one driver, one DXC build. `fusion == "unfused"` here, so the strict branch — a `fused mad()` mutant that must be caught: appended only for `hardware` at 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. - The assert pins only the first differing word (2). After the fold the two models differ at 32 of the 320 words, all `2 (mod 8)`; that the whole set agrees is not asserted. _AI-assisted._
roansystemlabs commented 2026-11-26 17:33:23 +00:00 (Migrated from github.com)

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 run compute_store_aot_mac_f32_hardware on main 6ee878d8 and on cc207f9a (same offscreen_check.exe, only the fixture changes), and run the binary mode with LLVM 15 llvm-mc. Results will follow here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7199222003 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#issuecomment-7199222003). Originally posted by [roansystemlabs](https://github.com/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 run `compute_store_aot_mac_f32_hardware` on main `6ee878d8` and on `cc207f9a` (same `offscreen_check.exe`, only the fixture changes), and run the `binary` mode with LLVM 15 `llvm-mc`. Results will follow here. AI-assisted.
SimSalabimse commented 2026-11-26 18:18:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T18:18:56Z.


NVIDIA result on cc207f9a: this adapter fuses mad(), and the PR fixes the failure from #2883 here.

Environment: Windows 11 25H2 (26200), MSVC 19.42, dev preset, fresh out/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 only tests/compute_store_check.py and docs, so both runs use the same build; only the fixture file differs.

Command

ctest --preset dev --no-tests=error -R "^compute_store_aot_mac_f32" --output-on-failure -V -j 1

Head cc207f9a (2 runs): 2/2 passed, ctest exit 0 both times.

adapter=NVIDIA GeForce RTX 4070 Ti vendor=10de device=2782
driver=32.0.16.2135
groups=1 compared_words=320 mismatches=0
debug_errors=0 debug_warnings=0
mac_f32: mad() fusion probe (hardware): fused

Negative control, fixture from the parent b505c32b: compute_store_aot_mac_f32_hardware fails, ctest exit 8 (WARP passes):

groups=1 compared_words=320 mismatches=0
AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}

So with the old probe a fusing NVIDIA card matches neither model; with the new classification it reads fused and the test passes. I did not run the binary mode with llvm-mc.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7200313342 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#issuecomment-7200313342). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T18:18:56Z. --- NVIDIA result on `cc207f9a`: this adapter fuses `mad()`, and the PR fixes the failure from #2883 here. **Environment:** Windows 11 25H2 (26200), MSVC 19.42, `dev` preset, fresh `out/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 only `tests/compute_store_check.py` and docs, so both runs use the same build; only the fixture file differs. **Command** ``` ctest --preset dev --no-tests=error -R "^compute_store_aot_mac_f32" --output-on-failure -V -j 1 ``` **Head `cc207f9a` (2 runs):** 2/2 passed, ctest exit 0 both times. ``` adapter=NVIDIA GeForce RTX 4070 Ti vendor=10de device=2782 driver=32.0.16.2135 groups=1 compared_words=320 mismatches=0 debug_errors=0 debug_warnings=0 mac_f32: mad() fusion probe (hardware): fused ``` **Negative control, fixture from the parent `b505c32b`:** `compute_store_aot_mac_f32_hardware` fails, ctest exit 8 (WARP passes): ``` groups=1 compared_words=320 mismatches=0 AssertionError: mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False} ``` So with the old probe a fusing NVIDIA card matches neither model; with the new classification it reads `fused` and the test passes. I did not run the `binary` mode with `llvm-mc`. AI-Assisted
roansystemlabs commented 2026-11-26 18:33:27 +00:00 (Migrated from github.com)

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 fuses FMad. 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

  • NVIDIA GeForce RTX 3070 (10de:2484), driver 32.0.16.2101; WARP 10.0.26100.9818
  • Windows 11 25H2, build 26200.9974; MSVC 14.44, dev preset
  • DXC dxcompiler.dll 1.9.2602.17 (21d28f727), from Windows SDK 10.0.26100.0, the same build as in #2883
  • D3D12 debug layer enabled. Every verbose run printed debug_errors=0 debug_warnings=0.
  • offscreen_check was built separately from each tree. Tests ran serially (-j 1) on an otherwise idle machine.

Before: main 6ee878d8

tests/compute_store_check.py on main is byte-identical to the PR's parent b505c32b.

ctest --preset dev --no-tests=error -j 1 -R '^compute_store_aot_mac_f32_hardware$' -V   # x3
  • All 3 runs failed with the same output. The unmutated draw matches (compared_words=320 mismatches=0). The probe then fails with mad() 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.
  • The whole ^compute_store_aot_ family: 179/180. The only red is compute_store_aot_mac_f32_hardware.

After: cc207f9a

  • Same command, x3: all 3 passed. Each run printed mac_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.
  • The PR merges cleanly into current main (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:

  • I compiled the fixture's mad() mutation with the same DXC.
  • I ran it through 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.
  • I computed the reference values separately, without mac_f32_words(). Unfused: the product rounded to f32, then the add. Fused: the exact rational a*b + c, rounded once to f32.
words RTX 3070 WARP
word 0 of every thread (64, constant operands) unfused (00000000), all 64 unfused
word 2, even threads (32 words: 2, 10, 18, …) fused (e.g. word 2 40400003, word 10 40400009) unfused (40400004, 40400008)
word 2, odd threads; words 1 and 3 (both models agree) match match
64 words past the group sentinel untouched sentinel untouched
words that match neither model 0 0

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 -dumpbin of the same mutated shader shows two run-time dx.op.tertiary.f32(i32 46, …) (FMad) calls. The store has word 0 as the literal i32 0, the same line as in #2883.

binary mode

I said earlier that I would run it with LLVM 15 llvm-mc. I couldn't: on Windows I don't have a libLLVM-15 for the library argument. The PR's own CI run did run it with the real tools: in the "Assemble and translate gfx1013 fixtures" job (merge 7127a6c of cc207f9a into b505c32b), tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 reports ok (117.8 s). Its startup controls() includes the new mac_f32_controls().

Not covered

  • RDNA 1/2/3 hardware; Intel.
  • A DXC that leaves word 0 to the driver. The docstring already says such a DXC would fail here with the first-mismatch detail. That is the right outcome.

No changes requested.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7200596333 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#issuecomment-7200596333). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-26T18:33:27Z. --- Independent review of head `cc207f9a42d79da5a6ba610930b2f4e59be4f54d`: **PASS**, on an NVIDIA Ampere desktop card that fuses `FMad`. 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 - NVIDIA GeForce RTX 3070 (`10de:2484`), driver 32.0.16.2101; WARP 10.0.26100.9818 - Windows 11 25H2, build 26200.9974; MSVC 14.44, `dev` preset - DXC `dxcompiler.dll` 1.9.2602.17 (`21d28f727`), from Windows SDK 10.0.26100.0, the same build as in #2883 - D3D12 debug layer enabled. Every verbose run printed `debug_errors=0 debug_warnings=0`. - `offscreen_check` was built separately from each tree. Tests ran serially (`-j 1`) on an otherwise idle machine. ### Before: main `6ee878d8` `tests/compute_store_check.py` on main is byte-identical to the PR's parent `b505c32b`. ```powershell ctest --preset dev --no-tests=error -j 1 -R '^compute_store_aot_mac_f32_hardware$' -V # x3 ``` - **All 3 runs failed with the same output.** The unmutated draw matches (`compared_words=320 mismatches=0`). The probe then fails with `mad() 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. - The whole `^compute_store_aot_` family: 179/180. The only red is `compute_store_aot_mac_f32_hardware`. ### After: `cc207f9a` - Same command, x3: **all 3 passed**. Each run printed `mac_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. - The PR merges cleanly into current main (`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: - I compiled the fixture's `mad()` mutation with the same DXC. - I ran it through `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. - I computed the reference values separately, without `mac_f32_words()`. Unfused: the product rounded to f32, then the add. Fused: the exact rational `a*b + c`, rounded once to f32. | words | RTX 3070 | WARP | |---|---|---| | word 0 of every thread (64, constant operands) | unfused (`00000000`), all 64 | unfused | | word 2, even threads (32 words: 2, 10, 18, …) | **fused** (e.g. word 2 `40400003`, word 10 `40400009`) | unfused (`40400004`, `40400008`) | | word 2, odd threads; words 1 and 3 (both models agree) | match | match | | 64 words past the group | sentinel untouched | sentinel untouched | | words that match neither model | **0** | 0 | 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 -dumpbin` of the same mutated shader shows two run-time `dx.op.tertiary.f32(i32 46, …)` (`FMad`) calls. The store has word 0 as the literal `i32 0`, the same line as in #2883. ### `binary` mode I said earlier that I would run it with LLVM 15 `llvm-mc`. I couldn't: on Windows I don't have a `libLLVM-15` for the library argument. The PR's own CI run did run it with the real tools: in the "Assemble and translate gfx1013 fixtures" job (merge `7127a6c` of `cc207f9a` into `b505c32b`), `tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1` reports `ok` (117.8 s). Its startup `controls()` includes the new `mac_f32_controls()`. ### Not covered - RDNA 1/2/3 hardware; Intel. - A DXC that leaves word 0 to the driver. The docstring already says such a DXC would fail here with the first-mismatch detail. That is the right outcome. No changes requested. AI-assisted.
KelboLive commented 2026-11-26 20:24:40 +00:00 (Migrated from github.com)

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

  • ✅ The mac_f32_controls() helper correctly simulates both unfused and folded-fused readbacks
  • ✅ Classification logic ('fused' vs 'unfused') is sound and properly tested
  • ✅ The documentation update accurately captures why the change was needed
  • ✅ No changes to the translator or lowering — strictly a test fix, as stated in the PR body

Notes

  • The 4 comments on this PR likely contain maintainer/engineer discussion; worth a quick check if there are specific review action items
  • The test correctly handles edge cases where neither model matches (failure) or when the renderer exits with code 3

Verdict: Clean fix. Ready for final review pass — this should be a quick approve.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6080120821 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#pullrequestreview-6080120821). Originally posted by [KelboLive](https://github.com/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 - ✅ The `mac_f32_controls()` helper correctly simulates both unfused and folded-fused readbacks - ✅ Classification logic ('fused' vs 'unfused') is sound and properly tested - ✅ The documentation update accurately captures *why* the change was needed - ✅ No changes to the translator or lowering — strictly a test fix, as stated in the PR body ### Notes - The 4 comments on this PR likely contain maintainer/engineer discussion; worth a quick check if there are specific review action items - The test correctly handles edge cases where neither model matches (failure) or when the renderer exits with code 3 **Verdict:** Clean fix. Ready for final review pass — this should be a quick approve.
R0Y00 commented 2026-11-27 06:47:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:47:01Z.

Review: APPROVED


Independent review of cc207f9a integrated with main f5204690 (5e75c126 locally). 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_check and ran ctest --preset <dev|release> --no-tests=error -V -R '^compute_store_aot_mac_f32_(warp|hardware)$'. Debug and Release /O2 each 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 /O2 job skipped and the local /O2 retest passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6084497964 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2892#pullrequestreview-6084497964). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T06:47:01Z. **Review:** APPROVED --- Independent review of `cc207f9a` integrated with `main` `f5204690` (`5e75c126` locally). 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_check` and ran `ctest --preset <dev|release> --no-tests=error -V -R '^compute_store_aot_mac_f32_(warp|hardware)$'`. Debug and Release `/O2` each 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 `/O2` job skipped and the local `/O2` retest passed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2892
No description provided.