Skip to content

crosslane_fuzz: --pc-tail-ubo for 128-byte push-constant GPUs - #1507

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
whoalin1:crosslane-pctail-ubo
Nov 25, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
whoalin1:crosslane-pctail-ubo

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #14 (comment) (posted earlier as a finding:).

What

tools/crosslane_fuzz.py had no --pc-tail-ubo flag and never forwarded it to rdna2spirv.py. On GPUs with maxPushConstantsSize = 128 (e.g. AMD Radeon iGPUs) every translated program failed with "need 144 push constant bytes", and setting LEONIDA_PC_TAIL_UBO=1 only for the harness ran the shader against the wrong layout — every word came back as the 0xEEEEEEEE anti-fold fill counted as mismatches. lds_fuzz/valu_fuzz/image_fuzz already handle this.

Mirrors the sibling-fuzzer pattern exactly: pc_tail_env() (LEONIDA_PC_TAIL_UBO = 1/true/yes/on), translate(..., pc_tail=) appends --pc-tail-ubo, gpu_env/run_gpu set LEONIDA_PC_TAIL_UBO=1 for the vk_compute_test side (both sides must agree — the SPIR-V layout is baked at translate time), still_fails ctx carries pc_tail so --minimize re-translates with the same layout, and --pc-tail-ubo works standalone or via the env var. Default off → NVIDIA/other devices unaffected.

Tested

  • tests/test_crosslane_fuzz.py: 76 tests OK — new PcTailUbo class pins flag→translator, flag/env→gpu_env, env→enabled through main(); 5 existing fakes updated for the new kwarg.
  • compileall clean; --help shows the flag.
  • GPU spot-check, AMD Radeon iGPU (gfx1036, driver 24.10.24, validation on, LEONIDA_PC_TAIL_UBO=1): --programs 8 --seed 1 --wave both --modes native,emulate --no-maskdata --pc-tail-ubo → wave32 native 4/4 + wave64 emulate 4/4 match, 0 harness errors (previously every program errored).

AI-assisted (Devin).

@GeorgiyDemo

Copy link
Copy Markdown
Contributor

Tested 1aeceed3a on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main f78385646 (Python fuzzer; GPU execution through vk_compute_test from the build at 66d4f5aa3):

  • pytest tests/test_crosslane_fuzz.py (pytest 9.2.0 from tests/requirements.txt): 74 passed, 2 skipped, 18 subtests passed. The same file on main: 5 failed, 72 passed, 2 skipped, 15 subtests — all five PcTailUbo::* tests fail there.
  • crosslane_fuzz.py --pc-tail-ubo --programs 5 --seed 1 --exe …/vk_compute_test: 5/5 match (3 wave32 native + 2 wave64 emulate, 0 mismatch, 0 harness errors). On main the flag is rejected: error: unrecognized arguments: --pc-tail-ubo.
  • Note on the device: M5 Pro reports maxPushConstantsSize = 256, so the 128-byte limit that motivated the flag is not present here; the pc-tail-ubo translation/harness path itself runs and matches, but the real 128-byte constraint is not exercised.

AI-assisted; synthetic fixtures only, no game data.

@ytsodacan

ytsodacan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

[KEEP]

@ytsodacan

ytsodacan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

[MERGE]

#1501 and #1508 are being marked duplicates of this PR; a maintainer still has to merge this one and close them.

@Gefik23

Gefik23 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tested 1aeceed on NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200, native Windows: pass.

llvm-mc 21.1.8 from scripts\build_llvm_mc.ps1, Vulkan SDK 1.4.363.0, vk_compute_test from scripts\build_runtime.ps1 (RelWithDebInfo). python -I tools/crosslane_fuzz.py --programs 50 --seed 1 (wave32 native + wave64 emulate):

run match other
main's fuzzer with LEONIDA_PC_TAIL_UBO=1 (the bug) 0 / 50 35 mismatch, 15 hyp_only, 0xeeeeeeee dumps
this PR, no flag 45 / 50 4 mismatch, 1 hyp_only
this PR, --pc-tail-ubo 45 / 50 same
this PR, LEONIDA_PC_TAIL_UBO=1 45 / 50 same

The three logs from this PR are byte-identical, so on a GPU with 256 push-constant bytes the 128-byte layout gives the same words as the 144-byte one. The 4 remaining mismatches (cs_xl32_100023 native; cs_xl64_100014, cs_xl64_100026, cs_xl64_100034 emulate) are the same without the flag and outside this PR. pytest tests/test_crosslane_fuzz.py: 74 passed, 2 skipped.

AI-assisted (Claude Code ran the build and tests). No game files.

@whoalin1

Copy link
Copy Markdown
Contributor Author

