Skip to content

Tests: a cross-backend and cross-device VALU fuzzer (ignored by default) - #2169

Open
alexdeliu wants to merge 1 commit into
xcl-dev:mainfrom
alexdeliu:recompiler/valu-fuzz
Open

alexdeliu wants to merge 1 commit into
xcl-dev:mainfrom
alexdeliu:recompiler/valu-fuzz

Conversation

@alexdeliu

@alexdeliu alexdeliu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Adds valu_fuzz_backends_agree. It runs every VOP3 / VOP3P VALU instruction of the RDNA2 table alone in a wave64 kernel, on 64 lanes × 4 rounds of edge and pseudo-random inputs (signed zeros, denormals, infinities, NaNs, integer and f16 edges), through both backends (HLSL + DXC, direct DXIL). It reports every instruction whose results differ between them, with the sources of each case. With XCL_FUZZ_DIR set, it writes the results per adapter. valu_fuzz_compare then reports what differs between adapters (run once per XCL_ADAPTER). Both tests are #[ignore]d because they take a minute or two of GPU time, not to hide a failure, and skip without a GPU. A port of the fuzzer behind Marvisak/VIctory#1614 (same author), whose findings include the shared-dword i64 compare that 5195e27 also handles.

Findings so far: #2168 (the HLSL backend's fast-math, and v_dot2_f32_f16 between RDNA4 and RDNA2).

What is in it

  • crates/xcl/src/gpu/recomp/valu_fuzz_tests.rs: the generator, the per-backend runs, the per-adapter files and the comparison.
  • crates/xcl/src/gpu/recomp/mod.rs: one #[cfg(test)] mod valu_fuzz_tests; line. Test-only, so this asks for the test-only label.

Tested

  • AMD Radeon RX 9070 (RDNA4, 32.0.32029.2010) and the Ryzen 7 7700 iGPU (gfx1036, 32.0.21045.29003) on one machine. Windows 11 Pro 26200, rustc 1.100.0 msvc, debug, Windows SDK 10.0.26100 DXC (validator 1.7).
  • cargo test --workspace -- --test-threads=4 on this branch, RX 9070: 1152 passed, 2 failed, 48 ignored. The 2 failures are fuzz_validate_and_gpu_1 / _3 (seeds 722 / 1599), which fail on main too on this card. The 2 extra ignored tests are the new ones. 81 tests SKIPPED by validator 1.7, plus 9 others, as on main.
  • valu_fuzz_backends_agree on each AMD adapter: 341 instructions, 333 compared on both backends, 6 differ (the issue above), 8 refused by both backends (the f64 div helpers, v_qsad/v_mqsad, v_mullit_f32, v_cvt_off_f32_i4). Rerun of those 6 with XCL_FUZZ_DXC_GIS=1 (XCL_FUZZ_OPS set to them, RX 9070): 0 differ.
  • valu_fuzz_compare over the two adapters: only v_dot2_f32_f16 differs (7 of 256, on both backends).

Regression run

  • From @Toons29's run in this PR's comments, both blocks as scripts/smoke.ps1 printed them: main at 568e7db7 and this PR's head e792e6b2, same title and time, on an AMD Radeon RX 9070 (32.0.32029.2010). The PR's run shows 104 % of main's frames and 100 % of its peak commit, with no crash and no device removal. The change is test-only (an #[ignore]d test and one #[cfg(test)] line), so the title does not reach it.
xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: e792e6b296959c9f1bf680199707aeabce07655d
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

Not tested

  • (Rerun after the rebase: cargo test --workspace -- --test-threads=4 at this head on main 568e7db, RX 9070: 1152 passed, 2 failed (seeds 722 / 1599, as on main), 48 ignored, 90 SKIPPED.)
  • NVIDIA and Intel. WARP skips the fuzzer, because it runs neither wave64 nor the split form here.
  • No retail run of my own: the regression run above is @Toons29's. The change is test-only.

AI use

  • Claude Code with Claude Opus 5.5 wrote the code, the tests and this description, and ran the tests above. The contributor opened it after reading the summary of the findings.

🤖 Generated with Claude Code

