vk_fuzz_run: read a wave32 one-word dump from vk_compute_test's larger buffer #388

Manually merged
github merged 3 commits from gh-pr/388/head into gh-pr/388/base 2026-11-26 08:57:09 +00:00
Owner

@⁠Sangonapou on GitHub · 2026-11-24 04:23 UTC · original
Sangonapou:fix-vk-fuzz-run-short-request → main · +45 −4 · 2 files · 3 commits · merged 2026-11-24 16:24 UTC

Claimed in the coordination issue as: claim in #14. This carries on my PR 7756 from the original repository, which was not among the 251 old-pr/* branches; same commit, rebased on main ece4ba5b.

What and why

tools/vk_fuzz_run.run_programs accepted a VKC_DUMP only when it was exactly 4 * words * wave bytes. vk_compute_test's output buffer is at least one 64-thread group of words (VKC_OUT_WORDS only raises it), and VKC_DUMP writes the whole buffer. So a request under 64 words (wave32 with words=1: 128 bytes asked, 256 written) failed the check, and every program came back as vk_compute_test exit 0 even though it had run and stored the right words. The docstring allows words 1, 2, 4 and 8; 2, 4 and 8 were never affected, and no current caller passes 1.

  • read_dump(path, words, wave) returns the first words * wave words of a dump at least that long, or None when it is missing or short.
  • A missing or short dump now reports vk_compute_test: no dump of N bytes or more instead of vk_compute_test exit 0.

Tested

NVIDIA GeForce RTX 3080 Ti Laptop (subgroup 32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300); runtime built from this branch with scripts\build_runtime.ps1 (MSVC 19.51); llvm-mc 23.1.6 (conda-forge).

Two real programs (v_add_nc_u32 of 5 and 3; v_not_b32 of 0x12345678) through run_programs at wave32:

words main ece4ba5b this branch
1 vk_compute_test exit 0 (both) [8], [0xedcba987]
2, 4, 8 correct identical to main
  • tests/test_vk_fuzz_run.py: 15 OK (new test_read_dump_takes_the_first_wave_of_a_larger_buffer: a 64-word dump for wave32 words=1, an exact-size dump, a short and a missing one).
  • tests/test_fmisc_diff.py (a vk_fuzz_run caller): 34 OK.
  • python -m compileall, scripts/check_no_game_data.py on both files: clean.

On the original repo, PR 7756 had four independent checks (two CPU-side parser sweeps over all eight shapes, a mocked run_programs probe and a revert check), all passing.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

🤖 Generated with Claude Code

