vk_model_fuzz: judge pk16_diff, vint_diff and sdwa_diff on any Vulkan GPU against their reference model (VK-MODEL-ORACLE) #1938
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1938"
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?
Imported from ubiquitarianism/leonida. Originally posted by levi2m on 2026-11-25T16:15:29Z.
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.pyorvk_fuzz_run.py, so it is independent of #1653, #1654, #1656 and #1519)Fixes: none
What and why
pk16_diff.py,vint_diff.pyandsdwa_diff.pycan 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.pyruns the same programs (same generator, same seed) through the translator andvk_compute_testand 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 novk_compute_test, 77 nothing judged.Nothing existing is edited. The tool reuses
vk_fuzz_run.judgeand each fuzzer'sgenerate,referenceand verdict, plus the sameuniformsetting each fuzzer's ownrun_suitepasses.docs/testing.mdgets 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 orllvm-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.vk_compute_testbuilt with llvm-mingw,llvm-mc21.1.8:pk16_diff120 programs seed 11: 120 match, exit 0 (and 6,000pk16_diffand 6,000vint_diffprograms over four seeds with the same harness: all match). With a folder that has novk_compute_test: oneERROR:line, exit 2.vint_diff120 programs seed 21: 120 match.sdwa_diff120 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_diffseeds 12, 13 and 14 with 1,500 programs each: 1,457, 1,444 and 1,455 match, and 5 programs mismatch (4 of themv_cvt_f32_u32_sdwawith asext()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.pyon the new files: clean.tests/test_tool_stdout_encoding.pyfails onmainfor three other tools (compute_heap_layout_census.py,game_run_summary.py,stage_timeline.py) and passes for this one.GPUs tested: NVIDIA GeForce RTX 4050 Laptop GPU, driver 621.01, Windows 11 build 26200
AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by Mby159 on 2026-11-25T18:41:10Z.
Independent verification on a second vendor's GPU (AMD Radeon 780M), with the reference model as the oracle.
Machine. AMD Radeon 780M Graphics (RDNA3 iGPU, gfx1103), AMD proprietary 26.10.2 (32.0.32015.12012, LLPC), Vulkan 1.4.359, subgroup 32..64, Windows 11 10.0.29712. Python 3.13.17, LLVM 23.1.6 (conda-forge llvm-tools, AMDGPU target), CMake 4.5.1 + Ninja, llvm-mingw clang++ 23.1.6.
vk_compute_testbuilt from this pull request's tree (baseb0f3d3998) with-DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF. The programs are assembled forgfx1013as the tool does; the device that runs them is RDNA3.Your reviewer check passes here:
python -I tests/test_vk_model_fuzz.py-> 10 tests OK.The 120-program numbers match what the pull request reports for the RTX 4050 Laptop.
pk16_diffvint_diffsdwa_diffAt 1,500 programs, for the two seeds below, the model and the GPU agree on every program the model judges.
sdwa_diffsdwa_diffThe two runs see the same programs: the model declines exactly the same ones (the f16 NaN operand, and for seed 12 the f16 NaN result whose payload is not modelled), so the skip breakdown is identical.
sdwa_diff.py's own defaults are--max-ops 4and the family op set, while this tool uses--max-ops 6and the fuzzer's wholeOPStable, so the CPU runs above were given--max-ops 6 --ops <all 92 opcodes>to land on the same program set.The
exit 2path behaves as documented:--buildpointing at a folder withoutvk_compute_testprints oneERROR:line and exits 2.One scope note. I ran wave 32 only (the tool's default), did not run the 6,000-program sweeps, did not run
--wave 64, and a 1,500-program seed-14 run had not finished when I posted this.Separately: the SDWA case #1939 describes, found with this tool on an NVIDIA driver, does not reproduce on this driver - the details are in #1939.
Imported from ubiquitarianism/leonida. Originally posted by levi2m on 2026-11-26T14:37:23Z.
Thanks @Mby159 for running this on the 780M. It is good to see the tool agree on a second vendor's GPU, and your point that the 1,500-program CPU runs need
--max-ops 6and the full op list to land on the same programs is a useful one.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T08:04:14Z.
Merged into
main(merge commiteb3a0d1f8), approved by DadaCap (maintainer). Thanks!Checked before merging: Tested in our local release candidate (main + 41 PRs): translator suite 512 files / 6,442 tests clean, Python suite with no new failure versus main, and 360 s game runs on an RTX 5080 with no regression. The merge was pinned to the head commit that was tested (
de04d88b9).AI-assisted (Claude Code), posted for DadaCap.