valu_fuzz_backends_agree runs every VOP3 / VOP3P VALU instruction of the
RDNA2 table alone in a wave64 kernel, on 64 lanes x 4 rounds of edge and
pseudo-random inputs, through the HLSL and the direct-DXIL backends, and
reports where they differ (with each case's sources). With XCL_FUZZ_DIR
it writes the results per adapter, and valu_fuzz_compare reports what
differs between adapters. Both are #[ignore]d (GPU minutes) and skip
without a GPU.

Assisted-by: Claude Code (Claude Opus 5.5)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@DarkPanda69

Copy link
Copy Markdown

Fuzzer run on NVIDIA (listed as untested) and on an RX 9070 XT, at head e792e6b applied on main 568e7db (the rebased base the description says was not rerun).

Tested (debug, Windows 11 Pro 26200, cargo test -p xcl --lib valu_fuzz_backends_agree -- --ignored --nocapture --test-threads=1, then valu_fuzz_compare, XCL_FUZZ_DIR set):

  • RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64): 341 instructions, 333 compared, 6 differ, the same 8 refused by both backends. The 6 and their counts match the description exactly: v_cos_f32 8, v_ldexp_f16 19, v_mul_f16 26, v_pk_mul_f16 49, v_sin_f16 4, v_sin_f32 7 (of 256). So it reproduces on the rebased tree.
  • RTX 3060 (32.0.16.1088, wave32 only, so the split wave64 form): 341 instructions, 333 compared, 1 differs, same 8 refused. None of the six AMD differences from Recompiler: the HLSL backend's fast-math loses -0 in f16 results and changes v_sin/v_cos on AMD #2168 shows up here. The one that does is new:
    • v_cubetc_f32: 58 of 256 differ. In every example the HLSL result is a signed zero where the direct result is a denormal, e.g. sources ff7fffff,0000ffff,54ed8ab5: hlsl 0x80000000, direct 0x8000ffff; sources 7fffffff,00000001,3c01bc00: hlsl 0x80000000, direct 0x80000001. On the RX 9070 XT the HLSL result keeps the denormal (0x8000ffff), so the NVIDIA driver flushes f32 denormals on the HLSL path for this instruction.
  • valu_fuzz_compare RX 9070 XT vs RTX 3060: 38 instruction/backend pairs differ. Mostly the same on both backends, so between the GPUs rather than the translators:
    • f16 rounding by one ulp: v_add_f16, v_sub_f16, v_subrev_f16 (3–6), v_cvt_f16_i16 (32), v_fma_f16 / v_pk_fma_f16 / v_pk_add_f16 / v_fma_mixlo_f16 (6–14), v_div_fixup_f16 (7). E.g. v_cvt_f16_i16 result 9: AMD 0x77d9, NVIDIA 0x77d8.
    • NaN encoding: v_fma_mixhi_f16 110, e.g. AMD 0xfe00…, NVIDIA 0x7fff….
    • f32 denormals from f64: v_cvt_f32_f64 4 (AMD 0x00000000, NVIDIA 0x00014800), v_cvt_f64_f32 14 of 512.
    • precision: v_log_f32 5 (AMD 0x3438aa3b, NVIDIA 0x3495f600), v_sin_f32 134/140, v_sin_f16 63/67, v_cos_f32 10/17, v_dot2_f32_f16 7.

I have the two per-adapter .tsv files if they are useful for comparing against your RDNA2 iGPU (which should be closest to the console).

Not tested: XCL_FUZZ_DXC_GIS=1 on the 3060, Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the fuzzer on this machine and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RDNA2 run of the ignored VALU fuzzer on exact PR head e792e6b296959c9f1bf680199707aeabce07655d (base 568e7db7729c8fa6c8f0f4b32d798faaf11462bb).

Environment: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Clean detached worktree; XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, XCL_FUZZ_DIR set. Each run used cargo test --locked -p xcl --lib -j 2 valu_fuzz_backends_agree -- --ignored --test-threads=1 --show-output and the fuzzer's default four rounds (256 inputs per instruction).

