Skip to content

crosslane_fuzz: --ext adds wave64 carries, DS permutes, mask SALU with SCC probes and SI_LOOP loops (model checked on RDNA2) - #3734

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Vonsek:claude/crosslane-fuzz-w64-ext
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Vonsek:claude/crosslane-fuzz-w64-ext

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-XLFUZZ-W64EXT, #3381 (comment)

What and why

tools/crosslane_fuzz.py (FUZZ-7) covers lane selects, ballots, v_mbcnt, permlane and DPP, but several wave64 cross-half paths of the translator had no random coverage: carries through 64-bit masks, the DS lane permutes, SCC of the 64-bit mask ops, and loops whose lanes leave on different iterations. --ext adds them to wave64 programs:

  • v_add_co, v_sub_co, v_subrev_co_u32 and the _ci forms, carry in and out in SGPR pairs or VCC.
  • ds_bpermute_b32, ds_permute_b32 (address permutations and colliding addresses), ds_swizzle_b32 (QUAD_PERM, BITMASK_PERM, SWAP, REVERSE, BROADCAST).
  • v_readlane/v_writelane with an SGPR lane select of 64 and up.
  • s_bcnt0/1, s_ff0/1, s_and/or/xor/andn2_b64, all ten s_*_saveexec_b64 forms, s_andn1/andn2_wrexec_b64, s_wqm_b64, s_cmp_eq/lg_u64, s_bitcmp0/1_b64, each followed by an s_cselect_b32 so the SCC is stored; s_cselect_b64 between masks; s_mov_b64 exec, mask; s_bfm_b64.
  • A loop in LLVM's SI_LOOP shape: per-lane trip counts, a break mask, s_andn2_b64 exec, s_cbranch_execnz back to the head, around one to four of the other ops. resolve_branches and the native kernel text learn backward branches (branch_offsets is the pure part, unit-tested).

Without the flag, and for wave32 programs with it, a seed gives the same program as before (test_dpp_seeds_are_unchanged and test_programs_are_reproducible still pass). An EXEC-off ds_swizzle_b32 source is tagged like the permlane case, so such programs are filed hyp_only until #2780 lands. Left out on purpose: 32-bit ops on one half of a mask (#663, #3225) and carries with a DPP source (#3553), which are known open differences.

Tool, tests and docs only; no translator change.