**@⁠Sangonapou** on GitHub · 2026-11-24 04:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388) `Sangonapou:fix-vk-fuzz-run-short-request` → `main` · +45 −4 · 2 files · 3 commits · merged 2026-11-24 16:24 UTC Claimed in the coordination issue as: [claim in #14](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). This carries on my PR 7756 from the original repository, which was not among the 251 `old-pr/*` branches; same commit, rebased on `main` `ece4ba5b`. ### What and why `tools/vk_fuzz_run.run_programs` accepted a `VKC_DUMP` only when it was exactly `4 * words * wave` bytes. `vk_compute_test`'s output buffer is at least one 64-thread group of words (`VKC_OUT_WORDS` only *raises* it), and `VKC_DUMP` writes the whole buffer. So a request under 64 words (wave32 with `words=1`: 128 bytes asked, 256 written) failed the check, and every program came back as `vk_compute_test exit 0` even though it had run and stored the right words. The docstring allows `words` 1, 2, 4 and 8; 2, 4 and 8 were never affected, and no current caller passes 1. - `read_dump(path, words, wave)` returns the first `words * wave` words of a dump at least that long, or `None` when it is missing or short. - A missing or short dump now reports `vk_compute_test: no dump of N bytes or more` instead of `vk_compute_test exit 0`. ### Tested NVIDIA GeForce RTX 3080 Ti Laptop (subgroup 32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300); runtime built from this branch with `scripts\build_runtime.ps1` (MSVC 19.51); `llvm-mc` 23.1.6 (conda-forge). Two real programs (`v_add_nc_u32` of 5 and 3; `v_not_b32` of `0x12345678`) through `run_programs` at wave32: | `words` | `main` `ece4ba5b` | this branch | |---|---|---| | 1 | `vk_compute_test exit 0` (both) | `[8]`, `[0xedcba987]` | | 2, 4, 8 | correct | identical to `main` | - `tests/test_vk_fuzz_run.py`: 15 OK (new `test_read_dump_takes_the_first_wave_of_a_larger_buffer`: a 64-word dump for wave32 `words=1`, an exact-size dump, a short and a missing one). - `tests/test_fmisc_diff.py` (a `vk_fuzz_run` caller): 34 OK. - `python -m compileall`, `scripts/check_no_game_data.py` on both files: clean. On the original repo, PR 7756 had four independent checks (two CPU-side parser sweeps over all eight shapes, a mocked `run_programs` probe and a revert check), all passing. AI-assisted: yes (Claude Code) ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
run_programs required a VKC_DUMP of exactly 4 * words * wave bytes. vk_compute_test's
output buffer is at least one 64-thread group of words (VKC_OUT_WORDS only raises it),
and VKC_DUMP writes the whole buffer, so wave32 with words=1 (128 bytes asked) got a
256-byte file and every program came back as "vk_compute_test exit 0". words=2, 4
and 8 were not affected.

read_dump() now takes the first words * wave words of a dump at least that long, and a
missing or short dump says so instead of reporting exit 0. Unit test in
tests/test_vk_fuzz_run.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The larger-buffer case filled the tail with R.FILL, the value the harness itself writes past the
program's stores, and every lane with the same word. Each lane now stores its own value and the tail
holds 0xDEADBEEF, so the test fails if read_dump took the tail, the wrong words or the wrong order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dump is longer than the request in the other direction too: wave64 with words=1 asks for 64 words,
and a two-group buffer holds 128. Only the first 64 are the wave's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:57:09 +00:00
github manually merged commit 8dcc396423 into gh-pr/388/base 2026-11-26 08:57:09 +00:00
Author
Owner

@⁠Oliwettoo on GitHub · 2026-11-24 10:34 UTC · original

Looks good. read_dump accepts a dump at least 4 * words * wave bytes long and reads only that prefix, which matches vk_compute_test writing its whole (≥ 64-word) buffer; a non-zero exit is still reported before the dump is read. tests/test_vk_fuzz_run.py passes with the PR on current main. Ship. AI-assisted review.

**@⁠Oliwettoo** on GitHub · 2026-11-24 10:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7128959952) Looks good. `read_dump` accepts a dump at least `4 * words * wave` bytes long and reads only that prefix, which matches vk_compute_test writing its whole (≥ 64-word) buffer; a non-zero exit is still reported before the dump is read. `tests/test_vk_fuzz_run.py` passes with the PR on current `main`. Ship. AI-assisted review.
Author
Owner

@⁠EvgHaze on GitHub · 2026-11-24 13:29 UTC · original

Read-only review (I could not build this head: the clone timed out from this machine, so nothing below is a test result).

The fix looks right, and it is worth landing specifically because of 32-wide devices:

  • vk_compute_test's buffer is at least 64 words, so wave=32, words=1 asks for 128 bytes and gets 256. The old getsize(dump) != 4 * words * wave therefore rejected a perfectly good run. On a 64-wide AMD host the natural wave=64, words=1 case needs 256 bytes and matches exactly, which is presumably how this stayed invisible: the broken shape is the 32-wide default, i.e. Apple (MoltenVK reports 4..32 and defaults to 32; KosmicKrisp is 32..32) and every NVIDIA/Intel fixture run.
  • read_dump reading exactly need bytes and slicing into wave lanes of words matches the layout the old code assumed, and the returncode check moved ahead of it, so a crashed run is still reported as an exit code rather than "no dump". The three new cases (larger buffer, exact size, short/missing) cover the branches.

