Skip to content

pk16_diff, vint_diff, sdwa_diff, wint_diff: --oracle hw,vk runs the translated programs on a Vulkan GPU - #6306

Merged
shayderrr merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:claude/fz-vk-more
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:claude/fz-vk-more

Conversation

@evilclanker9000

@evilclanker9000 evilclanker9000 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-VK-MORE, #5032 (comment)

Depends on: #5931 (this branch is stacked on it: the first commit is #5931's; tools/vk_fuzz_run.py is its shared runner)

What and why

pk16_diff, vint_diff, wint_diff and sdwa_diff judge the translator only in spirv_mini_interp. The same check in f32_fuzz --oracle hw,vk (#5351) and fmisc_diff (#5931) found real translator bugs and several driver problems the interpreter fuzzers cannot see, so this adds --oracle hw,vk (--wave 32|64, --build, --work, --vk-constants) to the four others through the same tools/vk_fuzz_run.py. wint_diff judges every lane of its per-lane programs in the wave size they were generated for; the others run identical lanes and judge lane 0. vk_fuzz_run.py gains the rewrite/per_lane/uniform options, s_mov_b32 vcc_lo, K as a 64-bit mov in wave64, and a judge() helper with an exact verdict; sdwa_diff adds a nan class (the reference declines an f16 NaN; the hardware kernels run with IEEE on).

Tested

Fresh seeds (pk16 201-203, vint 201-203, sdwa 211-213, wint 221-222), 400 to 500 programs each, AMD Radeon iGPU gfx1036 (driver 26.10.1) wave32 and wave64, NVIDIA RTX 5080 (616.92) wave32:

  • pk16_diff: Radeon 8 mismatches in wave32 (five v_med3_i16) and 8 in wave64 (seven v_med3_i16), the median of a constant operand coming out as a bound (fixed in the separate PR for cs_med3_i16; the rest are v_pk_* or v_min_i16), 0 on the RTX 5080.
  • vint_diff: 0 mismatches on all three.
  • sdwa_diff int: Radeon wave64 2 (v_not_b32_sdwa ... dst_unused:UNUSED_PAD gives 0xffffff00 for 0x0000ff00, also when the field extracts are written as shifts and a mask: a driver bug, posted as a finding), 0 elsewhere; f16: Radeon wave64 2 (v_cvt_f32_f16_sdwa dst_sel:WORD_1 of an f16 denormal), the rest nan.
  • wint_diff: Radeon 2 of 400 (one wave32 lane, one wave64 lane), RTX 5080 0 of 400.
  • Negative control: v_add3_u32 made to emit OpISub fails 79 of 80 programs on the Radeon.
  • New tests/test_vk_fuzz_run.py (program text, wave64 spelling, opaque seeds, judge, the --oracle vk guard of each of the four tools); the four tools' existing tests and test_fmisc_diff pass; test_docs_* and compileall OK. docs/shader_validation.md documents the mode and the table above.

AI-assisted: yes.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No translator rule here, so no docs/design.md row.

evilclanker9000 and others added 2 commits November 23, 2026 13:35
…PU, wave32 or wave64

fmisc_diff judged the translator in spirv_mini_interp only. --oracle hw,vk also runs
each program through llvm-mc, rdna2spirv.py and vk_compute_test as one wave of 32 or
64 identical lanes (tools/vk_fuzz_run.py, shared with other fuzzers) and judges lane
0's four words against the hardware's. The seeds are computed from the buffer fill at
run time: the AMD Windows driver folds an ordered compare of a literal NaN to true in
a wave32 pipeline. Seeds 11 to 13 (600 programs each): Radeon wave32 and wave64 and
RTX 5080 wave32 show only the denormal gap and omod turning -0 into +0 (ItsNotRexed#1281), no
mismatch.

AI-assisted.
…ranslated programs on a Vulkan GPU

The same check as fmisc_diff's (ItsNotRexed#5931) and f32_fuzz's (ItsNotRexed#5351), through the shared
tools/vk_fuzz_run.py: llvm-mc, rdna2spirv.py and vk_compute_test run each program as
one wave of 32 or 64 lanes and its words are judged against the hardware's from a
kernel in the same wave size. wint_diff judges every lane of its per-lane programs.
vk_fuzz_run.py gains rewrite/per_lane/uniform options, the s_mov_b32 vcc_lo data seed
as a 64-bit mov, and judge() with an exact verdict; sdwa_diff adds a nan class for
programs the reference declines for an f16 NaN.

Fresh seeds, 400 to 500 programs each: no mismatch on the RTX 5080 and none in
vint_diff anywhere. On the Radeon pk16_diff found v_med3_i16 with a constant operand
(fixed separately) and sdwa_diff / wint_diff a few wave64-only differences, listed in
docs/shader_validation.md.

AI-assisted.

@SirKingg SirKingg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes at 4ce6558 (stacked on #5931):

  1. tools/pk16_diff.py:591-596 and the corresponding exits in the other four fuzzers: --oracle hw,vk returns 0 when every Vulkan case is skipped, as long as a hardware/reference comparison passes. With a synthetic hardware oracle returning the reference and the Vulkan runner returning translator: not translated for every program, pk16 reports one hardware pass, one Vulkan skip, and exits 0. Unsupported subgroup sizes or a translator failure can therefore produce a successful run without any requested Vulkan comparison. Treat a run with no Vulkan verdict as non-success, and surface systemic execution failures.
  2. tools/sdwa_diff.py:649-654: any reference NaN skip classifies every differing output as nan, including a corrupted independent register. A synthetic program whose f16 operation encounters NaN but which separately observes the unchanged source returns nan when only that copied source word is corrupted (0x7e00 -> 0x7e01). This masks real translator or driver errors unrelated to the NaN operation; narrow the exemption to affected outputs or skip the case explicitly rather than presenting it as an explained difference.

Windows independent checks: RTX 4070 Ti, NVIDIA 610.88, MSVC 19.44. The six targeted Python test files passed (109 tests); synthetic negative controls detected corrupted final lanes for wave32 and wave64. MSVC-built vk_compute_test ran an independent synthetic wave32 Vulkan smoke test and returned all 128 expected words; the device reports subgroup range 32..32 and correctly rejects required wave64 with exit 77. These are not RDNA2-vs-Vulkan comparisons: the AMD hardware oracle and AMDGPU llvm-mc were unavailable, so the new end-to-end hw,vk path and real wave64 were not tested. No game files. Review assisted by AI; no approval or merge.

@nullmarsh

Copy link
Copy Markdown

Tested 4ce6558f (base 561b65a8) on an AMD Radeon RX 9060 XT (RDNA4, gfx1200), AMD Windows driver 26.11.2 (32.0.32029.2010), Windows 11 26200. vk_compute_test is from a 561b65a8 build; the PR changes no runtime code.

wint_diff --oracle hw,vk: 0 mismatches. Every lane was judged:

Seed Wave Programs Pass Mismatch Skipped
221 64 400 339 0 61
222 64 400 333 0 67
221 32 400 348 0 52
222 32 400 342 0 58

All the skips are the hardware side: assembler rejected: instruction not supported on this GPU (gfx1200), for v_cmp_f_i32, v_cmp_t_u32 and v_cmpx_t_u32, which GFX12 dropped. So on this card the 2-of-400 differing lanes from your gfx1036 run don't show up in 1,362 judged programs.

sdwa_diff --oracle hw,vk: exits 77 on every seed (211-213, int and f16, wave 32 and 64) with hardware oracle unavailable: gfx1200 has no SDWA (GFX9 and GFX10 only). That guard is right: RDNA3/4 have no SDWA encodings.

The v_not_b32_sdwa finding, checked directly. The hardware oracle can't run SDWA here, so I ran the program from the finding and four variants through this PR's vk_fuzz_run.run_programs. I compared the results with values worked out by hand from the SDWA rules: select the source bits, NOT them, keep the dst_sel bits, and UNUSED_PAD zeroes the rest. I ran wave64 and wave32, each with opaque=True and opaque=False:

Program (v_not_b32_sdwa v8, v3 ...) v3 Want Got (all four runs)
dst_sel:WORD_0 dst_unused:UNUSED_PAD src0_sel:BYTE_0 (the finding) 0xffff 0x0000ff00 0x0000ff00
same 0x12ab 0x0000ff54 0x0000ff54
WORD_0 / UNUSED_PAD / BYTE_1 0xffff 0x0000ff00 0x0000ff00
BYTE_0 / UNUSED_PAD / DWORD 0xffff 0x00000000 0x00000000
WORD_0 / UNUSED_PAD / WORD_0 0x00ff 0x0000ff00 0x0000ff00

So the wave64 miscompile you saw on the gfx1036 iGPU with 26.10.1 does not happen on RDNA4 with 26.11.2. From one card I can't tell whether the newer driver fixed it or the bug is specific to the RDNA2 compile path. A run of the same program on gfx1036 with 26.11.2 would separate the two before it goes to AMD.

Not run: pk16_diff and vint_diff, and the v_cvt_f32_f16_sdwa denormal case, which needs your exact program. The repro script and logs are local; I can paste the script if it helps.

Synthetic programs only, no game files. AI-assisted (Claude Code).

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds a shared Vulkan-GPU oracle path to four differential fuzzers. New tools/vk_fuzz_run.py (197 lines: program_text, wave64_text, judge, exact_verdict) wraps llvm-mc → rdna2spirv.py → vk_compute_test. pk16_diff.py, vint_diff.py, wint_diff.py, fmisc_diff.py extend hw_kernel(..., wave), run_suite(..., wave, build, work, vk_constants) and add VK verdicts; sdwa_diff.py adds vk_verdict() with an f16 nan class. tests/test_vk_fuzz_run.py is new; docs/shader_validation.md documents the mode.

Why merge

Judges translated programs against real hardware words on Radeon and RTX, exposing translator/driver bugs the mini-interpreter cannot see, with wave32/64 control and fresh-seed measurements.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

Adds a shared Vulkan-GPU oracle path to four differential fuzzers. New tools/vk_fuzz_run.py (197 lines: program_text, wave64_text, judge, exact_verdict) wraps llvm-mc → rdna2spirv.py → vk_compute_test. pk16_diff.py, vint_diff.py, wint_diff.py, fmisc_diff.py extend hw_kernel(..., wave), run_suite(..., wave, build, work, vk_constants) and add VK verdicts; sdwa_diff.py adds vk_verdict() with an f16 nan class. tests/test_vk_fuzz_run.py is new; docs/shader_validation.md documents the mode.

Why merge

Judges translated programs against real hardware words on Radeon and RTX, exposing translator/driver bugs the mini-interpreter cannot see, with wave32/64 control and fresh-seed measurements.

Verdict: Approve

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.

4 participants