Tested

  • python -I tests/test_crosslane_fuzz.py: 71 tests OK (15 new in Ext: each op's model against hand-computed values, the loop's trip counts, forward and backward branch offsets, a label for every loop in the native kernel text, wave32 and no-flag seeds unchanged). --self-test OK. tests/test_docs_*.py OK.
  • Model against hardware, AMD Radeon RDNA2 iGPU (gfx1036, Ryzen 9 9950X3D, driver 26.10.1), raw wave64 kernels: --ext --dpp --wave 64 --oracle hw --programs 100 --seed 21 --no-maskdata matches 100/100 (groups of one to three waves and partial waves; 29 programs with a hypothesis op, all confirmed).
  • Translator on the same 100 programs, same GPU: native (64-wide subgroup, --w64-native) 85 match, 0 mismatch, 15 hyp_only; --wave64-emulate the same. The 15 reach an EXEC-off v_permlane or ds_swizzle_b32 source (Translator: v_permlane16/x16 FI=0 and BOUND_CTRL for source lanes off in EXEC (SHADER-74) #580, SHADER-503: zero inactive source lanes in DS_SWIZZLE_B32 #2780).
  • NVIDIA RTX 5080 (driver 616.92), --ext --dpp --wave 64 --modes emulate --programs 60 --seed 23: 46 match, 0 mismatch, 14 hyp_only.
  • Negative control: with s_bfm_b64's size masked with 31 instead of 63 in tools/rdna2spirv.py, --ext --wave 64 --modes emulate --programs 30 --seed 22 reports a mismatch (program 2200084, a bfm program, lanes 62-63); reverted, the same run has none.

What the hardware run settled is written up in docs/shader_validation.md (FUZZ-7): the DS ops need s_waitcnt lgkmcnt(0) before their result is used, they stay inside the 32-lane half, colliding ds_permute_b32 senders resolve to the highest lane, and an EXEC-off source reads 0.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule, so no contract row.

AI-assisted.

…h SCC and loops

Wave64 programs get v_*_co(_ci)_u32 through SGPR pairs and VCC, ds_bpermute_b32,
ds_permute_b32, ds_swizzle_b32, lane selects of 64 and up, the b64 mask ops with
an SCC probe, the saveexec/wrexec family, s_bfm_b64, s_wqm_b64 and SI_LOOP-shaped
loops. Seeds without the flag, and wave32 programs, are unchanged. The model was
checked on RDNA2 (gfx1036): 100/100 programs.

AI-assisted.
@ddm-j

ddm-j commented Nov 22, 2026

Copy link
Copy Markdown

Tested bf73f8e on AMD Radeon 610M iGPU (RDNA2 gfx1036, RADV Mesa 26.2.6, subgroup 32..64) and NVIDIA RTX 4070 Ti (615.78.08, subgroup 32..32), Fedora 45: pass, 0 mismatches anywhere.

Model against hardware. This is an independent run of the model on gfx1036, through tools/hw_oracle over Linux libdrm instead of the Windows driver. It's the same chip family as the author's, so it's independent of the driver, not the silicon.

--ext --dpp --wave 64 --w64-native --modes native --oracle hw --programs 100 --no-maskdata result
--seed 21 (the author's) match 100, mismatch 0; hyp_confirmed 29 (swizzle 20, permlane 12, dpp 7)
--seed 31 (new) match 100, mismatch 0; hyp_confirmed 42 (swizzle 29, permlane 17, dpp 5)

Seed 21 reproduces the description's 100/100 with 29 hypothesis programs, all confirmed.

Translator (--ext --dpp --wave 64 --programs 100 --no-maskdata):

seed 21 seed 31
RADV, --wave64-emulate 85 match, 0 mismatch, 15 hyp_only 71 match, 0 mismatch, 29 hyp_only
RADV, native 64-wide (--w64-native) 82 match, 0 mismatch, 18 hyp_only 67 match, 0 mismatch, 33 hyp_only
RTX 4070 Ti, --modes emulate 85 match, 0 mismatch, 15 hyp_only 71 match, 0 mismatch, 29 hyp_only

Also:

  • python -I tests/test_crosslane_fuzz.py: 71 tests OK (2 skipped). --self-test OK.
  • The PR changes only the tool, tests and docs, so I ran only a short Linux GPU check: run_gpu_tests.py --filter cs_w64x, 19/19 on RADV native and 19/19 on the 4070 with LEONIDA_W64_EMULATE=1; natively the 4070 skips them, as expected.

AI-assisted (Claude Code); numbers copied from the run logs.

@WHOISJARDAS

Copy link
Copy Markdown
Contributor

Tested bf73f8e on AMD Radeon RX 9070 XT (RDNA4, gfx1201), AMD 26.11.2 (LLPC), Windows 11: pass on your seeds. I found one translator gap on other seeds; it isn't caused by this PR. The runtime was built at f847748, this PR's base.

  • python -I tests/test_crosslane_fuzz.py: 71 tests OK (2 skipped). --self-test OK.
  • --ext --dpp --wave 64 --w64-native --programs 100 --no-maskdata (translator oracle), as match / mismatch / hyp_only:
seed --wave64-emulate native, 64-wide
21 85 / 0 / 15 85 / 0 / 15
31 71 / 0 / 29 71 / 0 / 29
2, 3, 4 77 / 0 / 23, 78 / 0 / 22, 79 / 0 / 21 same as emulated
1, 5 67 / 0 / 32 and 72 / 0 / 27, plus 1 rejected program each same as emulated
  • Native matches emulated on AMD's Windows driver, unlike RADV's 82/18 and 67/33 in ddm-j's run. Seed 21 also matches the 85/0/15 in your description. That fits ddm-j's guess that the native difference comes from the driver, and this run is on another architecture (RDNA4).
  • Runs without --ext are unchanged. With --wave 64 --w64-native --programs 100, seeds 1–3 give the same output as f847748.

The two rejected programs come from a translator gap.

  • cs_xl64_100060 (seed 1) and cs_xl64_500020 (seed 5) contain ds_swizzle_b32 vD, vS offset:swizzle(BROADCAST,32,0).
  • That encodes as offset 0, and llvm-mc then prints no offset: at all: ds_swizzle_b32 v3, v4.
  • Gen.swizzle (tools/rdna2spirv.py:1559 on main) finds no pattern and raises Unsupported: ds_swizzle pattern, so the fuzzer exits 1. The program is rejected both natively and with --wave64-emulate.
  • Offset 0 is BITMASK_PERM with the and, or and xor masks all 0, so every lane reads lane 0 of its 32-lane group.

I'm claiming the translator fix: a missing offset will be read as BITMASK_PERM "00000". I'll check it with this PR's fuzzer on seeds 1 and 5. Until it lands, --ext runs on those seeds end with exit 1.

AI-assisted (Claude Code).

@crastinator

Copy link
Copy Markdown
Contributor

Tested bf73f8e merged into main f847748c (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • Whole run_gpu_tests.py: 185/199 native, 185/199 with LEONIDA_W64_EMULATE=1 (skips: the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 41/41.
  • Model vs hardware (Linux DRM oracle), crosslane_fuzz --ext --oracle hw --programs 1000:
    • seed 1: wave32 500/500 and wave64 500/500 match, 0 mismatch (wave64: 80 hyp_permlane and 135 hyp_swizzle confirmed);
    • seed 2: 500/500 and 500/500 (wave64: 80 permlane and 144 swizzle confirmed).
    • No GPU fault in the kernel log.
  • Translator, the default modes, both waves, --ext --programs 1000:
    • seed 1: wave32 native 357 match / 28 mismatch / 115 hyp_only; wave64 emulate 346 / 18 / 136;
    • seed 2: 356 / 28 / 116 and 344 / 14 / 142.
    • None of these are new. main without --ext gives the same 28 wave32 mismatches on seed 1, and 33 for wave64 emulate. They are the known w32hi lane and EXEC-off permlane differences (most are tagged "program has a hypothesis op").
  • tests/test_crosslane_fuzz.py: 69 passed, 2 skipped, 9 subtests passed.

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

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested bf73f8ea, applied alone on main f847748c: pass, with one finding about two command lines in the description.

Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62, 64-wide subgroup) and RTX 3070 (NVIDIA 610.74, 32-wide), picked with LEONIDA_VK_DEVICE. vk_compute_test built from f847748c.

  • New test file on main's tool: python -I tests/test_crosslane_fuzz.py gives 15 errors in 71 tests (TypeError: Gen.__init__() got an unexpected keyword argument 'ext', AttributeError: module 'crosslane_fuzz' has no attribute 'branch_offsets').

  • Whole PR: 71 tests OK, 2 skipped (the two hardware-oracle tests: no AMD clang on this PC). --self-test OK. tests/test_docs_*.py (4 files) OK.

  • Translator against the model, --ext --dpp --wave 64 --no-maskdata:

    GPU mode seed programs match mismatch hyp_only
    Radeon native 64-wide (--w64-native) 21 100 85 0 15
    Radeon --wave64-emulate 21 100 85 0 15
    Radeon native 64-wide 21 300 227 0 73
    Radeon emulated 21 300 227 0 73
    RTX 3070 emulated 21 100 85 0 15
    RTX 3070 emulated 23 60 46 0 14
    RTX 3070 emulated 23 300 221 0 79

    The seed-21 rows of 100 and the seed-23 row of 60 are the description's numbers exactly. No rejected programs or harness errors in any run.

  • Negative control (s_bfm_b64 size masked with 31 in a scratch copy of tools/rdna2spirv.py, passed with --translator), --ext --wave 64 --modes emulate --programs 30 --seed 22 --no-maskdata on the RTX 3070: 1 mismatch, program 2200084; with the unchanged translator 0.

  • Finding: the RTX line and the negative-control line in the description leave out --no-maskdata, and as written they do not give the stated numbers here. --ext --dpp --wave 64 --modes emulate --programs 60 --seed 23 gives 45 match, 1 mismatch (program 2300127), 14 hyp_only; over 300 programs 215 / 6 / 79, the same six programs on the Radeon emulated and on the RTX 3070. --programs 30 --seed 22 without the flag gives 2 mismatches (2200078, 2200090) on both GPUs before any change to the translator, and 3 with the s_bfm_b64 change. Every one of these programs has a maskdata op (a mask read as data, Translator: a lane mask read as data gives the wave's bits (SHADER-21 part 1, #210) #293), and main's fuzzer without --ext gives 3 mismatches for seed 23 too, so they are the known Translator: a lane mask read as data gives the wave's bits (SHADER-21 part 1, #210) #293 gap and not the new ops; with --no-maskdata all the numbers above match the description. The two command lines in the description, and the --seed 23 sentence this PR adds to docs/shader_validation.md, should say --no-maskdata.

Not checked: --oracle hw (the model against the hardware; needs AMD clang, not on this PC), native wave64 on the RTX 3070 (no 64-wide subgroup), wave32 programs beyond what the unit tests cover.

AI-assisted; measured on my PC.

@ItsNotRexed
ItsNotRexed merged commit d672bc0 into ItsNotRexed:main Nov 23, 2026
0 of 4 checks passed
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