One suggestion on the test, not the code: the tail in test_read_dump_takes_the_first_wave_of_a_larger_buffer is filled with R.FILL, which is also what the harness writes past the program's stores. So the test would still pass if read_dump accidentally read the whole buffer and sliced it — the values would be identical. A distinct sentinel in the tail (e.g. 0xdeadbeef instead of R.FILL) would make the test prove the tail is not read. Cheap to add while the fixture is being touched.

On the Apple side I can supply the hardware check once the tree is reachable: valu_fuzz --family f16 --programs 200 --seed 1 --wave both on an M3 with MoltenVK 1.4.2 and KosmicKrisp 26.3.1 is already set up here and runs the wave=32 path by default.

AI-assisted.

**@⁠EvgHaze** on GitHub · 2026-11-24 13:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7132905614) Read-only review (I could not build this head: the clone timed out from this machine, so nothing below is a test result). The fix looks right, and it is worth landing specifically because of 32-wide devices: - `vk_compute_test`'s buffer is at least 64 words, so `wave=32, words=1` asks for 128 bytes and gets 256. The old `getsize(dump) != 4 * words * wave` therefore rejected a perfectly good run. On a 64-wide AMD host the natural `wave=64, words=1` case needs 256 bytes and matches exactly, which is presumably how this stayed invisible: the broken shape is the **32-wide default**, i.e. Apple (MoltenVK reports 4..32 and defaults to 32; KosmicKrisp is 32..32) and every NVIDIA/Intel fixture run. - `read_dump` reading exactly `need` bytes and slicing into `wave` lanes of `words` matches the layout the old code assumed, and the `returncode` check moved ahead of it, so a crashed run is still reported as an exit code rather than "no dump". The three new cases (larger buffer, exact size, short/missing) cover the branches. One suggestion on the test, not the code: the tail in `test_read_dump_takes_the_first_wave_of_a_larger_buffer` is filled with `R.FILL`, which is also what the harness writes past the program's stores. So the test would still pass if `read_dump` accidentally read the whole buffer and sliced it — the values would be identical. A distinct sentinel in the tail (e.g. `0xdeadbeef` instead of `R.FILL`) would make the test prove the tail is not read. Cheap to add while the fixture is being touched. On the Apple side I can supply the hardware check once the tree is reachable: `valu_fuzz --family f16 --programs 200 --seed 1 --wave both` on an M3 with MoltenVK 1.4.2 and KosmicKrisp 26.3.1 is already set up here and runs the `wave=32` path by default. AI-assisted.
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 13:31 UTC · original

@⁠EvgHaze thanks, good catch. Done in 2bf664f2: the larger-buffer case now gives each lane its own value (0x100 + lane) and fills the tail with 0xDEADBEEF (asserted to differ from R.FILL), so the test fails if read_dump took the tail, the wrong words or the wrong order. I also checked it the other way round: a read_dump that turns the whole 64-word buffer into lanes now fails it. tests/test_vk_fuzz_run.py: 15 OK. Code unchanged. An Apple run of the wave=32 path would be very welcome.

**@⁠Sangonapou** on GitHub · 2026-11-24 13:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7132950832) @⁠EvgHaze thanks, good catch. Done in `2bf664f2`: the larger-buffer case now gives each lane its own value (`0x100 + lane`) and fills the tail with `0xDEADBEEF` (asserted to differ from `R.FILL`), so the test fails if `read_dump` took the tail, the wrong words or the wrong order. I also checked it the other way round: a `read_dump` that turns the whole 64-word buffer into lanes now fails it. `tests/test_vk_fuzz_run.py`: 15 OK. Code unchanged. An Apple run of the `wave=32` path would be very welcome.
Author
Owner

@⁠EvgHaze on GitHub · 2026-11-24 14:26 UTC · original

Checked 2bf664f2. I could not run the test file itself (it imports hw_oracle.runner, and the clone still will not complete from this machine), so I ran read_dump directly from tools/vk_fuzz_run.py at that commit against the same fixtures, plus one you do not have yet:

