Skip to content

FUZZ-8: wave64 half-mask shapes in the fuzzer + cs_w64_exec_half GPU test (translator fix landed in #3225) - #663

Open
tunczzz wants to merge 2 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-masks
Open

tunczzz wants to merge 2 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-masks

Conversation

@tunczzz

@tunczzz tunczzz commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Item: FUZZ-8 finding, posted in #374: #374 (comment)

Depends on: #615 (stacked on it; only the last commit, 1f87f232, is new here).

Update 2026-11-23: this PR no longer changes tools/rdna2spirv.py. #3225 (SweatierKey, 99c048f7) fixed both translator bugs below while this PR waited, and the rebase onto main 98fa503f keeps main's translator. What's left is the fuzzer shapes that found the bugs and a GPU regression test that pins the fix. Both pass on main's translator, natively and with --wave64-emulate.

Findings (fixed on main by #3225; found here independently)

Found by tools/cf_diff.py with the new mask shapes below, on the translator before #3225:

  1. A register written to exec_lo changed all 64 lanes. v_cmp_gt_u32 vcc, 8, v1; s_and_b32 exec_lo, exec_lo, vcc_lo must leave lanes 32-63 alone, but lanes 32-63 switched off. s_mov_b32 exec_lo, s0 did the same. Any op but s_mov_b32 into exec_hi was rejected (Unsupported: destination exec_hi).
  2. SCC of a 32-bit op on one half of a mask took the lane's own bit. s_and_b32 s50, vcc_hi, exec_hi; s_cbranch_scc0 must vote over lanes 32-63 only.

Fuzzer

  • tools/cf_ref.py: every _b32 op is a 32-bit word op (exec_lo/hi, vcc_lo/hi, SGPRs), which is what the hardware does in both wave sizes. It also adds s_cmp_eq/lg_u64 and s_cselect_b64.
  • tools/cf_diff.py, new shapes: v_cmp_*_e64 into an SGPR mask feeding s_and_saveexec and v_cndmask_b32_e64; constant EXEC (s_mov_b32 exec_lo/exec_hi, literal); s_and_b32 on one EXEC half; SCC of half-mask ops; s_cmp of masks against 0; s_cselect between masks. Instruction sizes now count literals.
  • On the translator before rdna2spirv: fix 32-bit bitwise SALU ops on wave32 and wave64 half lane masks #3225, seed 80 gave 17 mismatches and 21 skips (destination exec_hi) in 600 cases, all wave64. On main 98fa503f it gives 0 and 0, and so do 800 more programs over the stack tip (seeds 4242/4243, wave32/64, depth 4 dispatch loop).
  • tests/test_cf_diff.py: five half-mask regression cases in both forms. They pass on main and fail on the translator before rdna2spirv: fix 32-bit bitwise SALU ops on wave32 and wave64 half lane masks #3225.

GPU test

runtime/test/shaders/cs_w64_exec_half.asm is a wave64 dump (one wave64, 64 threads) registered in check.py and run_gpu_tests.py. Expected out[0..7] = 1 0 1 1 0 3 9 9. It needs a 64-wide subgroup or LEONIDA_W64_EMULATE=1. Testers' results are in the comments: native wave64 on RDNA2/RDNA3/RDNA4 (RADV and AMDVLK), and emulated on several NVIDIA GPUs, all 1 0 1 1 0 3 9 9. I didn't run it myself; the PC's RTX 5070 Ti has 32-wide subgroups.

Tests

WSL Ubuntu, llvm-mc 21, on 676d59ce: tests/test_cf_diff.py, test_cf_ref.py, test_run_gpu_tests.py and tests/semantic/test_spirv_wave_interp.py give 139 passed, 132 subtests. The full pytest tests --ignore=tests/semantic on the stack tip shows only the 7 failures plain main has (test_joaat_agreement, fixed by #4753; test_rdna2_decode llvm-mc parity).

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

@IAmNotSiob IAmNotSiob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tunczzz's cf_diff sweep already shows main's 43 mismatches go to 0 with this plus #615, and tests pass with main here (805). lgtm \o/ AI-assisted review (Claude Code).

@Pierre-Kookis

Copy link
Copy Markdown
Contributor

GPU run of #663 (eb89f82), which asks for a 64-wide subgroup or LEONIDA_W64_EMULATE=1. I ran both, on one machine.

Setup: Windows 11. AMD Radeon Graphics (Ryzen 7 7800X3D iGPU, RDNA2), driver 32.0.21043.5001, native wave64 (subgroup 32..64). RTX 4070 Ti SUPER, driver 610.88, subgroup 32. Test programs from main c432cdc (llvm-mingw clang), llvm-mc 23.1.6.

cs_w64_exec_half cs_scc_mask32 suite
AMD native wave64 PASS 1 0 1 1 0 3 9 9 PASS 7 0 0 9 11 13 7 13 82/87, 5 skipped (mesh)
NVIDIA, no emulation SKIP (no 64-wide subgroup) PASS 60/87, 27 skipped
NVIDIA LEONIDA_W64_EMULATE=1 PASS 1 0 1 1 0 3 9 9 PASS 87/87

Native wave64 and emulated give the same words. tests/test_run_gpu_tests.py: 18 OK. python -m unittest discover -s tests/semantic: 805 OK. I didn't run tests/test_cf_diff.py because it imports pytest. GitHub now shows a conflict with main, so this run is from before any rebase.

(AI-assisted run, counts only.)

@matheuskshn

Copy link
Copy Markdown
Contributor

Ran python -I tools/cf_diff.py --programs 12 --seed 17 at eb89f82 on Windows 11 / Python 3.12.14. The structured campaign gave 24 passes across wave32 and wave64, 0 mismatches, 0 skips and 0 harness errors. This was CPU differential validation; the dedicated hardware coverage remains separate. AI-assisted.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested eb89f82 on RTX 4090 (driver 621.14, 32-wide subgroups), Windows 11 26200: pass (32-wide half)

  • RelWithDebInfo Ninja build of runtime/ (MSVC, Vulkan SDK 1.4.363.0); ctest: 27/27
  • python -I scripts/run_gpu_tests.py: 60/87 passed, 27 skipped; with LEONIDA_W64_EMULATE=1: 87/87. main c432cdc on the same machine: 59/85 (26 skipped) and 85/85
    • cs_w64_exec_half: skipped without emulation (no 64-wide subgroup here), 1 0 1 1 0 3 9 9 with LEONIDA_W64_EMULATE=1
    • cs_scc_mask32: 7 0 0 9 11 13 7 13 in both modes
  • python -m unittest discover -s tests/semantic: 805 OK
  • python -m pytest tests --ignore=tests/semantic: 2029 passed, 5 skipped, 1 xfailed

This still needs a native wave64 (AMD) run. No game files used. AI-assisted run (Claude Code).

@realmalikov

Copy link
Copy Markdown

Tested #663 (eb89f82) on an NVIDIA GTX 1060 6GB (Pascal, subgroup 32..32, NVIDIA 582.78,
Windows 11 10.0.26200). No game files.

With LEONIDA_W64_EMULATE=1 (this device has no 64-wide subgroup, so native wave64 skips as expected):
cs_w64_exec_half (1 group x 64): 0 mismatches, out[0..7] = 1 0 1 1 0 3 9 9
cs_scc_mask32 (1 group x 64): 0 mismatches, out[0..7] = 7 0 0 9 11 13 7 13
AI-assisted.

@abilliontokens

Copy link
Copy Markdown
Contributor

Tested 676d59ce on AMD Radeon RX 9060 XT (RDNA4, AMDVLK 32.0.32029.2010, subgroup 32..64, Windows 11): pass.

  • Runtime test programs: RelWithDebInfo Ninja build of main d974c88a (this PR changes no runtime C++/CMake), MSVC BuildTools 2022, Vulkan SDK 1.4.363, llvm-mc 21.1.8, loader pinned to the AMD ICD via HKLM LoaderSettings.
  • python -I scripts/run_gpu_tests.py --llvm-mc <llvm-mc> --build runtime/build --require-pass from this head: 204/219 passed, 15 skipped, 0 failed. The 15 skips are the d3d12_*-run fixtures (cs_buf_*, cs_m4_*, ps_m*, vs_m*), expected. The two shaders this PR adds run natively on wave64 (no LEONIDA_W64_EMULATE needed): cs_scc_mask32 → 7 0 0 9 11 13 7 13, cs_w64_exec_half → 1 0 1 1 0 3 9 9, both PASS.
  • python -I -m unittest discover -s tests -p "test_cf_*.py": OK; -p "test_run_gpu_tests.py": OK; python -I -m compileall -q tools tests scripts: clean.

@AwkGrep256

Copy link
Copy Markdown
Contributor

Tested on Linux (CachyOS, kernel 7.3.5, Mesa 26.3.1 RADV), RX 9070 XT (gfx1201) and the Ryzen 7 9800X3D iGPU (gfx1036), through #4241's head e156275e, which contains this PR's head 676d59ce. This is the first real-GPU run of the new fixtures, and they pass.

  • scripts/run_gpu_tests.py, full suite, native wave64: 204/219 pass, 0 fail, 15 skipped on both GPUs.
    • cs_w64_exec_half gives 1 0 1 1 0 3 9 9.
    • cs_scc_mask32 gives 7 0 0 9 11 13 7 13.
    • ps_scc_mask32 passes.
  • LEONIDA_W64_EMULATE=1 (wave64 on 32-wide subgroups), filtered to these three: all pass on both GPUs.

One note for the description: this PR no longer changes tools/rdna2spirv.py. The two translator bugs it describes are already fixed in its base 98fa503f, I believe by 99c048f7 ("fix 32-bit bitwise SALU ops on wave32/wave64 lane masks"). With the base's translator, the three fixtures also pass, native and emulated, on both GPUs. So what's left here is the fuzzer shapes plus two GPU regression tests that pin that fix. The "translator fix" in the title and the "with the old translator" sentence describe code that has since landed elsewhere.

AI-assisted (Claude Code).

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @AwkGrep256, you're right. I'd retitled the PR but left the old body. The description now says the translator change landed in #3225 (99c048f7) and that this PR is the fuzzer shapes plus cs_w64_exec_half, which pins that fix. I dropped the "fixed here" and cost-guard text, since that code isn't in the branch any more, and updated #615's body the same way. Thanks also @cxchhh, @KkelebekK, @Vonsek and @abilliontokens for the runs; the body now points to them for the GPU results. No code change, so nothing was rerun. AI-assisted (Claude Code).

@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested 676d59c on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

No game files. AI-assisted.

tunczzz and others added 2 commits November 23, 2026 11:54
…_mask32 GPU test

The translator side of this PR (s_not_b32 on a wave32 lane mask votes its
SCC) landed on main through ItsNotRexed#3225 (SweatierKey), so the branch now keeps
main's tools/rdna2spirv.py and adds the checks around it:

- tools/cf_ref.py models s_not_b32/b64; tools/cf_diff.py generates s_not
  in the sccmask/csel shapes; tests/test_cf_diff.py has the two s_not
  regression cases (they fail with the old per-lane SCC).
- runtime/test/shaders/cs_scc_mask32.asm: @kotorvr's compute test for
  s_and + s_cselect, s_andn2 + s_cbranch_scc1, s_not, s_or, s_xnor,
  registered as a wave32 dump in check.py and run_gpu_tests.py (skipped
  below 32 lanes).
- docs/design.md: s_not_b32 in the rule, the GPU results and @kotorvr's
  corpus count.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alf GPU test

The translator side of this PR (wave64 32-bit ops on one half of EXEC/VCC:
exec_lo writes and the half's SCC vote) landed on main through ItsNotRexed#3225
(SweatierKey), so the branch now keeps main's tools/rdna2spirv.py. The
new shapes below pass on it; they found both bugs on the translator
before ItsNotRexed#3225:

- A register written to exec_lo set all 64 lanes, and any op but
  s_mov_b32 into exec_hi was rejected ("destination exec_hi").
- The SCC of a 32-bit op on one half of a mask took the lane's own bit.

Fuzzer: cf_ref treats every _b32 op as a 32-bit word op (halves
included) and models s_cmp_eq/lg_u64 and s_cselect_b64; cf_diff adds
e64 compares into SGPR masks (saveexec, v_cndmask), constant EXEC,
half-EXEC ops, half-mask SCC, s_cmp on masks and s_cselect between
masks, and counts literals in instruction sizes. GPU test
cs_w64_exec_half (wave64 dump; expected 1 0 1 1 0 3 9 9).

Depends on: ItsNotRexed#615

AI-assisted (Claude Code).

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

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased the FUZZ-8 stack onto main 561b65a8 (main's large merge had made every PR in the stack conflict). This PR's commit is now 1f87f232 (force-pushed). One conflict: main also edited the docs/design.md row "Wave64 handling". I merged the two edits sentence by sentence, keeping main's text plus this PR's exec_lo/exec_hi note.

Tests (WSL Ubuntu, llvm-mc 21, CPU only; the PC's RTX 5070 Ti not used): on #615's head, tests/test_cf_diff.py + test_cf_ref.py + test_run_gpu_tests.py give 121 passed, 148 subtests. On the stack tip 8811c2b2 (#4947) the same three give 393 passed, tests/semantic/test_spirv_wave_interp.py 23 passed, and tools/cf_diff.py seeds 9180–9182 give 1,400 programs (wave32 and wave64, depth 3/4, dispatch loop, --spirv-val) with 0 mismatch and 0 skipped. The full pytest tests --ignore=tests/semantic -n 2 on the tip has 7 failures, the same 7 plain main 561b65a8 has: test_joaat_agreement (fixed by #4753) and test_rdna2_decode's llvm-mc parity test. AI-assisted (Claude Code).

@IxMxAMAR

Copy link
Copy Markdown

Tested 1f87f23 on Windows 11 Pro 26200: pass, no regressions. AMD Radeon RX 9070 XT (AMD 26.11.2, Vulkan 1.4.359, subgroup 32..64, native wave64) and the Intel Graphics iGPU of a Core Ultra 5 225 (driver 101.8860, subgroup 8..32, LEONIDA_W64_EMULATE=1). Runtime built from 561b65a with MSVC 19.50 (its runtime sources are identical to this head), Vulkan SDK 1.4.350, llvm-mc AMD LLVM 23.

  • run_gpu_tests.py: RX 9070 XT 218/234 passed, 16 skipped, 0 failed. Intel 200/234 passed, 33 skipped, 1 failed. cs_scc_mask32 and cs_w64_exec_half pass on both GPUs, and every other test has the same result as on main 561b65a. The Intel failure is ms_wave_info_s3, which fails the same way on main (ms_wave_info_s3 intermittently fails on RX 7900 XT / RADV NAVI31 (pass rate 100% -> 2.5%, same binaries) #6172).
  • test_cf_diff.py 58 passed, test_cf_ref.py 26 OK, test_run_gpu_tests.py 47 OK, tests/semantic 6150 run OK.
  • Main has since moved to 1cc6e3c, and this head now conflicts with it in runtime/test/shaders/check.py and scripts/run_gpu_tests.py.

No game files. AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested 1f87f232 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • Merge: this head sits on 561b65a8, which already contains d0835dd9, so the merge was a fast-forward. Outside runtime/test/shaders, runtime/ is identical to 561b65a8, so the test programs are from a Linux build of 561b65a8.
  • python -I scripts/run_gpu_tests.py: 218/234 passed, 16 skipped, 0 failed, both without emulation and with LEONIDA_W64_EMULATE=1.
  • Test-by-test comparison (PASS/FAIL/SKIP and name), in both modes:
    • Against d0835dd9 without the PR (196/210, 14 skipped): no test changed or disappeared, and 24 tests are new.
    • Against 561b65a8 without the PR (216/232, 16 skipped): 22 of those 24 are already there with the same result (20 PASS, ps_live_width and ps_m2_literal SKIP). The only differences are cs_scc_mask32 and cs_w64_exec_half.
  • python -I runtime/test/shaders/check.py on the same work folders: 205 of 205 pass, 0 skipped, in both modes. Both new fixtures are ok.
  • pytest: tests/test_cf_diff.py 58 passed, tests/test_cf_ref.py 26 passed, tests/test_run_gpu_tests.py 47 passed, tests/semantic/test_spirv_wave_interp.py 19 passed (174 subtests in all).
  • tools/cf_diff.py: --self-test OK. --seed 80 --programs 600 --wave 64: 600 pass, 0 mismatch, 0 skipped, 0 harness errors.
  • Conflicts: as @IxMxAMAR noted, git merge-tree shows this head conflicts with main 1cc6e3c1 in runtime/test/shaders/check.py and scripts/run_gpu_tests.py. Against the newer 1a9c8c9e it also conflicts in docs/design.md.

No game files used. AI-assisted (Claude Code).

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.