Skip to content

Tests: run the v_fma_f32 control of the no-contraction test on its own - #676

Open
Tjabooo wants to merge 1 commit into
xcl-dev:mainfrom
Tjabooo:tests/fma-control-own-program
Open

Tjabooo wants to merge 1 commit into
xcl-dev:mainfrom
Tjabooo:tests/fma-control-own-program

Conversation

@Tjabooo

@Tjabooo Tjabooo commented Nov 24, 2026

Copy link
Copy Markdown

On RADV, gpu_nonfused_mad_and_mac_prevent_fma_contraction fails its fused control. The cause is the test's layout, not missing FMA: the v_fma_f32 control sits in the same program as the mad_nf ops, on the same inputs. RADV merges the fma's v0 * v1 with their identical precise products and rounds it twice. A lone v_fma_f32 is fused there. This runs the control as its own program, so it checks what it is meant to check: that the backend fuses. Part of #472.

How I narrowed it down (RX 9070 XT, RADV / Mesa 26.2.6, vkd3d-proton v3.1, main dd2ae9a):

  • The DXIL has the control as a plain FMad without !dx.precise (DXC 2026_09_29), and the SPIR-V that vkd3d-proton hands to RADV has OpExtInst Fma %v0 %v1 %v2 without NoContraction (VKD3D_SHADER_DUMP_PATH).
  • In RADV's NIR (RADV_DEBUG=shaders) there is no ffma left: the value stored to v16 is fadd(fmul(v0, v1) // exact, v2) // exact, the same instructions as the mad_nf lines.
  • With only the V_FMA_F32 line in the program, both lanes pass (0x73FFFFFF, 0x28800000). With the v_mad_f32 line (v12) removed but the other mad_nf lines kept, it still fails, because they share the v0 * v1 product.

Folding an fma's product into an identical exact product is arguably a Mesa bug. A real shader with both patterns would round that fma twice on RADV. I can report it to Mesa separately. This PR only keeps the test from depending on it.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_nonfused_mad_and_mac_prevent_fma_contraction translates and runs the v_fma_f32 control as a second program on the same register state, and asserts both lanes of v16 there. The non-fused checks are unchanged.

Tested

Regression run

  • Test-only change (tests.rs), no runtime code, so no smoke.ps1 run.

Not tested

AI use

  • Claude Code with Claude Opus 5.5: ran the investigation (DXIL / SPIR-V / NIR dumps), wrote the change and this description. I read the diff.

gpu_nonfused_mad_and_mac_prevent_fma_contraction put the fused control in
the same program as the mad_nf ops it checks, on the same inputs. RADV
(Mesa 26.2, through vkd3d-proton) then merges the fma's v0 * v1 with the
identical precise products of the mad_nf ops and rounds it twice, so the
control fails although a lone v_fma_f32 is fused there. Running the control
as its own program measures what it is meant to: whether the backend fuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lordon1a

Copy link
Copy Markdown

Independent GPU test report on bbf6c40:

Tested

  • Hardware: NVIDIA GeForce RTX 3070 Ti Laptop GPU (driver 616.64, wave32, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200), rustc 1.100.0 (x86_64-pc-windows-gnullvm), debug build, DXC 1.9.2609.5 (01b62ad4)
  • Command: cargo test -p xcl --lib gpu_nonfused_mad_and_mac_prevent_fma_contraction -- --nocapture
  • Result: 1 passed, 0 failed, 0 ignored in 0.80s (gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction ok)

Not tested

  • AMD / wave64, Intel GPU, retail title

AI use

  • Antigravity (Google DeepMind agent) — fetched bbf6c40 in a detached worktree, audited the diff, ran the GPU test, and posted this report.

@joeypercia

Copy link
Copy Markdown

Native Windows AMD run, the other half of Not tested (NVIDIA is above): bbf6c40 merged onto main 91f9a5e (clean merge).

Tested

  • AMD Radeon iGPU (Ryzen 7 7800X3D, RDNA2, 32–64 lanes, no mesh shaders), driver 26.11.2 (32.0.21045.29003); RTX 4070 Ti (616.56, 32 lanes); Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11; debug
  • gpu_nonfused_mad_and_mac_prevent_fma_contraction: passes on the RDNA2 iGPU and on the RTX 4070 Ti, the separate fused control included
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on the RDNA2 iGPU: 692 passed, 0 failed, 41 ignored; SKIPPED: gpu_geometry_mode_es_gs_strip, gpu_mesh_mode_two_passes (no mesh shaders)