PASS  wave32 words=1, per-lane 0x100+lane, tail 0xDEADBEEF  -> [[0x100+lane]] * 32, sentinel absent
PASS  exact size, wave32 words=4                            -> unchanged (lanes[0]=[0..3], lanes[31]=[124..127])
PASS  short dump (31 words)                                 -> None
PASS  missing file                                          -> None
PASS  wave64 words=1 from a two-group dump (128 words)      -> lanes 0..63 read, tail not read
R.FILL = 0xeeeeeeee, so the sentinel assertion is meaningful.

The per-lane values are the right call: with a single repeated word the test could not tell a wrong order from a right one, and 0xDEADBEEF in the tail is exactly the case that would have caught a whole-buffer read.

The last row is the only thing I would consider adding: a wave=64, words=1 case over a two-group dump, because that is the shape a 64-wide AMD/NVIDIA host produces — the same bug in the other direction, where the buffer is now longer than the request rather than equal to it. Not a blocker.

AI-assisted.

**@⁠EvgHaze** on GitHub · 2026-11-24 14:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7134387242) Checked `2bf664f2`. I could not run the test file itself (it imports `hw_oracle.runner`, and the clone still will not complete from this machine), so I ran `read_dump` directly from `tools/vk_fuzz_run.py` at that commit against the same fixtures, plus one you do not have yet: ```text PASS wave32 words=1, per-lane 0x100+lane, tail 0xDEADBEEF -> [[0x100+lane]] * 32, sentinel absent PASS exact size, wave32 words=4 -> unchanged (lanes[0]=[0..3], lanes[31]=[124..127]) PASS short dump (31 words) -> None PASS missing file -> None PASS wave64 words=1 from a two-group dump (128 words) -> lanes 0..63 read, tail not read R.FILL = 0xeeeeeeee, so the sentinel assertion is meaningful. ``` The per-lane values are the right call: with a single repeated word the test could not tell a wrong order from a right one, and `0xDEADBEEF` in the tail is exactly the case that would have caught a whole-buffer read. The last row is the only thing I would consider adding: a `wave=64, words=1` case over a two-group dump, because that is the shape a 64-wide AMD/NVIDIA host produces — the same bug in the other direction, where the buffer is now *longer* than the request rather than equal to it. Not a blocker. AI-assisted.
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 14:35 UTC · original

@⁠EvgHaze thanks for running it. Added your last row in 8dcc3964: wave=64, words=1 from a two-group (128-word) dump, per-lane 0x200 + lane with the sentinel in the second group, expecting lanes 0..63 only. tests/test_vk_fuzz_run.py: 15 OK. Code unchanged.

**@⁠Sangonapou** on GitHub · 2026-11-24 14:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7134618813) @⁠EvgHaze thanks for running it. Added your last row in `8dcc3964`: `wave=64, words=1` from a two-group (128-word) dump, per-lane `0x200 + lane` with the sentinel in the second group, expecting lanes 0..63 only. `tests/test_vk_fuzz_run.py`: 15 OK. Code unchanged.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 16:24 UTC · original

Merging.

Why merged: vk_fuzz_run reads the first wave of vk_compute_test's larger (64-word or more) dump, so a wave32 run with words=1 no longer drops every result. Oliwettoo said "Ship". The current head adds EvgHaze's suggested case (wave64, words=1, from a two-group dump); tools/vk_fuzz_run.py is unchanged since that review.

Why it's good: tests/test_vk_fuzz_run.py: 15 passed.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main 1504c1af6 (a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main 98a977b4b: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

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

**@⁠QemmHD** on GitHub · 2026-11-24 16:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7137617077) Merging. **Why merged:** vk_fuzz_run reads the first wave of vk_compute_test's larger (64-word or more) dump, so a wave32 run with words=1 no longer drops every result. Oliwettoo said "Ship". The current head adds EvgHaze's suggested case (wave64, words=1, from a two-group dump); tools/vk_fuzz_run.py is unchanged since that review. **Why it's good:** tests/test_vk_fuzz_run.py: 15 passed. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Alone on main, its tests passed both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #388, #418, #421, #434, #470, #484, #485, #486 and #488 merged onto main 1504c1af6 (a225e593e). There the repo-consistency set gives 566 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 306/308. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same skip set. git merge-tree against current main 98a977b4b: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠EvgHaze on GitHub · 2026-11-25 12:23 UTC · original