Real-hardware check on the rebased head c7b4b3f9c: AMD Radeon integrated GPU of a Ryzen 5 7600 (RDNA2/gfx1036, Windows driver 24.10.24, Vulkan 1.3.280, maxPushConstantsSize 128), pc-tail enabled.

tools/crosslane_fuzz.py --programs 50 --seed 1 completed on both modes with 0 rejected programs, 0 harness errors and 0 skips:

mode programs match mismatch hypothesis-only
wave32 native 25 23 1 1
wave64 emulate 25 22 3 0

The important pc-tail result is that the run no longer produces the 0xeeeeeeee push-constant garbage/harness failure shape on this 128-byte GPU: the translated programs are dispatched and read back normally. The four mismatches are cs_xl32_100023, cs_xl64_100014, cs_xl64_100026 and cs_xl64_100034, the same four cases Gefik23 reported on a 256-byte NVIDIA GPU without depending on the pc-tail flag, so they are pre-existing crosslane/mask-model failures outside this plumbing PR. cs_xl32_100021 is hypothesis-only.

No game files. AI-assisted (SWE-2.1 Max ran/recorded the AMD check).

On GPUs whose push constant block is 128 bytes (AMD iGPUs) every
rdna2spirv.py translation fails with "need 144 push constant bytes"
unless --pc-tail-ubo moves the tail to a UBO, and vk_compute_test then
needs LEONIDA_PC_TAIL_UBO=1 to bind the same layout -- the same pairing
lds_fuzz.py, valu_fuzz.py and image_fuzz.py already implement. This
adds the flag (also enabled by LEONIDA_PC_TAIL_UBO=1) and forwards it
to both the translator and the harness, including the --minimize path.

AI-assisted. Tested: tests/test_crosslane_fuzz.py (76 tests), and a
GPU spot-check on the AMD iGPU (Vulkan, validation on): 8 programs,
wave32 native + wave64 emulate, all match with no harness errors.

Co-Authored-By: Devin <noreply@cognition.ai>
@whoalin1
whoalin1 force-pushed the crosslane-pctail-ubo branch from c7b4b3f to 706ecea Compare November 25, 2026 20:59
@whoalin1

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto current main (db1a22d29) as 706eceaf0; no conflicts. The branch is unchanged: crosslane_fuzz --pc-tail-ubo for 128-byte push-constant GPUs. The AMD RDNA2 evidence posted earlier stands on the same diff. AI-assisted with Devin.

@whoalin1

Copy link
Copy Markdown
Contributor Author

Additional real-hardware pass on the rebased head 706eceaf0, AMD Radeon(TM) Graphics 128-byte iGPU (gfx1036), validation layers on (LEONIDA_VK_VALIDATION=1):

crosslane_fuzz --programs 24 --seed 7 --wave both --modes native,emulate --no-maskdata --pc-tail-ubo
  wave32 native:  programs 12, match 12, mismatch 0, hyp_only 0, rejected 0, harness_errors 0, skipped 0
  wave64 emulate: programs 12, match 12, mismatch 0, hyp_only 0, rejected 0, harness_errors 0, skipped 0

exit 0, zero validation errors — the pc-tail-ubo layout agrees end to end (translator flag → SPIR-V set-1 block → harness bind) on the 128-byte device. AI-assisted (Devin).

@whoalin1

Copy link
Copy Markdown
Contributor Author

One more coverage data point on 706eceaf0, same AMD 128-byte iGPU, validation on — wave64 native (--w64-native, the least-tested configuration; gfx1036 subgroup 32..64, default 64):

crosslane_fuzz --programs 32 --seed 42 --wave 64 --modes native --w64-native --no-maskdata --pc-tail-ubo
  wave64 native: programs 32, match 32, mismatch 0, hyp_only 0, rejected 0, harness_errors 0, skipped 0

exit 0 — the pc-tail-ubo layout holds in native wave64 as well. AI-assisted (Devin).

@aslan2142
aslan2142 merged commit ab2fb71 into ProjectLeonida:main Nov 25, 2026
2 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged, thanks! This is the one PR kept for crosslane_fuzz --pc-tail-ubo. #1501 and #1508 make the same change, and I'm closing them as duplicates.

  • Why this one: the coordinator compared all three diffs and picked it, and it has the most outside testing: an Apple M5, an RTX 4060 on Windows, and an RDNA2 iGPU with 128-byte push constants.
  • The rebase onto db1a22d29 (706eceaf0) changes only tools/crosslane_fuzz.py and its test, at the same size as the reviewed diff.
  • Checked on main 4eab4f6d3 + 706eceaf0: the semantic suite passes (491 files, 6,312 tests, 0 files failed); test_crosslane_fuzz pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

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.

5 participants