Not tested

Run and report by Claude Code (Claude Opus 5.5).

@towiice towiice left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested:

  • Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, 32-wide subgroups / wave32, driver 610.88), Windows 11 x64 (26H2 / 10.0.26300), DXC v1.9.2609 (01b62ad4), toolchain stable-x86_64-pc-windows-gnullvm (llvm-mingw 23.1.6).
  • Test command: cargo test -p xcl --lib gpu_nonfused_mad_and_mac_prevent_fma_contraction -- --nocapture
  • Result: 1 passed, 0 failed (0.65 s).

Separating the v_fma_f32 control into its own isolated program avoids driver shader optimization merging with precise products while verifying hardware fused multiply-add behavior. Passes cleanly on NVIDIA Turing.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Full-suite run on this PR's head bbf6c40, for the counts CONTRIBUTING.md item 2 asks for, on a GPU family the description doesn't cover:

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, wave32), Ryzen 9 5950X, Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 692 passed, 0 failed, 41 ignored (16 test binaries, the e2e title included)
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested: AMD / wave64; no retail title (this PR changes only gpu/recomp/tests.rs).

AI-assisted (Claude Code).

@crastinator crastinator left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on RDNA2 under Wine (RADV). Same result as the RX 9070 XT in the description.

Tested (head bbf6c40, and merged onto main 1ec4c98: no conflicts)

  • AMD Radeon RX 6700 XT (RDNA2, gfx1031, RADV NAVI22, Mesa 26.3.1), Ryzen 7 5700X, Linux 7.3.5 (CachyOS)
  • Wine: Proton Experimental 11.0-20261112 (its files/bin/wine, kernel write watches), with its own vkd3d-proton (stock, not the #257 patch) and DXVK v3.1.1-209 dxgi; VKD3D_CONFIG=ignore_shared_fence; DXC 1.9.2609
  • Cross-built on Linux for x86_64-pc-windows-msvc (clang-cl / lld-link 23.1.5, xwin SDK 10.0.26100), Rust 1.99.1, debug; the lib test binary run under Wine
  • On main 1ec4c98, gpu_nonfused_mad_and_mac_prevent_fma_contraction fails here: v_fma_f32 overflow control should stay fused, left 2139095040 (+inf), right 1946157055.
  • At bbf6c40 it passes, and it also passes with the PR merged onto 1ec4c98. So the lone v_fma_f32 is fused on gfx1031 / RADV too.
  • Whole lib suite, one test per process (see note): main 664 ok / 4 failed / 21 ignored / 5 aborted at the #241 assertion / 1 exits with code 5 (mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares, right after its mid-list split; newer than this PR and probably the same stock-vkd3d-proton limit); PR head 644 ok / 3 failed / 21 ignored / 5 aborted. The only status change in tests present on both sides is this test, FAILED -> ok. The 3 that still fail are gpu_f64_roots and gpu_f64_math_random (#530) and xma2_source_voice_decodes_and_manages_lifetime (#890), and all three fail on main too.

Under stock vkd3d-proton, D3D12.X tests take down the test process (iface->lpVtbl == &d3d12_heap_vtbl, #241), so the suite was run one test per process: every test in the binary, each with --exact <name> --test-threads=1, compared against main the same way.

Not tested

  • Windows, NVIDIA, a retail title. The full suite with a patched vkd3d-proton.

AI use

  • Claude Code (Claude Opus 5.5) built the branches, ran the tests and wrote this report; I checked the results.

Update: re-run at bbf6c40 after @pablogonz12's RDNA4 result. On RDNA2 it still passes with every vkd3d-proton / dxil-spirv build I have, including the dxil-spirv master 7c048638 used there. So the difference looks like it's in RADV's RDNA4 (gfx12) backend, not in dxil-spirv.

  • RX 6700 XT (gfx1031), Mesa 26.3.1 RADV (the same Mesa as the RX 9070 XT run), Proton Experimental's Wine; --exact gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction --test-threads=1:
vkd3d-proton dxil-spirv result
Proton Experimental's own (Proton's) pass 2/2
v3.1 + #257's patch, -Db_ndebug=true 53aac418 (#775) pass 2/2
v3.1, no patch, -Db_ndebug=true 53aac418 pass 2/2
v3.1 + #257's patch, -Db_ndebug=true 7c048638 (master, as in the RDNA4 run) pass 3/3
  • RADV_DEBUG=shaders on gfx1031: the lone control program compiles to one fused op, v_fmac_f32_e32 v10, v3, v4 (v10 holding v5, the addend).
  • So the PR's premise (a lone v_fma_f32 is fused) holds on gfx1031 with Mesa 26.3.1, but per the RDNA4 report it does not on gfx1201. Comparing RADV_DEBUG=shaders (or nir) for the control on the RX 9070 XT would show whether ACO splits it there.

@pablogonz12

Copy link
Copy Markdown
Contributor

Test report for head bbf6c40 (based on 91f9a5e). It does not fix the test on this setup: the lone v_fma_f32 control is unfused here too.

Tested

  • AMD Radeon RX 9070 XT (RDNA4, RADV / Mesa 26.3.1), Ryzen 9 9900X, CachyOS (Linux 7.3), Wine (GE-Proton11-14), vkd3d-proton v3.1 + the Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 patch with subprojects/dxil-spirv moved to master 7c048638 (Linux: dxil-spirv asserts on the DXIL of jumps_to_outer_loop_heads_are_structured (b8b1f49), the suite crashes under vkd3d-proton #1425), DXC 1.9.2609.5, Rust stable, release, x86_64-pc-windows-gnu, --test-threads=4.
  • gpu_nonfused_mad_and_mac_prevent_fma_contraction on this head fails at its new control: v_fma_f32 overflow control should stay fused, left 2139095040 (0x7F800000), right 1946157055 (0x73FFFFFF). Alone (--test-threads=1) it fails the same way. The non-fused asserts before it pass.
  • Whole xcl lib suite on this head: 716 passed, 6 failed, 21 ignored, 0 SKIPPED (the six: gpu_f64_roots, gpu_f64_math_random, this test, gpu_depth_buffer_created_for_unordered_access_is_placed, xma2_source_voice_decodes_and_manages_lifetime, pe::tests::parses_own_test_binary_tls). main b7aa9f3 plus a test-only commit: 714 passed, 9 failed (the same six plus three interference failures that pass alone).
  • So the result from the description (a lone fma is fused on Mesa 26.2.6) does not hold on Mesa 26.3.1 here. I did not find out why (the SPIR-V I dumped is the non-fused program, not the control).

Not tested

  • Mesa 26.2.6, Windows, NVIDIA; the NIR of the lone control.

AI use

  • Claude Code (Claude Sonnet 5.5) ran the builds and tests on my machine and wrote this report.

@crastinator

Copy link
Copy Markdown

@pablogonz12 for comparison: same Mesa 26.3.1 on RDNA2 (RX 6700 XT, gfx1031). At bbf6c40 the test passes with every dxil-spirv I have, your master 7c048638 included, and RADV_DEBUG=shaders shows the lone control as one v_fmac_f32. So it looks gfx12-specific. Details in my review above (edited).

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (bbf6c40)

Hardware / environment

  • Commit bbf6c406e5c1b831bb7aed57400c797f6e8cc42c (PR Tests: run the v_fma_f32 control of the no-contraction test on its own #676).
  • Intel Arc A770, driver 32.0.101.9175. AMD Ryzen 7 3800X 8-Core Processor. Windows build 10.0.26200.9974.
  • Rust 1.100.0 (0ef1bc386 2026-11-09), x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad4) and DXIL 1.9.2609.5.
  • Cargo test profile, unoptimized, with incremental compilation and debug info disabled.

Commands and results

  • cargo test -p xcl --lib --no-run exited 0 outside the Arc lock and produced the library test executable. This step ran zero tests.
  • With XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1, ran this command under the lock held by Invoke-ArcTest.ps1. $testExe denotes the executable Cargo reported.
& $testExe gpu::recomp::tests::gpu_nonfused_mad_and_mac_prevent_fma_contraction --exact --nocapture --test-threads=1
  • The test executable and lock wrapper both exited 0. The log reported 1 passed, 0 failed, 0 ignored, 672 filtered out, and 0 skipped (case-sensitive lines beginning with SKIPPED ). The harness finished in 0.64s.

Observed behavior

The selected test exercised both shaders in one test case. The non-fused MAD and MAC assertions passed for positive infinity on overflow (0x7F800000) and positive zero on cancellation (0x00000000). The separate V_FMA_F32 dispatch used the same inputs and passed the fused-result assertions (0x73FFFFFF and 0x28800000, respectively).

Not tested

The full GPU workspace suite, game smoke runs, and the RADV/vkd3d-proton configuration were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr676-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recompiler: v_fma_f32 is not fused on AMD's RDNA1 driver (mad() left unfused)

10 participants