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.

@MrCheese5

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.

@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).

tunczzz and others added 2 commits November 23, 2026 20:03
…_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 onto main 867d922f: the head was 1f87f232 and is now a305f508. The whole FUZZ-8 stack moved together (#615 → #663 → #4077 → #4104 → #4134 → #4241 → #4909 → #4930 → #4947).

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

@pr-sorter

Copy link
Copy Markdown

Tested a305f50 on AMD Radeon RX 5700 XT (RDNA1), Mesa RADV 26.2.5, Linux (CachyOS 7.3), i7-7700K: pass (AMD wave64 half)

  • scripts/run_gpu_tests.py, full suite: 215/243 passed, 28 skipped, 0 FAIL; 249/249 translated and pass spirv-val. With LEONIDA_BARY_FALLBACK=1: 219/243, 24 skipped. main 5d74c27 on the same machine gives 213/241 and 217/241; the only differences are the two new tests.
  • PASS cs_w64_exec_half 1 0 1 1 0 3 9 9 (native 64-wide subgroup) and PASS cs_scc_mask32 7 0 0 9 11 13 7 13 (required 32-wide subgroup), in both runs. These are the only translated modules that differ from main's.
  • LEONIDA_W64_EMULATE=1 --filter cs_w64_exec_half also gives 1 0 1 1 0 3 9 9 here, but at this device's default subgroup size, so the emulated run on a 32-wide GPU still needs someone.
  • Skipped here as on main: the ms_* tests (no VK_EXT_mesh_shader) and the fixtures run by the D3D12 tests.

AI-assisted (Claude Code), run by a person; built and run in a sandbox without network.

@byPreaZy

Copy link
Copy Markdown

checked: #663 (CPU side; GPU fixture blocked by local toolchain) | with: applied the last-commit diff on main 5d74c27, ran tests/test_cf_diff.py (58 passed), tests/test_cf_ref.py (26 tests OK), tests/test_run_gpu_tests.py (62 tests OK) | on: Windows 11, RX 9060 XT | result: CPU PASS

Could not run cs_w64_exec_half / cs_scc_mask32 on the GPU: the only llvm-mc on this machine (LLVM 23.1.6 at D:\llvm) is built without the AMDGPU target ("unable to get target for 'amdgcn-unknown-amdpal'"), so build.py cannot assemble the fixtures. The fuzzer and semantic-test side is verified; the wave64 GPU fixture still needs a run on an AMDGPU-enabled llvm-mc.

AI-assisted check.

@hwcopeland

Copy link
Copy Markdown

Tested a305f50 on AMD Radeon 8060S (Strix Halo, gfx1151, subgroup 32..64), RADV Mesa 26.3.1, Arch Linux container on Ubuntu 24.04.5 / kernel 7.0.0-38; LLVM 23.1.5, SPIRV-Tools v2026.4: pass.

  • scripts/run_gpu_tests.py: 249 shaders translate and pass spirv-val; 227/243 passed, 16 skipped, 0 failed, both native wave64 and with LEONIDA_W64_EMULATE=1 (main 867d922, this branch's base: 225/241). cs_w64_exec_half and cs_scc_mask32 pass natively on wave64 hardware.
  • pytest tests/test_cf_diff.py tests/test_cf_ref.py tests/test_run_gpu_tests.py: 146 passed, 161 subtests passed
  • tools/cf_diff.py --programs 300 --seed 1 --wave both --spirv-val: 600 pass, 0 mismatch, 0 skipped, 0 harness errors

Synthetic fixtures only, no game files. AI-assisted (Claude Code).

@byPreaZy

Copy link
Copy Markdown

checked: #663 GPU side now PASS too — update to the earlier CPU-only note | with: llvm-mc via WSL Fedora (/usr/bin/llvm-mc, LLVM with amdgcn target), spirv-as/spirv-val from Vulkan SDK 1.4.363.0, run_gpu_tests.py --filter | on: Windows 11, AMD Radeon RX 9060 XT (RDNA4, wave32/64) | result: PASS

  • cs_w64_exec_half: translated, spirv-val OK, GPU output 1 0 1 1 0 3 9 9 — exact match with the expected words
  • cs_scc_mask32: translated, spirv-val OK, GPU output 7 0 0 9 11 13 7 13 — exact match

Plus the earlier CPU side: test_cf_diff.py 58 passed, test_cf_ref.py 26 OK, test_run_gpu_tests.py 62 OK. For the record, the Windows LLVM at D:\llvm has no AMDGPU target, but WSL Fedora's /usr/bin/llvm-mc does; LLVM_MC="wsl -d FedoraLinux-44 -e /usr/bin/llvm-mc" works with build.py and run_gpu_tests.py as documented.

AI-assisted check.

@BatSmacker84

Copy link
Copy Markdown

Tested a305f5083 merged onto main 5d74c2723 on AMD Radeon RX 7800 XT, driver 26.11.2, Windows 11 26200: pass.

  • Both new fixtures pass, native wave64 and emulated.
  • Python: 165 tests plus 187 subtests pass.

AI-assisted: Codex GPT-6.2 Sol ran the tests, Claude Opus 5.5 reviewed the report. No game files used.

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.