[PR #1938] vk_model_fuzz: judge pk16_diff, vint_diff and sdwa_diff on any Vulkan GPU against their reference model (VK-MODEL-ORACLE) #1944

Open
opened 2026-11-26 21:19:29 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1938
Author: @levi2m
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/vk-model-oracle


📝 Commits (1)

  • de04d88 vk_model_fuzz: judge pk16_diff, vint_diff and sdwa_diff on any Vulkan GPU against their reference model (VK-MODEL-ORACLE)

📊 Changes

3 files changed (+306 additions, -0 deletions)

View changed files

📝 docs/testing.md (+16 -0)
➕ tests/test_vk_model_fuzz.py (+169 -0)
➕ tools/vk_model_fuzz.py (+121 -0)

📄 Description

Claimed in the coordination issue as: VK-MODEL-ORACLE (claim, in #1608, the continuation of #14)
Depends on: none (does not edit pk16_diff.py, vint_diff.py, sdwa_diff.py or vk_fuzz_run.py, so it is independent of #1653, #1654, #1656 and #1519)
Fixes: none

What and why

pk16_diff.py, vint_diff.py and sdwa_diff.py can run their translated programs on a Vulkan GPU, but only as --oracle hw,vk: the expected words come from a native AMD GPU. Without one, the GPU half of these fuzzers is out of reach, so an NVIDIA or Intel card never gets judged against them.

tools/vk_model_fuzz.py runs the same programs (same generator, same seed) through the translator and vk_compute_test and judges the result against each fuzzer's reference model instead. That model is written from the ISA pseudocode and already decides the CPU-interpreter run. A mismatch means the GPU, the translator or the model disagrees; the docs say to re-read the program with the fuzzer itself first. A program the model declines is a skip. Exit codes follow the other tools: 0 match, 1 mismatch, 2 no vk_compute_test, 77 nothing judged.

Nothing existing is edited. The tool reuses vk_fuzz_run.judge and each fuzzer's generate, reference and verdict, plus the same uniform setting each fuzzer's own run_suite passes. docs/testing.md gets a short section next to the AMD hardware oracle one.

Tested

  • python -I tests/test_vk_model_fuzz.py: 10 tests OK. A stand-in judge replaces the GPU, so they need no Vulkan device or llvm-mc: the programs are the ones the fuzzer generates for the seed, the model words are what the GPU is judged against, sdwa is not assumed uniform, a declined program is a skip, and exit codes 0, 1, 2, 77 and the usage error.
  • On the GPU, native Windows 11, NVIDIA RTX 4050 Laptop (driver 621.01), vk_compute_test built with llvm-mingw, llvm-mc 21.1.8: pk16_diff 120 programs seed 11: 120 match, exit 0 (and 6,000 pk16_diff and 6,000 vint_diff programs over four seeds with the same harness: all match). With a folder that has no vk_compute_test: one ERROR: line, exit 2. vint_diff 120 programs seed 21: 120 match. sdwa_diff 120 programs seed 21: 116 match, 4 declined by the model (f16 NaN operands). First real use (an earlier script version of this same logic, before it was split into this tool), sdwa_diff seeds 12, 13 and 14 with 1,500 programs each: 1,457, 1,444 and 1,455 match, and 5 programs mismatch (4 of them v_cvt_f32_u32_sdwa with a sext() source; see the follow-up pull request for SHADER-SDWA-SEXT-SHIFTS). The CPU interpreter run of the same seeds has 0 mismatches, so those are the GPU differing from the SPIR-V's meaning.
  • python -m compileall -q tools tests, tests/test_text_write_line_endings.py, tests/test_docs_cli_flags.py, tests/test_docs_links.py, tests/test_ci_registration.py, tests/test_docs_design_rows.py: OK. scripts/check_no_game_data.py on the new files: clean. tests/test_tool_stdout_encoding.py fails on main for three other tools (compute_heap_layout_census.py, game_run_summary.py, stage_timeline.py) and passes for this one.
  • No game files.

GPUs tested: NVIDIA GeForce RTX 4050 Laptop GPU, driver 621.01, Windows 11 build 26200
AI-assisted: yes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1938 **Author:** [@levi2m](https://github.com/levi2m) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/vk-model-oracle` --- ### 📝 Commits (1) - [`de04d88`](https://github.com/ubiquitarianism/leonida/commit/de04d88b92643715b0257eee224bd8e35c912e58) vk_model_fuzz: judge pk16_diff, vint_diff and sdwa_diff on any Vulkan GPU against their reference model (VK-MODEL-ORACLE) ### 📊 Changes **3 files changed** (+306 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/testing.md` (+16 -0) ➕ `tests/test_vk_model_fuzz.py` (+169 -0) ➕ `tools/vk_model_fuzz.py` (+121 -0) </details> ### 📄 Description Claimed in the coordination issue as: VK-MODEL-ORACLE ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167721110), in #1608, the continuation of #14) Depends on: none (does not edit `pk16_diff.py`, `vint_diff.py`, `sdwa_diff.py` or `vk_fuzz_run.py`, so it is independent of #1653, #1654, #1656 and #1519) Fixes: none ### What and why `pk16_diff.py`, `vint_diff.py` and `sdwa_diff.py` can run their translated programs on a Vulkan GPU, but only as `--oracle hw,vk`: the expected words come from a native AMD GPU. Without one, the GPU half of these fuzzers is out of reach, so an NVIDIA or Intel card never gets judged against them. `tools/vk_model_fuzz.py` runs the same programs (same generator, same seed) through the translator and `vk_compute_test` and judges the result against each fuzzer's reference model instead. That model is written from the ISA pseudocode and already decides the CPU-interpreter run. A mismatch means the GPU, the translator or the model disagrees; the docs say to re-read the program with the fuzzer itself first. A program the model declines is a skip. Exit codes follow the other tools: 0 match, 1 mismatch, 2 no `vk_compute_test`, 77 nothing judged. Nothing existing is edited. The tool reuses `vk_fuzz_run.judge` and each fuzzer's `generate`, `reference` and verdict, plus the same `uniform` setting each fuzzer's own `run_suite` passes. `docs/testing.md` gets a short section next to the AMD hardware oracle one. ### Tested - `python -I tests/test_vk_model_fuzz.py`: 10 tests OK. A stand-in judge replaces the GPU, so they need no Vulkan device or `llvm-mc`: the programs are the ones the fuzzer generates for the seed, the model words are what the GPU is judged against, sdwa is not assumed uniform, a declined program is a skip, and exit codes 0, 1, 2, 77 and the usage error. - On the GPU, native Windows 11, NVIDIA RTX 4050 Laptop (driver 621.01), `vk_compute_test` built with llvm-mingw, `llvm-mc` 21.1.8: `pk16_diff` 120 programs seed 11: 120 match, exit 0 (and 6,000 `pk16_diff` and 6,000 `vint_diff` programs over four seeds with the same harness: all match). With a folder that has no `vk_compute_test`: one `ERROR:` line, exit 2. `vint_diff` 120 programs seed 21: 120 match. `sdwa_diff` 120 programs seed 21: 116 match, 4 declined by the model (f16 NaN operands). First real use (an earlier script version of this same logic, before it was split into this tool), `sdwa_diff` seeds 12, 13 and 14 with 1,500 programs each: 1,457, 1,444 and 1,455 match, and 5 programs mismatch (4 of them `v_cvt_f32_u32_sdwa` with a `sext()` source; see the follow-up pull request for SHADER-SDWA-SEXT-SHIFTS). The CPU interpreter run of the same seeds has 0 mismatches, so those are the GPU differing from the SPIR-V's meaning. - `python -m compileall -q tools tests`, `tests/test_text_write_line_endings.py`, `tests/test_docs_cli_flags.py`, `tests/test_docs_links.py`, `tests/test_ci_registration.py`, `tests/test_docs_design_rows.py`: OK. `scripts/check_no_game_data.py` on the new files: clean. `tests/test_tool_stdout_encoding.py` fails on `main` for three other tools (`compute_heap_layout_census.py`, `game_run_summary.py`, `stage_timeline.py`) and passes for this one. - No game files. GPUs tested: NVIDIA GeForce RTX 4050 Laptop GPU, driver 621.01, Windows 11 build 26200 AI-assisted: yes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1944
No description provided.