Commit Graph

33 Commits

Author SHA1 Message Date
6f1298b00d crosslane_fuzz: reject dumps from failed GPU processes (OLD-10052)
Reject dumps written by crashed/failed GPU runs and update test harnesses for pc_tail keyword parameter.

AI-assisted (Claude Code, Claude Opus 5.5).
2026-11-26 00:56:19 +03:00
706eceaf02 crosslane_fuzz: --pc-tail-ubo for 128-byte push constant GPUs
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>
2026-11-25 22:59:07 +02:00
e0f40f47a0 docs: point crosslane_fuzz at its --help usage line (#6537)
Squash-merged after diff review of PR #6537
2026-11-23 12:50:22 -06:00
0721490907 Merge pull request #4637 from tupacfan04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:16:42 -05:00
e431512e5b Merge pull request #3943 from Felix Croasdale
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:46 -05:00
9e5cd1f89c crosslane_fuzz: accept --wave 32 / --wave 64 with the default --modes
The guards from 8a6820e5 refused a run when any selected mode had nothing
to run. They should refuse it only when none of them has anything to run. With
the default --modes (native,emulate), `--wave 32` stopped with "--modes emulate
needs wave64 programs" although native runs every wave32 program. `--wave 64`
stopped with "--wave 64 --modes native runs nothing" although emulate runs
every wave64 one. `--dpp-sweep --wave 32|64` failed the same way.

`--wave 32 --modes emulate` and `--wave 64 --modes native` (without
--w64-native) are still usage errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:35:18 -06:00
e47c9bb69a crosslane_fuzz: say which relative --exe forms CreateProcess doesn't take from the working directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:36:24 -06:00
170a0e5dea crosslane_fuzz: run the harness by its absolute path (relative --exe with "/" on Windows)
`--exe runtime/build/RelWithDebInfo/vk_compute_test.exe` passed the
tool's os.path.isfile check, but Windows' CreateProcess searches for a
relative path with "/" that doesn't start with ./ or ../ instead of
taking it from the working directory, so the first GPU run ended in
"FileNotFoundError: [WinError 2]" with a traceback. main() now makes
args.exe absolute after the configuration-folder lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:36:08 -06:00
bf73f8ea27 crosslane_fuzz: --ext adds wave64 carries, DS permutes, mask SALU with 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.
2026-11-22 22:26:44 +01:00
4e477e98ab Merge pull request #1959 from SHAFAY04
# Conflicts:
#	docs/design.md
2026-11-22 10:39:49 -05:00
321529bf91 BUILD-162: DPP16/DPP8 sweep, measured on RDNA2 (RX 6700 XT, gfx1031)
crosslane_fuzz.py --dpp-sweep runs one program per DPP case instead of random
ones: every DPP16 control (335) x bound_ctrl x fi x 3 EXEC patterns, all 256
row_mask/bank_mask pairs, and 19 DPP8 select sets x fi (7,206 per wave size).
Ops rotate through mov/not/add/xor, half of them in place. Failures print
the case label, and a per-family table follows the summary.

Gen.op_dpp now builds through dpp_op() with the same random draws, so
existing --dpp seeds give the same programs (pinned by a test).

On an RX 6700 XT (gfx1031, Windows HIP oracle): --dpp-sweep --oracle hw
--wave both gives 14,412/14,412 matching, and random --dpp seeds 1-8 give
8,000/8,000. Docs updated (shader_validation.md FUZZ-7, design.md DPP row).

AI-assisted (Claude Code).
2026-11-22 20:04:37 +05:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
8407a908dc Merge pull request #1588 from bobcatchris 2026-11-22 07:38:24 -05:00
8a6820e5dc crosslane_fuzz: refuse wave/mode combinations that run nothing
`--wave 32 --modes emulate` and `--wave 64 --modes native` (without
`--w64-native`) each select no program that mode could run, so nothing ran,
`summary:` printed with no line under it, and the exit code was 0. That is the
same false pass #1452 fixed for a count below 1, reached through a flag
combination, so both become usage errors before anything is generated or the
harness is looked for.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 06:32:33 -06:00
cbb770ff65 Merge pull request #1447 from Claude 2026-11-22 07:07:47 -05:00
8cb875ee30 Merge pull request #1452 from bobcatchris 2026-11-22 06:38:07 -05:00
449cb7b460 fuzzers: skip wave32 runs vk_compute_test could not pin to 32 lanes
valu_fuzz.py, lds_fuzz.py and crosslane_fuzz.py ask vk_compute_test for
32-lane subgroups (VKC_SUBGROUP_SIZE=32) for wave32 programs, but they
ignored its "compute subgroup size: 32 not available" line. On a device
that can't pin that size (Mesa llvmpipe: 8 lanes) every wave32 program
was judged at the driver's size and its cross-lane results came out as
translator mismatches. On main f85582e with llvmpipe, lds_fuzz --emulate
--programs 400 --seed 5150 gave 215 mismatches, all wave32, and
crosslane_fuzz --wave 32 --no-maskdata gave 68 of 100.

Those wave32 programs are now skips, as check.py's unpinned_subgroup_skip
does for its lane-mask dumps. Programs translated with --wave64-emulate
use no subgroup operations, so they are still compared at any size
(400 of 400 match on llvmpipe). crosslane_fuzz counts the skips in its
summary and exits 2 when every program was skipped, as the other two
fuzzers already do.

The line is parsed by compute_fixture.unpinned_subgroup, shared by the
three fuzzers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:33:45 +00:00
a0b14cb1a5 crosslane_fuzz: refuse a program or op count below 1
--programs 0, or any negative count, generated no program and still printed a
bare "summary:" with no lines and exit 0, which reads as a pass from a fuzzer
whose whole job is to fail loudly; --ops 0 built a program with no ops instead
of refusing. valu_fuzz, lds_fuzz, salu_diff, f32_fuzz and mem_diff already
refuse below 1, so this was the last fuzzer without the guard.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 05:31:50 -06:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
c067ae32dc crosslane_fuzz: a missing vk_compute_test is one line before anything runs
With the translator oracle and no vk_compute_test at --exe (nor in its
RelWithDebInfo/Release folder), the fuzzer generated and translated its
programs and then ended in a bare FileNotFoundError traceback from the first
GPU run. It now stops right after parsing its arguments with one line naming
the path and how to build it, exit 1, as lds_fuzz.py does. --oracle hw alone
and --self-test don't need it.

The HarnessErrors tests and test_mc_command's missing-llvm-mc case run main()
with the GPU replaced; they now pass an --exe that exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:44:56 +00:00
18670d9aea Merge pull request #1249 from Felix Croasdale 2026-11-22 04:37:52 -05:00
aa41f3d500 mc_command: name --llvm-mc only for the tool that has it; one import in crosslane_fuzz
Review on #1249: the message offered '(or --llvm-mc)' in every tool, but
only run_gpu_tests.py has that option. run()/not_found() take the tool's
option name, and run_gpu_tests.py passes it. crosslane_fuzz.py imports
mc_command once at module level instead of in two functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:15:13 -06:00
40bd14777a Merge pull request #1249 from Felix Croasdale 2026-11-22 04:07:53 -05:00
e63bf6bdef mc_command.run: a missing llvm-mc is one line, not a FileNotFoundError traceback
Without llvm-mc, run_gpu_tests.py, valu_fuzz.py, lds_fuzz.py,
image_fuzz.py, crosslane_fuzz.py and runtime/test/shaders/build.py
ended in 'FileNotFoundError: [WinError 2]' from subprocess.run: the first
step of TEST-71 on a Windows machine without one. Only shader_disasm.py
said what was missing. mc_command.run() starts an llvm-mc command and
turns a command that can't be started into shader_disasm.py's message
(set LLVM_MC or --llvm-mc, build_llvm_mc.ps1, the WSL form); the six
llvm-mc call sites use it. tests/test_mc_command.py covers run() and
each tool with a nonexistent LLVM_MC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:02:20 -06:00
d296e34661 crosslane_fuzz: a program the GPU harness hangs or crashes on no longer ends the run
vk_compute_test timing out on one program raised subprocess.TimeoutExpired out
of main(): the run stopped with a traceback and every result before it was
lost, as was the name of the program in the summary. A missing dump did the
same through RuntimeError. Both are now a HarnessError for that program: it is
listed with the other failures (and kept with --keep), counted as
harness_errors in the summary, and the run goes on. The exit code is 2 when
harness errors are the only failures, as in valu_fuzz.py and lds_fuzz.py; 1
still means a mismatch or an untranslated program.

Seen on an RX 7900 XTX (AMD 26.10.1): --seed 7900 --dpp, wave32 native,
cs_xl32_790023712 timed out after 60 s.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcPmkK8w6mToPwmoiLYPZt
2026-11-22 10:01:00 +01:00
5636ae8313 hw oracle: hypothesis mismatches are mismatches, wave-size probe, --keep writes the kernel that ran
- run_hw: a failing hypothesis op counts as a mismatch (exit 1) and in hyp_only;
  --minimize marks the hypothesis ops that remain
- Oracle startup probe: a wave64 kernel must see lane 32 as 32, a wave32 kernel
  as lane 0 of the second wave
- test_on_hardware also asserts rejected == 0, no mismatches, no hyp_only
- --keep / --minimize write hw_lines() for hardware failures
- docs: where the permlane FI=0 (#374, #580) and DPP8 (#238) hypotheses come from,
  and the re-run table (24,000 programs, hyp_only 0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:13:05 +01:00
45c7911148 crosslane_fuzz: optional hardware oracle (--oracle hw, translator,hw)
Runs each FUZZ-7 program natively on the AMD GPU in wave32 and native
wave64, with its real group size and EXEC setup, every thread storing its
14 words, and compares them with the model. hw_oracle gains raw kernels
(own stores), per-kernel workgroup size and wave64 code objects; the
launcher takes name:threads:words tokens.

24,000 programs on gfx1150: 0 mismatches; the permlane FI=0 and DPP8
inactive-source hypotheses hold on the hardware too. Translator mismatches
all trace to masks read as data (#293) and permlane (#580).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:05:34 +01:00
a6e3198607 Fuzzers: find vk_compute_test in a Visual Studio build
valu_fuzz.py and lds_fuzz.py ran <build>/vk_compute_test, so with the Visual
Studio generator (runtime/build/RelWithDebInfo) every program stopped with a
FileNotFoundError traceback. They now look in <build> and then its
RelWithDebInfo/Release folder, as run_gpu_tests.py does, and stop with one line
when it isn't built. crosslane_fuzz.py's default --exe gets the same fallback.
2026-11-22 09:37:03 +05:30
fd22f01ca2 Merge pull request #750 from kotorvr
# Conflicts:
#	docs/design.md
2026-11-21 21:37:59 -05:00
d0f0a510f3 rtti_scan: keep the old report when a write fails; mark mad denormals as not modelled
Follow-ups to review points on three merged PRs.

#658 (@VictorJulianiR): rtti_scan.py opened the report in place, so a write
that failed after the open (full disk, locked range) left a 0-byte file and
the previous report was gone. The report is now written to a temp file next to
it and swapped in with os.replace; on failure the temp file is removed.

#627 (@Caasares): three subnormal cases pinned the translator's result as if
it were RDNA2's. v_mad_f32, v_mac_f32 and v_mad_legacy_f32 flush f32
denormals on RDNA2 (LLVM SIISelLowering.cpp, isFMADLegal). They move to
DenormalDivergenceTests, which pins the translator result and records the RDNA2
one; docs/design.md lists the flush as not modelled. No translator change.

#645 (@esteban-dcp): crosslane_fuzz.py still called permlane FI=0
unmeasured; comments now point at the measurement and at #580.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:30:20 +00:00
8cd37b2b21 crosslane_fuzz.py: ask for 32-wide subgroups for wave32 and emulated programs (FUZZ-13)
run_gpu never set VKC_SUBGROUP_SIZE, unlike lds_fuzz.py and valu_fuzz.py.
On AMD (compute default 64) a wave32 program with a group over 32 lanes
ran as one 64-wide subgroup and mismatched in wave 1: 23 of 50 programs,
reported by @Pierre-Kookis, with VKC_SUBGROUP_SIZE=32 bringing that to 0
of 100.

The environment is now built by gpu_env(), which sets
VKC_SUBGROUP_SIZE=32 for wave32 programs and for wave64 ones translated
with --wave64-emulate; native wave64 keeps the device default, as
--w64-native intends. Both callers pass the mode. Four unit tests cover
it.
2026-11-22 02:09:02 +00:00
082e150f41 crosslane_fuzz: accept --modes both, reject unknown modes
The run loop only knows native and emulate. --modes both (offered by the
help) or a typo like emulat ran every program natively, wave64 included
without --w64-native, and reported false mismatches.
2026-11-22 02:22:53 +01:00
0f25c63200 Tools: wave and cross-lane differential fuzzer on the GPU (FUZZ-7)
tools/crosslane_fuzz.py generates seeded wave32/wave64 compute programs
from readlane/writelane/readfirstlane, v_cmp/v_cmpx ballots, s_bcnt/s_ff1
of masks, v_mbcnt, v_cndmask, permlane16/x16, forward s_cbranch_execz/
vccz/vccnz and (--dpp) DPP16/DPP8, under random EXEC, nested saveexec,
partial waves and multi-wave groups. A 64-lane model of the ISA is
compared with the translated SPIR-V run by vk_compute_test (VKC_OUT_WORDS
/ VKC_DUMP), wave32 natively and wave64 with --wave64-emulate.

Found SHADER-52 (#407) and two DPP bugs in #238. tests/test_crosslane_fuzz.py
checks the model without a GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:14:53 +00:00