Apple run of the wave=32 path, as asked.

Machine:  Apple M3, 10-core (MacBook Air 13", Mac15,13), macOS 27.0 (26A5406e), arm64
Driver:   MoltenVK 1.4.2 (Homebrew), ICD loaded directly; subgroup 4..32, default 32
Tree:     ubiquitarianism/leonida `0d80bc5`, `cmake -S runtime -B runtime/build -G Ninja`
          198 targets, 33 `vk_*` tools
Tools:    Homebrew llvm-mc 23.1.4 (AMDGPU), SPIRV-Tools 1.4.363.0, AppleClang 21.0.0, CMake 4.4.4, Python 3.13.7

Unit test file, on macOS: python3 -I tests/test_vk_fuzz_run.py → 15 tests, OK. Same count as the merge comment.

The exact shape that used to be dropped, end to end on the GPU — run_programs(words=1, wave=32), where the dump is 64 words and the request is 32:

per_lane=True  -> 32 lanes, [[0], [1], [2], ... [30], [31]]   (program stores the lane id from v20)
per_lane=False -> 'lanes [1, 2, 3] differ from lane 0 on identical inputs'

So all 32 lanes come back, in order, and the uniform check still rejects a program whose lanes differ — both halves of the read path behave on a 32-wide host.

What I could not run here: the differential fuzzers in their hardware-compare mode. vint_diff.py --oracle hw,vk (the mode that exercises this wrapper) exits with hardware oracle unavailable: the launcher targets the Windows AMD driver (amdhip64_7.dll), so there is no hw,vk run from a Mac. The Apple result above is the wrapper plus vk_compute_test on a 32-wide host, not a hardware comparison.

AI-assisted. No game data: one hand-written program, and the numbers above are its output.

**@⁠EvgHaze** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/388#issuecomment-7162308852) Apple run of the wave=32 path, as asked. ```text Machine: Apple M3, 10-core (MacBook Air 13", Mac15,13), macOS 27.0 (26A5406e), arm64 Driver: MoltenVK 1.4.2 (Homebrew), ICD loaded directly; subgroup 4..32, default 32 Tree: ubiquitarianism/leonida `0d80bc5`, `cmake -S runtime -B runtime/build -G Ninja` 198 targets, 33 `vk_*` tools Tools: Homebrew llvm-mc 23.1.4 (AMDGPU), SPIRV-Tools 1.4.363.0, AppleClang 21.0.0, CMake 4.4.4, Python 3.13.7 ``` **Unit test file, on macOS:** `python3 -I tests/test_vk_fuzz_run.py` → **15 tests, OK**. Same count as the merge comment. **The exact shape that used to be dropped**, end to end on the GPU — `run_programs(words=1, wave=32)`, where the dump is 64 words and the request is 32: ```text per_lane=True -> 32 lanes, [[0], [1], [2], ... [30], [31]] (program stores the lane id from v20) per_lane=False -> 'lanes [1, 2, 3] differ from lane 0 on identical inputs' ``` So all 32 lanes come back, in order, and the uniform check still rejects a program whose lanes differ — both halves of the read path behave on a 32-wide host. **What I could not run here:** the differential fuzzers in their hardware-compare mode. `vint_diff.py --oracle hw,vk` (the mode that exercises this wrapper) exits with `hardware oracle unavailable: the launcher targets the Windows AMD driver (amdhip64_7.dll)`, so there is no `hw,vk` run from a Mac. The Apple result above is the wrapper plus `vk_compute_test` on a 32-wide host, not a hardware comparison. AI-assisted. No game data: one hand-written program, and the numbers above are its output.
This discussion has been locked. Commenting is limited to contributors.
No description provided.