HLSL compile Instructions Compared on both backends Differing instructions Refusals
Default 341 333 6 16 entries (8 instructions, both backends)
XCL_FUZZ_DXC_GIS=1 341 333 8 16 entries (same 8 instructions)

The default run reproduced #2168's six differences with the same counts: V_COS_F32 8, V_LDEXP_F16 19, V_MUL_F16 26, V_PK_MUL_F16 49, V_SIN_F16 4, V_SIN_F32 7 (each of 256). With -Gis, those six disappeared, but eight FMA-family instructions then differed: V_DIV_FMAS_F32 2, V_FMAC_F32 2, V_FMAC_LEGACY_F32 4, V_FMA_F16 6, V_FMA_F32 1, V_FMA_MIXHI_F16 7, V_FMA_MIXLO_F16 6, V_PK_FMA_F16 14 (each of 256). For example, strict HLSL gave 0x3c01 for one V_FMA_F16 case where direct DXIL gave 0x3c00.

I reran only those eight FMA instructions immediately afterward: 0/8 differed without -Gis; 8/8 differed with it, with the same per-instruction counts. This confirms the change in this fixture. It suggests that applying -Gis globally would trade one set of backend differences for another on this GPU; the fuzzer does not establish which backend matches the console for every FMA case.

All four ignored-test invocations completed with 1 test passed, 0 failed, 0 ignored. That test status means the fuzzer completed; it does not mean the backend outputs matched. I did not run the full workspace suite, a retail title, or a cross-device comparison on this PR head. Local logs and TSV outputs are preserved; no game data was used or uploaded.

AI use: OpenAI Codex ran and repeated the comparisons, checked the exact revision and logs, and prepared this report.

@alexdeliu
alexdeliu marked this pull request as ready for review November 25, 2026 10:43
@raylitebull

Copy link
Copy Markdown
Member

Diff audit on e792e6b (valu_fuzz_tests.rs + mod.rs) looks clean (#[ignore] fuzzer) and CI run 45564995525 has been approved.

Note that PR description currently fails because no test-only label exists on this repo (or needs a paired xcl-smoke v1 block to clear the check) before this can merge.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of e792e6b2 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: e792e6b296959c9f1bf680199707aeabce07655d
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

Victorbriez added a commit to Victorbriez/xcl that referenced this pull request Nov 25, 2026
The HLSL helpers wrote the negation as `-x`, which DXC compiles to `fsub -0.0, x`. With no denormal option the driver may flush a denormal there, and NVIDIA does: v_cubetc_f32 returned ±0 for a denormal source on an RTX 3070, where the direct backend (`fneg`) returns the negated denormal. The VALU fuzzer of xcl-dev#2169 found 58 of 256 cases; with the sign bit flipped it finds none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Victorbriez added a commit to Victorbriez/xcl that referenced this pull request Nov 25, 2026
Both backends negated with `fsub -0.0, x`: the HLSL helpers through `-x`, the direct lowering through `fneg`. With no denormal option a driver may flush a denormal there. NVIDIA does on the HLSL path (v_cubetc_f32 returned ±0 for a denormal source on an RTX 3070), and RADV under vkd3d-proton does on the direct path (reported on xcl-dev#2348). Both now flip the sign bit, as the direct backend's directed-rounding path already does for source modifiers (`fsrc_bits`). The VALU fuzzer of xcl-dev#2169 found 58 of 256 cases differing between the backends on NVIDIA; with this change it finds none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Victorbriez added a commit to Victorbriez/xcl that referenced this pull request Nov 25, 2026
Both backends negated with `fsub -0.0, x`: the HLSL helpers through `-x`, the direct lowering through `fneg`. With no denormal option a driver may flush a denormal there. NVIDIA does on the HLSL path (v_cubetc_f32 returned ±0 for a denormal source on an RTX 3070), and RADV under vkd3d-proton does on the direct path (reported on xcl-dev#2348). Both now flip the sign bit, as the direct backend's directed-rounding path already does for source modifiers (`fsrc_bits`). The VALU fuzzer of xcl-dev#2169 found 58 of 256 cases differing between the backends on NVIDIA; with this change it finds none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants