rdna2spirv: a VALU data read of a lane-mask operand yields the wave's mask word #1397
Open
github-bot
wants to merge 5 commits from
github-bot/gh-1397 into main
AGit
pull from: github-bot/gh-1397
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1397
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1397"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@whoalin1 on GitHub · 2026-11-24 23:23 UTC · original
whoalin1:mask-regs-data-read→main· +670 −41 · 14 files · 5 commits · openClaimed in the coordination issue: #14
Depends on: #953
What
A lane mask (EXEC/VCC or a mask-tracked SGPR) that an instruction reads as a 32-bit value — for example
v_mov_b32of it into a plain VGPR, or a scalar number reader such ass_add_u32 s20, s10, K— must produce the wave's mask word. Hardware SGPRs hold that wave-wide word; the translator previously produced each lane's own0/~0bit in the VALU path.This pull request now:
src_u/lane_mask_word), while mask consumers keep extracting the lane bit throughmask_src;if (active)runs, since the gather is a cross-lane operation;docs/design.mdrecords the contract. Semantic coverage includes narrowed SGPR/VCC reads, independent all-ones SGPR EXEC restore, EXEC round trips, scalar readers, vector-bitwise mask composition, native/emulated wave64 structure, and the eager-gather shape.Tested
python -I scripts/run_semantic_tests.py tests/semantic— 488 files, 6298 tests, 0 files failed;compileallclean;tests/test_lane_masks.pypassed.VK_LOADER_DRIVERS_SELECT=*nv-vk*):tools/crosslane_fuzz.py --programs 200 --seed 7 --wave 32 --modes native— 199 match / 1 mismatch / 0 hypothesis-only versus 186 / 9 / 5 atba315fbf1. The remainingcs_xl32_700032minimizes to an inactive-EXEC write-predication case (v_cmpx+ maskdatav_mov+v_xor), distinct from the narrowed-EXEC mask-word family and already present before this change.--programs 106) � 105 match / 1 mismatch / 0 hypothesis-only versus 100 / 3 / 3 atba315fbf1. The remainingcs_xl32_10200411is an EXEC-zero/readfirstlane control-flow case. AMD evidence is reported in the pull-request comments; no game files were used.AI-assisted (SWE-2.1 Max).
A register holds this lane's bit of a lane mask; v_mbcnt, s_bcnt1 and s_ff1 gather the other lanes' bits with a subgroup operation (Gen.wave_mask). v_mbcnt writes a VGPR, so its result is selected on the lane's EXEC, and MoltenVK's SPIRV-Cross inlined the single-use gather into the taken arm of that ternary: v6 = active ? popcount(simd_or(mine ? bit : 0) & below) + acc : v6; A lane that is off never ran the gather, so its bit was missing from every other lane's count. Gen.wave_mask now stores the gather to a variable of its own with Gen.eager, as SHADER-529 did for DPP's ballot and shuffle. On an Apple M5 (MoltenVK 1.4.2), tools/crosslane_fuzz.py with wave 32, native and no maskdata goes from 92 of 100 programs matching to 100 of 100, and from 193 to 200 of 200 with DPP at seed 7. Co-Authored-By: Claude Fable 5.2 <[email protected]> Co-Authored-By: SWE-2.1 Max <[email protected]>@GeorgiyDemo on GitHub · 2026-11-24 23:55 UTC · original
Tested
3ec97f53eon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain364ab4eab(translator-only PR; binaries from the build at66d4f5aa3, GPU test C++ unchanged in between):mainthey fail:test_lane_masks_vector_bitwise4,test_salu64_bitwise_data9,test_salu_movrels_lane_mask32,test_scselect_b64_data2 failures — the coverage claim holds.--filter mask6/12 passed, 5 skipped, 1 failed;--filter exec4/8, 3 skipped, 1 failed. The failure iscs_mask_vgpr_exec:15 15 15 15 3735928559 …where the fixture expects4294967295 4294967295 …(SHADER-21 part 2 fixture from72d7e52df). Withmain'stools/rdna2spirv.pyin the same worktree and the same binary it PASSes; reproduced 3/3 runs.cs_mask_vgpr_execPASSes with both this head andmain's translator — the same SPIR-V yields0xFFFFFFFFthere and0xFon MoltenVK.src_udata-read path callslane_mask_word→wave_mask, which rebuilds the mask with anOpGroupNonUniformBallotof this lane's bit. The fixture doesv_cmp_lt_u32 vcc_lo …(VCC =0xFFFFFFFF),s_mov_b32 exec_lo, 0xF, thenv_mov_b32 v2, vcc_lo; on MoltenVK the ballot only covers the four invocations active under that EXEC and returns0xF, while the hardware VCC word is0xFFFFFFFF. KosmicKrisp returns the full subgroup mask and hides it.So at least on MoltenVK this is a regression against an existing GPU test: a mask word read as data cannot be reconstructed by a ballot that the current EXEC restricts.
AI-assisted; synthetic fixtures only, no game data.
@ecox982745 on GitHub · 2026-11-25 00:46 UTC · original
I tested the mask word and the EXEC write mask independently on an RTX 4090, Windows 11, NVIDIA 616.64, with a 32-lane compute subgroup. At head
b9cea5af, 25/25 dispatches matched every lane; the same inputs matched in 9/25 at parent1154976d.The existing
cs_mask_vgpr_execfixture passed on both revisions here. I added four local synthetic probes, each run with six pairs of masks supplied at dispatch. They read eithervcc_loor a compare-written SGPR, through eitherv_mov_b32orv_xor_b32. A distinguishing case was a comparison setting the odd lanes (0xaaaaaaaa) followed by EXEC selecting the even lanes (0x55555555). On the head every even lane received the full mask word on the move, and the odd lanes kept their sentinel. On the parent every even lane received zero.For comparison with the MoltenVK report, the original fixture produced byte-identical SPIR-V from
3ec97f53andb9cea5afwith my default build (SHA-256b675f09a98b92c423c6706e5a864dbcd555afe0ae43ad7606aab33a609d899be). My module materializes the mask with twoOpGroupNonUniformBitwiseOr … Reduceinstructions and has noOpGroupNonUniformBallot. The fixture also passed withLEONIDA_PC_TAIL_UBO=1. Comparing the subgroup operations in the failing MoltenVK module would help narrow down the driver difference; this NVIDIA run leaves that failure open.Both revisions' five modules passed Vulkan 1.2 SPIR-V validation. I built the compute harness from the PR head. Separately, all 33 tests in the four changed CPU semantic test files passed on the head. AI-assisted verification.
@tiguan26 on GitHub · 2026-11-25 03:40 UTC · original
Merged b9cea5a into current main (
bfef489cb): no conflicts. The four test files this PR touches pass, and the changed expectations look right to me: a mask SGPR read by a VALU op is the 32-bit word on hardware, not the lane's 0 / ~0.The full translator suite (Linux, Python 3.13) has one new failure, and it's a good one:
tests/semantic/test_slot67_operand_forms.py::test_wave32_compare_high_word_preserves_low_and_clears_inactive_bitsis an unexpected success. That test is marked@unittest.expectedFailurewith a comment saying hardware copies the packed word (s_mov_b32 s8, vcc_hi->0x80000004) while main gives each lane its own mask value, which is what this PR fixes. With the marker left in, the suite reportsFAILED (unexpected successes=1). Dropping@unittest.expectedFailureand that comment's "fails there" sentence should make it green. Otherwise onlytest_int32_to_f64fails, as on main here (aspirv-optcrash in my environment).AI-assisted (Claude).
@thesubtleties on GitHub · 2026-11-25 04:03 UTC · original
I'm the author of #1043 (SHADER-MASK-AS-DATA), which overlaps. I ran both on main
bfef489c, RTX 3080 and gfx1036.Your branch (
b9cea5afb) handles the copy-then-v_readfirstlaneidiom that mine leaves out, and flags fewer fuzz programs: 12 here, 22 with #1043, 97 on main (fivecrosslane_fuzzruns).Two gaps:
--wave64-emulate, e.g.cs_xl64_2026173083558(seed 20261123, plain): "OpControlBarrier inside a folded lane-local region". The planner inwave64_emulate_opt.pyneeds to count these reads as exchanges; #1043 does it at three sites, feel free to reuse it.s_add_u32,s_mul_i32, shifts...) still see one lane's bit;test_mask_as_data.pyin #1043 covers them.test_slot67_operand_formsalso needs itsexpectedFailureremoved, for both of us. They look complementary; whichever merges first, I'm happy to rebase. AI-assisted (Claude Code)@levi2m on GitHub · 2026-11-25 04:27 UTC · original
Another card, native Windows: NVIDIA RTX 4050 Laptop (Ada, 10de:28a1), driver 621.01, Windows 11 build 26200, subgroup 32..32. No game files, nothing online.
tools/crosslane_fuzz.py, 200 programs per run, seeds 101, 102 and 103, on main3ff2a2adwithvk_compute_testbuilt from it. The "this PR" runs use only thetools/part of this diff (headb9cea5af) through--translator.--wave64-emulate, 600 programsEvery mismatching program on main includes the
maskdataop. The fix is confirmed on this card, and no harness errors on either side.Two things this PR leaves, for the record:
cs_xl64_10100316, opsbcnt, branch, cmp, exec, mask_salu, maskdata, mbcnt, mbcnt_data, permlane, readfirstlane, readlane, valu, writelane):AssertionError: wave64 emulation: x_split inside a folded lane-local region, fromemit_folded_region. This is the same class as theOpControlBarrier inside a folded lane-local regioncase in @thesubtleties' comment above, with a different assertion text.cs_xl32_10200411, also a mismatch on main): s13 is expected to be the same mask word in every lane (0xb945de14) and comes out per lane (0/0xffffffff). It reads a mask held in a scalar register, which may be the scalar follow-up mentioned in the PR notes; I did not trace it.The other fuzzers on main, same card, three seeds each, show nothing:
lds_fuzz(400 native and 300 emulated programs per seed) andvalu_fuzzf16 and mem (300 each) have 0 mismatches, andimage_fuzzmatches 300 of 300 per seed.AI-assisted: yes
@whoalin1 on GitHub · 2026-11-25 08:15 UTC · original
Pushed
8ece74e2aaddressing the review findings (EXEC-coverage gating for mask-word gathers incl. the MoltenVKcs_mask_vgpr_execballot-under-EXEC case, scalar mask-number reads, and the wave64-emulate folded-region gaps).Independent GPU verification on this head (RTX 4070 SUPER + AMD Radeon gfx1036 iGPU,
LEONIDA_VK_VALIDATION=1):cs_mask_vgpr_execpasses on both GPUs;--filter mask/execcurated shaders: AMD 12/12 + 8/8, NVIDIA same modulo wave64 skips; withLEONIDA_W64_EMULATE=1on NVIDIA all 20 pass.crosslane_fuzzseeds 101-103, 100 programs/seed, wave 64, modes plain /--ext/--ext --dpp: 0 mismatches, 0 rejected on both GPUs (baseline main had ~6-11 mismatches per 100-program run).AI-assisted work.
@ecox982745 on GitHub · 2026-11-25 08:48 UTC · original
8ece74e2afixes the reported wave64 translation failure on my RTX 4090. I also found a wave32 regression relative to its immediate parent142293b30: when EXEC comes from a register, a vector read of a previously computed mask can return just the current lane’s bit.With all 32 lanes active,
v_cmp_ne_u32_e64 s8, v5, 0setss8to0x05010204(v5contains the corresponding bit in each lane). Then set EXEC and runv_mov_b32_e32 v2, s8. Both variants below have identical runtime EXEC and use the same input and harness.8ece74e2a0x05010204s_mov_b32 exec_lo, -10x05010204s_mov_b32 exec_lo, s4, withs4 = 0xffffffff0or0xffffffffAcross the previous 25-dispatch test, the parent matched 800/800 lane results. The new head had 224 wrong lane results across 16 dispatches. This includes VCC and compare-written
s8, with both move and XOR consumers. The unchangedcs_mask_vgpr_execfixture passed. The literal/register pair above would make a regression test for the fallback inmask_word_read_ok.I also replayed the two exact programs from the RTX 4050 report against the fuzzer’s CPU reference:
cs_xl64_10100316, emulated wave64: parent refused translation. Head translated, passedspirv-val, and matched all 896 checked words.cs_xl32_10200411, native wave32: 64/896 words still differ on both revisions. The first expected0xb945de14and read zero. This is program 106 for seed 102 with a single wave size and the default 24 operations, beyond the reported 100-program sweep.Windows, NVIDIA 616.64, LLVM 23.1.6. I rebuilt
vk_compute_testat8ece74e2aand reran both revisions with it. The 16 tests in the two changed semantic test files passed on CPU. AI-assisted verification using synthetic inputs.@whoalin1 on GitHub · 2026-11-25 08:59 UTC · original
Thanks ecox982745 — confirmed reading. The
s_mov_b32 exec_lo, s4(register-sourced EXEC) vs literal-1divergence points at themask_word_read_okfallback treating a register-written EXEC mask as lane-local; a literal-vs-register EXEC pair is exactly the regression test we'll add. We're reproducing on the RTX 4070 SUPER + AMD gfx1036 iGPU, will fix on this branch, and re-verify both revisions' 16-dispatch sweep. Noted oncs_xl32_10200411(seed 102 prog 106, native wave32, 64/896 words on both revisions) — tracking separately as it predates this fix. AI-assisted.@Gefik23 on GitHub · 2026-11-25 09:19 UTC · original
Tested 8ece74e2a with
tools/crosslane_fuzz.pyon NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200, native Windows. llvm-mc 21.1.8 (scripts\build_llvm_mc.ps1),vk_compute_testfrom main3f81d46ac,--translatorpointed at this PR'stools/rdna2spirv.py.3f81d46ac--programs 50 --seed 1--programs 200 --seed 7, wave32 native--programs 200 --seed 7, wave64 emulate--programs 50 --seed 1 --no-maskdata(main only)So every wave64 mismatch on these seeds is gone. The 7 wave32 mismatches left (
cs_xl32_7000{87,135,151,153,185,197,205}) also fail on main, so they are not regressions. With--minimizethey all come down to a mask computed under one EXEC and read as data under a narrower one, which looks like the same family as the register-EXEC case above. The two shortest:In both cases the bits of lanes 20..31, which are not in the group, read back as set. Full-wave groups fail the same way, for example
cs_xl32_700032(group 64):v_cmp_gt_u32_e64 s16, v2, v4/v_cmpx_gt_u32_e32 31, v3/v_mov_b32_e32 v7, s16. To reproduce:python -I tools/crosslane_fuzz.py --programs 200 --seed 7 --wave 32 --translator <this PR>/tools/rdna2spirv.py --minimize.AI-assisted (Claude Code ran the fuzzer and the reductions). No game files.
@whoalin1 on GitHub · 2026-11-25 11:13 UTC · original
Pushed
ba315fbf1fixing the wave32 register-EXEC regression @ecox982745 reported.Root cause:
Gen._mov_sgpr_valshandledexec/exec_lo/exec_hisources only under clean/constant EXEC half-state — under an unknown narrowing (("n", tag)) it recorded nothing, sos_mov_b32 exec_lo, s4minted a fresh tag andmask_word_read_okdenied the mask-word gather (per-lane 0/0xffffffff). The fix aliases the SGPR to the narrowing tag using the same("al", ...)schemes_*_saveexecalready uses, which_exec_src_exresolves — literal and register EXEC restores now behave identically.New coverage: 2 semantic tests (wave32 + wave64 EXEC round-trip asserting the
OpGroupNonUniformBitwiseOrgather) +cs_exec_copyGPU fixture storing mask word / exec_lo word / literal-restore word side by side.Verification (RTX 4070 SUPER + AMD gfx1036 iGPU,
LEONIDA_VK_VALIDATION=1): semantic suite 487 files / 6,291 tests / 0 failed; exec+mask filters andcs_exec_copyPASS on both GPUs with identical words; literal-vs-register now agree (out[0]==out[2]). Independent review APPROVEd (tests confirmed to fail on the parent translator). Re-running the narrowed-EXEC fuzz repros (cs_xl32_700087/700152/700032 family) to confirm coverage — will follow up. AI-assisted.@ecox982745 on GitHub · 2026-11-25 11:15 UTC · original
I verified
ba315fbf1against its parent8ece74e2aon the RTX 4090. The saved-EXEC round trip is fixed: the newcs_exec_copyfixture went from 32 wrong output words on the parent to 128/128 correct on the head. The original case from my earlier report still fails when EXEC is set from an independent SGPR after the comparison.Here's a small way to reproduce that distinction using the PR's own
cs_exec_copy.asm. Keep the expected outputs and the rest of the fixture as written:EXEC is full when the comparison defines
s8and is full again when the move reads it. With the edit, all 32 lanes get the first output word wrong: even lanes return zero, odd lanes return0xffffffff, and all should return0xaaaaaaaa. The other three fields match in every lane, including the EXEC word and the mask read after the literal restore.The original five synthetic modules are byte-identical across these two commits. Re-running their 25 dispatches gave the same 224/800 wrong lane results across 16 dispatches. A diagnostic that reads the complete mask into a VGPR immediately after the compare, before changing EXEC, matched all 96 lane results across three full and partial EXEC patterns. This gives a passing control for investigating where the complete mask word can be preserved.
Native wave32, Windows 11, NVIDIA 616.64, LLVM 23.1.6. The edited fixture passed Vulkan 1.2 SPIR-V validation. All 16 CPU tests in
test_lane_masks_vector_bitwise.pypassed on the head. AI-assisted verification.@hugo0024 on GitHub · 2026-11-25 11:57 UTC · original
Tested
ba315fbf1merged onto mainbcaa13dadon an Apple M5 (MoltenVK 1.4.2, macOS 27.2.1), with the test programs built from that main. AI-assisted.The fixtures on MoltenVK
run_gpu_tests.py --filter mask: 7/12 passed, 5 skipped.--filter exec: 6/9 passed, 3 skipped.cs_mask_vgpr_execand the newcs_exec_copypass; every skip is "no 64-wide compute subgroup on this device".crosslane_fuzz.py --programs 200 --seed 31008 --wave 32 --dpp --ext(match / mismatch / hypothesis only)b9cea5afb8ece74e2aba315fbf1#953 is the whole-wave mask gather that MoltenVK needs stored, so the right-hand column is the one to read on this driver. The
b9cea5afbrow was measured earlier today on main3f81d46ac; the translator on main changed once since then (#1493).The 12 programs left at
ba315fbf1are the same 12 as at8ece74e2a, and all are the family @Gefik23 and @ecox982745 describe, a mask read by a VALU op after EXEC changed:What this run adds: all 12 matched at the first head,
b9cea5afb. For the three I looked at (cs_xl32_3100893037,..125,..134),b9cea5afbemits twoOpGroupNonUniformBitwiseOrand the two later heads emit no subgroup operation at all, as main does. So this family is not a MoltenVK effect, and the first head had it right.wave64 emulate,
--programs 150 --seed 31009 --wave 64 --modes emulate --dpp --ext: main 144 / 5 / 1,ba315fbf1149 / 1 / 0, nothing rejected. The one left fails on main too,cs_xl64_3100993145(group 40), minimised:Not tested: any other GPU, and the game corpus.
@EvgHaze on GitHub · 2026-11-25 13:11 UTC · original
Apple check of the new
cs_exec_copyfixture, on both drivers.scripts/run_gpu_tests.py --filter cs_exec— identical words on both drivers, 3/3 passed:cs_exec640 0 0 0 0 0 0 0cs_exec_const16 8 2 16 0 16cs_exec_copy(new)2863311530 4294967295 2863311530 0 2863311530 4294967295 2863311530 1python3 -I scripts/run_semantic_tests.py tests/semantic→ 489 files, 6300 tests, 0 failed (main is 6288, so this diff adds twelve), 143 s.Both Apple drivers run these at subgroup size 32 natively, so the lane-mask-as-data read is not being emulated in either run. MoltenVK's SPIRV-Cross path and KosmicKrisp's
nir_to_mslpath agree word for word.AI-assisted. No game data: hand-written fixtures, and the numbers above are test output.
@GeorgiyDemo on GitHub · 2026-11-25 14:14 UTC · original
Follow-up: the regression I reported at
3ec97f53e(cs_mask_vgpr_exec:15 15 15 15 …on MoltenVK) is gone atba315fbf1on the same machine where it reproduced — Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), MoltenVK 1.4.2, binaries from the build at66d4f5aa3:cs_mask_vgpr_execPASS:4294967295 4294967295 4294967295 4294967295 3735928559 3735928559 3735928559 3735928559on MoltenVK and the same on KosmicKrisp (Mesa 26.3.1).--filter mask: 7/12 passed, 5 skipped, 0 failed (all skips are "no 64-wide compute subgroup on this device").--filter cs_exec: 3/3 PASS, including the newcs_exec_copy(2863311530 4294967295 2863311530 0 …), same words as the M3 run.test_lane_masks_vector_bitwise,test_salu64_bitwise_data,test_salu_movrels_lane_mask,test_scselect_b64_data): OK.So this is fixed on macOS 26.7.3 as well, not just on the 27.x runs above.
AI-assisted; synthetic fixtures only, no game data.
@aslan2142 on GitHub · 2026-11-25 16:37 UTC · original
Thanks, @whoalin1. The saved-EXEC round trip is fixed. Open points:
main.b9cea5afband mismatch now.AI-assisted (Claude Code, Claude Opus 5.5).
@ecox982745 on GitHub · 2026-11-25 16:47 UTC · original
I compared #1043 (
4d58a05d6) and #1397 (ba315fbf1) for the independent-EXEC case in the review above. I merged each PR separately ontomainat9e7720c9elocally and ran the same synthetic wave32 shaders on an RTX 4090, Windows 11, NVIDIA 616.64. Both merges were clean. This is GPU readback using the same executable for all three builds.cs_exec_copy(correct output words / 128)v_mov_b32(dispatches passing / 12)v_xor_b32(dispatches passing / 12)The move and XOR rows each cover six runtime mask pairs for each of two sources, VCC and compare-written
s8. Adding the stockcs_mask_vgpr_execcontrol gives 9/25, 17/25 and 9/25 passing dispatches respectively. Across those 25 dispatches, #1043 reduced incorrect lane values from 224 to 112, all in XOR. Every module passed Vulkan 1.2 SPIR-V validation, and every readback guard was intact.For the overlapping fixes, #1043's handling of
v_mov_b32already covers both EXEC fixtures here. The XOR row gives a separate regression target for the remaining arithmetic use of a mask. This comparison covers native wave32 on this GPU. AI-assisted verification with OpenAI Codex.@whoalin1 on GitHub · 2026-11-25 17:07 UTC · original
Pushed
52fb23042. This reworks the narrowed-EXEC side rather than extending the coverage proof:Verified here (no game files):
run_semantic_tests.py tests/semantic: 488 files, 6298 tests, 0 files failed;compileall,tests/test_lane_masks.py, andcheck_no_game_datapassed.crosslane_fuzz.py --programs 200 --seed 7 --wave 32 --modes native199 match / 1 mismatch / 0 hyp-only (was 186 / 9 / 5 atba315fbf1); seed 102, 106 programs 105 / 1 / 0 (was 100 / 3 / 3).The residual is
cs_xl32_700032, minimized tov_cmp+v_cmpx+ maskdatav_mov+v_xor; it is an inactive-EXEC write-predication case that already mismatched before this work, not the narrowed-but-nonzero EXEC mask-word family.cs_xl32_10200411also remains in the seed-102 stream and starts withexec_lo = 0, a separate no-active-lane/readfirstlane control-flow case.On overlap: #1043 currently fixes the independent-EXEC
v_movcases but not arithmeticv_xorin ecox982745's comparison. This head is intended to cover mask data reads uniformly; I have not merged or duplicated #1043's follow-forward VGPR-copy analysis.AI-assisted (SWE-2.1 Max).
@EvgHaze on GitHub · 2026-11-25 17:11 UTC · original
Apple run of the new head
52fb23042, on both drivers.--filter cs_execcs_exec_copywords2863311530 4294967295 2863311530 0 2863311530 4294967295 2863311530 1--filter mask(non-64-wide)cs_mask_vgpr_exec4294967295 4294967295 4294967295 4294967295 3735928559 3735928559 3735928559 3735928559490 files, 6307 tests, 0 failedTwo things worth stating plainly:
cs_exec_copy, so my run does not cover them and I am not claiming it does. If you paste that fixture or point at a branch with it, I will run it on this machine in the same two drivers and add the row.AI-assisted. No game data.
@ecox982745 on GitHub · 2026-11-25 17:15 UTC · original
@EvgHaze, here are the synthetic fixtures for the Apple run. On the RTX 4090,
52fb23042passes 25/25 dispatches (800/800 lane results), up from 9/25 onba315fbf1. The independent-EXEC move and XOR rows both pass 12/12. The separate saved-EXEC and independent-SGPR fixtures each pass 128/128 output words. All readback guards were intact. This closes the two failing rows from my earlier comparison on this GPU.I ran the PR head directly with native wave32 on Windows 11, NVIDIA 616.64. I also translated all seven programs after merging this head onto the same
main(9e7720c9e) used in the comparison. All seven SPIR-V modules matched the ones dispatched byte for byte and passed Vulkan 1.2 validation.Independent SGPR fixture and all-lane check
Save as
runtime/test/shaders/cs_exec_copy_independent.asm.From the repo root, with your usual driver and push-constant settings and
vk_compute_teston PATH, run the following for each driver. The last command checks the full result, including 16 guard words.Independent-EXEC move and XOR rows
This is the exact
s8XOR shader. For the move variant, replace onlyv_xor_b32_e32 v2, s8, v7withv_mov_b32_e32 v2, s8. For the VCC pair, replaces8withvcc_loin the compare and the consumer. Build each name with the samebuild.pycommand as above.Run each variant once per pair below, setting
VKC_SGPRS=s4,s5to the two literal hex values,VKC_SUBGROUP_SIZE=32andVKC_OUT_WORDS=64. For lanei, when bitiofs4is set, expects5for the move ors5 ^ 0x12345678for XOR. Otherwise expect0xdeadbeef. Words 32–63 keep the harness fill0xeeeeeeee.AI-assisted verification with OpenAI Codex.
@mrgenty on GitHub · 2026-11-25 18:03 UTC · original
Tested
52fb23042withcrosslane_fuzz.pyon an NVIDIA GeForce RTX 3060 (NVIDIA 621.24, Windows 11 build 26300, subgroup 32..32). One program is left, reduced to four instructions below.Setup:
vk_compute_testand the fuzzer (with its model) from mainb0f3d399,--translatorpointed at each tree'stools/rdna2spirv.py, llvm-mc 21.1.8 (scripts\build_llvm_mc.ps1), Vulkan SDK 1.4.363.0. No game files.b0f3d3994d58a05d652fb23042With
--no-maskdata, main matches 400/400 in both modes on this card (seed 73190611), so the masks-as-data programs are the only ones that differ here.The one left here:
cs_xl32_2511325437669, wave32, group 20.--minimizegives:v3was seeded aslane + 0xd4718f66. The model expectss14 = 0xd4718f66in every lane, lane 0's untouchedv3. This head returns0x00018f66in all 20 lanes, which is that value ANDed with0xfffff, the 20 lanes of the group. So it looks as if thev_readfirstlanereadsv3as a mask word because av_movfrom a mask reaches it, although thatv_movwrote no lane. I did not trace it in the translator, so take the cause as a guess; the numbers are measured.It is not a regression: main fails the same program differently (each lane gets its own
v3, so only lane 0 is right), and #1043 returns0x000fffff.For comparison, the four programs #1043 leaves on this seed reduce to a
v_mov_b32of a mask followed byv_readfirstlane_b32(three wave32 cases, one with EXEC set to 0 first) and tov_mov_b32 v3, s21of the high half of as[20:21]mask under--wave64-emulate. This PR matches all four.Not tested: native wave64 (this card has no 64-wide subgroup), other seeds on this head, and the semantic suite.
AI-assisted (Claude Code).
@ecox982745 on GitHub · 2026-11-25 18:16 UTC · original
I narrowed down the RTX 3060 result on an RTX 4090. It also happens when both the move and the read have active lanes. This gives a regression test independent of the semantics of a read with empty EXEC.
On
52fb23042, seedv3with0xd4718f66 + lane, let only lane 7 overwrite its ownv3, then restore full EXEC before reading lane 0. The shader stores bothv3directly and the word returned throughs14. Lane 0's direct word is correct in all three group sizes.s140xd4718f660x000000660xd4718f660x00018f660xd4718f660xd4718f66Removing only the predicated
v_movgave the full expected broadcast in all 12 control dispatches. Selecting lane 7 as the reader after only lane 3 wrote gave the same truncation at group sizes 8 and 20. Reading lane 7 after lane 7 itself wrote gave the expected0x80in all three sizes.In the 20-thread module,
OpGroupNonUniformShufflebroadcasts the word, then a shift and AND extract one bit per lane. Thes14consumer rebuilds the word withOpGroupNonUniformBitwiseOr … Reduce. A 20-thread group can supply only bits 0–19 to that reduction. This points to preserving the full scalar value through this read when the selected lane retains ordinary data. Read-first-lane lowering on the tested headNative wave32, Windows 11, NVIDIA 616.64. Six synthetic modules per revision passed Vulkan 1.2 validation, with all readback guards intact. Baseline
9e7720c9ealso fails the 20-thread live-move case, returning different words across lanes. AI-assisted verification with OpenAI Codex.@whoalin1 on GitHub · 2026-11-25 19:33 UTC · original
Thanks for narrowing this down. I agree with the interpretation that this is a mixed-provenance case rather than a regression introduced by
52fb23042: your baseline control also fails the live-move case.The current model has one static provenance for the whole VGPR.
lane_masks.pyalready special-cases the copy shape: av_mov_b32of a mask into a VGPR is an ordinary EXEC-gated VALU write, not an all-lanes mask computation, so inactive lanes keep their old data. But after that write the register can contain the mask word in some lanes and ordinary data in others. Whenv_readfirstlanelater selects a lane, the correct result depends on which kind of value that selected lane retained. The present translator cannot represent that lane-dependent provenance, so it chooses the mask interpretation for the whole register and rebuilds only the mask bits — exactly the 8/20-thread truncation you measured.I do not see a small sound fix inside this PR without tracking which lanes of the VGPR received the mask word (or otherwise carrying per-lane provenance) through the copy and the first-lane selection. Since the case exists on main as well, my preference is to treat it as a follow-up rather than block the lane-mask data-read improvement here. If others prefer, I can write the finding up separately with your reduced shader as the reproducer.
AI-assisted analysis with Devin.
@whoalin1 on GitHub · 2026-11-25 22:38 UTC · original
Rebased onto current
main(581ddba5d) and pushed ase3e119a46; GitHub now reports the PR mergeable again. The only conflicts were the fixture-list intersections with the newly mergedcs_w32_wrxchg2*/cs_w64x_partial_swizzleentries; resolution keeps both those andcs_exec_copy.Post-rebase verification on this machine:
python -m compileall -q make_game.py tools tests scripts/run_gpu_tests.py runtime/test/shaders/check.py— pass.python -I scripts/run_semantic_tests.py tests/semantic— 493 files, 6,334 tests, 0 files failed in 345 s (Python 3.14).python -I scripts/run_gpu_tests.py --filter cs_exec_copy --require-pass— pass on both GPUs, withLEONIDA_VK_VALIDATION=1and spirv-val clean:cs_exec_copyPASS, exact words.cs_exec_copyPASS, identical exact words.No game files used. AI-assisted with Devin.
@whoalin1 on GitHub · 2026-11-26 05:01 UTC · original
Additional AMD evidence on the current head
e3e119a46f. Same synthetic crosslane slice before/after, no game files:a73a57e13, seed 14 wave64-emulate slice (26 programs, --dpp --ext): 23 match, 1 non-hypothesis mismatch (cs_xl64_1400067), 1 hypothesis-only mismatch (cs_xl64_1400059). The companion wave32-native half was 25/25 clean.So this PR fixes both seed-14 wave64-emulate divergences on AMD, including the non-hypothesis cs_xl64_1400067 case.
@EvgHaze on GitHub · 2026-11-26 05:58 UTC · original
@ecox982745 ran your five fixtures on the Apple side, at this head (
e3e119a46), on both drivers.s8(6 SGPR pairs)s8(6 SGPR pairs)vcc_lo(6 SGPR pairs)vcc_lo(6 SGPR pairs)Every lane value and
0xeeeeeeeefill word matches, and both drivers agree word for word — a 32-wide host runs these natively, so nothing here goes through wave64 emulation.Two notes on reproducing it:
v_cmp_ne_u32_e64 vcc_lo, v5, 0(your VCC variant) assembles, but the move variant has to drop thev7operand —v_mov_b32_e32 v2, s8, notv_mov_b32_e32 v2, s8, v7; with three operands llvm-mc rejects it.AI-assisted. No game data: hand-written shaders, and every number above is a readback comparison.
@ecox982745 on GitHub · 2026-11-26 06:19 UTC · original
@sdelectron, I checked the six seed-1 cases you reported on the RTX 5080 against this PR on a physical RTX 4090. All six also differ from the CPU reference on current main. All six match after merging this PR locally. That includes the three read-first-lane cases (
100023,100075,100014), parked lane access (100026), the prefix count (100034), and the 18-lane tail mask (100077). For the last case main returned0xffffffffwhere the reference has0x0003ffff. Seed-1 coordination reportsa73a57e13e3e119a46I used main's
crosslane_fuzz.pygenerator and reference (--seed 1 --programs 100 --wave both, default 24 ops), assembled the inputs once and ran both sets with the samevk_compute_testbuilt from main. Six of the ten main-side mismatches were ordinary model comparisons. The other four programs contain an operation the fuzzer marks as a hypothesis. All 200 dispatched modules passed Vulkan 1.2 SPIR-V validation and ran with Khronos validation enabled. Windows 11, NVIDIA 616.64. The clean merge tree wasdd50d3bb2bb09f7d406a90cc0c534a5af48f6300.I also retested the separate lane-7 fixture on that merge tree to check what remains for the mixed-provenance claim. After only lane 7 writes a mask to its vector register and full EXEC is restored, the direct lane values are all correct. The broadcast of lane 0 should give
0xd4718f66; it still gives0x00000066for 8 threads and0x00018f66for 20. The 32-thread case and all three controls without the predicated move pass; all guard words stayed intact. This smaller fixture still exercises the outstanding bug even though the full seed-1 corpus now passes.AI-assisted verification (OpenAI Codex). All shaders and inputs were synthetic.
@Christopher-Sundeby on GitHub · 2026-11-26 13:14 UTC · original
Verified on NVIDIA: this pull request clears 19 of the 20
crosslane_fuzzmismatches thatmaingives on four seeds, with no new ones. The one left is the knowncs_xl64_200065.Setup: RTX 3060 Ti (subgroup 32), NVIDIA 621.24, Windows 11, MSVC
vk_compute_test. The heade3e119a46merges cleanly ontomaina73a57e13. llvm-mc 21.1.8 (AMDGPU),--programs 100 --wave both(50 wave32 native + 50 wave64 emulate per seed), translator oracle.mainmismatches (w32 / w64 emu)mainhypothesis-onlycs_xl64_200065(seed 2, wave64 emulate,s10expected0x0000008c, got0x00000000). That is sdelectron's repro of the outstanding SHADER-READFIRSTLANE-MIXED-PROVENANCE part, so it is not new.cs_xl64_700024, wave64 emulate) that this pull request fixes:python -I scripts/run_semantic_tests.py tests/semanticon the merged tree: 499 files, 6,370 tests, 0 files failed (262 s, 32 jobs).mainwith the same setup (seed 41, 100 programs, native and emulated) are clean:valu_fuzzf16 and mem,lds_fuzz,image_fuzz(seed 42),f32_fuzz(seed 42, 200 programs).No game files. AI-assisted (Claude Code).
@qhukz13 on GitHub · 2026-11-26 14:14 UTC · original
I checked
e3e119a46merged onto maina73a57e13(no conflicts), CPU only, on Linux with Python 3.14. The GPU side is well covered above, but every run there iscrosslane_fuzzcompute. This adds the mesh stage under--wave64-emulate: 128-thread NGG mesh shaders (two waves) are the "VS as MS" path the world-load draws take. I ran them inspirv_mini_interp.run_workgroupon 32-wide subgroups and compared each thread's exported position with a hand model.The bug is there on the mesh path too, and this fixes it. Take
v_cmp_gt_u32 vcc, 40, v0, thenv_mov_b32 v6, vcc_lo:0instead of the word0xffffffff;v_cmp_gt_u32_e64 s[10:11], 40, v0followed bys_add_u32 s20, s10, 1is wrong on the same 24 lanes.With this PR both are right, in the structured form and in the forced round-loop form.
No regressions on the mesh path:
v_readfirstlane/s_and_saveexecloops;execnz,v_cmpxand VCC-vote latches;s_barrier+ LDS inside a loop;s_endpgm.s_cmp_eq/lg/lt_u32ands_bitcmp1_b32on a mask word, intos_cselect_b32or a branch, are right on both trees. I had wondered whetherMASK_NUMBER_READERSneeds the compares, and it does not.tools/cf_diff.py's programs as 2-wave mesh shaders: 300 programs (seeds 21-22, depth 3), each in the default form, the forced round-loop form and without the extras_barrier. That is 900 runs, 350 of them in the round-loop form: 900 matchcf_ref, with no non-uniform barrier and no runaway loop.73516a290(Windows 10, Python, 24 jobs): 499 files, 6,370 tests, 0 files failed.Cost, for the record. Each mask-as-data read site adds one exchange segment under
--wave64-emulate. The scheduler switch goes 2 → 3 cases for a singlev_mov_b32 v, vcc_lo, and 5 → 6 for one inside a loop, plus 2 workgroup atomics. The staticOpControlBarriercount is unchanged, but in the round-loop form an extra segment is an extra round at run time. That includesv_mov_b32 v6, exec_lowith EXEC still full, which main already got right. If a census ever shows these reads are common in the mesh corpus, the gather could be skipped wherelane_masksproves the mask is all ones or zero. That is not a reason to hold this.On #1043: plamea's seed-1 sweep (#1608) and the runs above have this PR covering everything #1043 does, plus the
v_readfirstlanecases, and #1043 is 553 commits behind. I would merge this one.AI-assisted (Claude Code).
@kawaii-shakal on GitHub · 2026-11-27 10:02 UTC · original
Independent check of
e3e119aunder--wave64-emulate, by Claude Code (AI-assisted) on my behalf. Linux, Mesalavapipe (llvmpipe, LLVM 19.1.7, 8-lane subgroups; emulated wave64 uses no subgroup operations, so it is judged
there, docs/shader_validation.md "Subgroup size").
tools/crosslane_fuzz.py --wave 64 --modes emulate --dpp --ext(main's fuzzer,--translatorpointed at thishead):
d1dff794Every one of main's 21 failing programs has a mask read as data (
maskdata); none is left here, and nothing isrejected. Minimized on main, the shortest are:
s_bfm_b64 s[18:19], 47, 49/v_mov_b32_e32 v3, s19(group 192): expected 0xfffe0000 in every lane, maingives 0 or 0xffffffff per lane.
s_bfm_b64is not mentioned in this thread, so this may be a useful fixture.v_cmp_gt_u32_e32 vcc, 51, v1/v_mov_b32_e32 v3, vcc_hi(group 64): expected 0x0007ffff.v_cmp_ne_u32_e64 s[18:19], v7, v4/s_and_b64 s[20:21], .../v_mov_b32_e32 v5, s21in a group of 100(a partial second wave): expected 0x0000000f in wave 1.
No regressions seen on this head (each its own seed):
tests/semantic493 files / 6,334 tests, 0 failed;lds_fuzz.py --wave 64 --emulate150/150;valu_fuzz.py --family mem --wave 64 --emulate120/120;cf_diff.py --wave 64300/300. Native wave32 was not run (lavapipe can't pin 32-lane subgroups), and no hardwareGPU. The branch now conflicts with main.
Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.