Shader tests: differential fuzzing against an RDNA2 interpreter ("oracle"), port of avatarmanz#403 #70

Closed
github-bot wants to merge 1 commit from github-bot/gh-70 into main AGit
Owner

@⁠simbaui4life on GitHub · 2026-11-27 16:14 UTC · original
test/rdna2-oracle → main · +1854 −0 · 2 files · 1 commits · closed without merging

A port of avatarmanz/VIctory-7900XTX#403: a differential fuzzer for the shader translator, as tests. One commit on d12eb1b. It does not change the translator.

Why: the translator's tests check chosen cases. This one checks whole random programs against a model of the RDNA2 ISA that shares no code with the translator, on the GPU the translation runs on. It covers EXEC-narrowed branches, SCC, VCC and cross-lane reads and writes. On this fork's RTX target, wave64 runs as two 32-lane host waves, which is where most of its findings are.

How it works (crates/victory-shader/src/emit/oracle_tests.rs, cfg(all(test, windows)))

  • Random compute programs: integer VALU and SALU, lane compares, lane-divergent if/else under EXEC, uniform ifs and loops on SCC, and v_readlane/v_writelane/v_readfirstlane.
  • They are encoded to GFX10 machine code. The encoder is checked against the decoder's instruction names, so a mismatch means the translation, not the encoding.
  • They are translated by the production path: spill::build, structure, resource::track, io::raise, then emit retried as translate does (FIRST_HALF).
  • They run on emit::host and are compared lane by lane with an interpreter that shares nothing with the translator. A program that differs is minimized and printed as a listing.

Running it

  • Default tests, no GPU needed: oracle_encoding_reads_back_as_the_instructions_meant and oracle_interpreter_follows_the_isa_on_known_cases.
  • The fuzzer is #[ignore]d:
    VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1
  • VICTORY_ORACLE_OUT=<file> writes the report.
  • VICTORY_ORACLE_AVOID=salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data leaves out the known classes.

Findings (the fixes are the two companion PRs from simbaui4life:fix/salu-minmax-scc-lane-masks and simbaui4life:fix/scalars-after-lane-branches)

  • s_min/s_max SCC.
  • v_readlane/v_writelane lane wrap.
  • Scalars written in lane branches.
  • Still open:
    • v_writelane to a lane EXEC leaves out.
    • wave64 VCC read as data after a uniform branch.
    • VCC bits of inactive lanes after a v_cmp under narrowed EXEC.
    • wave64 v_readfirstlane per 32-lane half.

Tested (RTX 4070 Ti, driver 621.01, Windows 11 26200)

  • Base d12eb1b: cargo test -p victory-shader 288 passed.
  • This branch: 290 passed (the two oracle tests added). cargo clippy -p victory-shader --all-targets -- -D warnings is clean.

Not tested: AMD hardware.

No game data in the commits.

🤖 Generated with Claude Code

**@⁠simbaui4life** on GitHub · 2026-11-27 16:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/70) `test/rdna2-oracle` → `main` · +1854 −0 · 2 files · 1 commits · closed without merging A port of avatarmanz/VIctory-7900XTX#403: a differential fuzzer for the shader translator, as tests. One commit on `d12eb1b`. It does not change the translator. **Why:** the translator's tests check chosen cases. This one checks whole random programs against a model of the RDNA2 ISA that shares no code with the translator, on the GPU the translation runs on. It covers EXEC-narrowed branches, SCC, VCC and cross-lane reads and writes. On this fork's RTX target, wave64 runs as two 32-lane host waves, which is where most of its findings are. **How it works** (`crates/victory-shader/src/emit/oracle_tests.rs`, `cfg(all(test, windows))`) - Random compute programs: integer VALU and SALU, lane compares, lane-divergent if/else under EXEC, uniform ifs and loops on SCC, and `v_readlane`/`v_writelane`/`v_readfirstlane`. - They are encoded to GFX10 machine code. The encoder is checked against the decoder's instruction names, so a mismatch means the translation, not the encoding. - They are translated by the production path: `spill::build`, `structure`, `resource::track`, `io::raise`, then `emit` retried as `translate` does (`FIRST_HALF`). - They run on `emit::host` and are compared lane by lane with an interpreter that shares nothing with the translator. A program that differs is minimized and printed as a listing. **Running it** - Default tests, no GPU needed: `oracle_encoding_reads_back_as_the_instructions_meant` and `oracle_interpreter_follows_the_isa_on_known_cases`. - The fuzzer is `#[ignore]`d: `VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1` - `VICTORY_ORACLE_OUT=<file>` writes the report. - `VICTORY_ORACLE_AVOID=salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data` leaves out the known classes. **Findings** (the fixes are the two companion PRs from `simbaui4life:fix/salu-minmax-scc-lane-masks` and `simbaui4life:fix/scalars-after-lane-branches`) - s_min/s_max SCC. - v_readlane/v_writelane lane wrap. - Scalars written in lane branches. - Still open: - `v_writelane` to a lane EXEC leaves out. - wave64 VCC read as data after a uniform branch. - VCC bits of inactive lanes after a `v_cmp` under narrowed EXEC. - wave64 `v_readfirstlane` per 32-lane half. **Tested** (RTX 4070 Ti, driver 621.01, Windows 11 26200) - Base `d12eb1b`: `cargo test -p victory-shader` 288 passed. - This branch: 290 passed (the two oracle tests added). `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean. **Not tested:** AMD hardware. No game data in the commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Random compute programs (integer VALU and SALU arithmetic, lane compares,
lane-divergent if/else under EXEC, uniform ifs and loops on SCC, cross-lane
reads and writes) are encoded to GFX10 machine code, translated by the
production path (spill::build, structure, resource::track, io::raise,
emit_with_retries), run on the host GPU and compared lane by lane with an
interpreter that shares nothing with the translator (not the decoder, the
IR or the lowering). The encoder is checked against the decoder's
instruction names, so a mismatch means the translation, not the encoding.
Failing programs are minimized and printed as a listing.

Wave64 runs on a host of 32-lane waves (TEST_HOST_WAVE), once with exact
translations only (VICTORY_WAVE_LOCAL=idiom) and once as the default.

Default tests: the encoder round trip and the interpreter on known cases
(no GPU needed). The fuzzer is #[ignore]d:
  cargo test -p victory-shader --lib oracle -- --ignored --nocapture --test-threads=1
with VICTORY_ORACLE_RUNS (200), VICTORY_ORACLE_SEED (1), VICTORY_ORACLE_OUT
(report file) and VICTORY_ORACLE_AVOID (leave out known bug classes).
Without an SM 6.6 hardware device it skips.

Ported from avatarmanz/VIctory-7900XTX#403.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:18:51 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-11-27 18:10 UTC · original

Ran the differential oracle fuzzer from PR #70 at 62eed99 on an NVIDIA Blackwell part. The PR body lists several oracle differences as still open, so this is a report of what this adapter produced, not a review of the change.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), 16 GB, driver 32.0.16.2124
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 19.44.35230, DXC 1.9.2609.5
  • Build: debug (test profile), VICTORY_REQUIRE_HW_GPU=1, VICTORY_DXIL from DXC 1.9.2609.5

Results

  • cargo test -p victory-shader --lib oracle -- --test-threads=4: 2 passed, 0 failed, 1 ignored (exit 0). The ignored test is oracle_fuzz.
  • VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 VICTORY_REQUIRE_HW_GPU=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1: FAILED, 0 passed, 1 failed, exit 101. The test panicked at oracle_tests.rs:1851 with "exact translations that differ from the oracle": left 171, right 0.
  • Same command with VICTORY_ORACLE_AVOID set to the five classes named in the PR body (salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data): FAILED, 0 passed, 1 failed, exit 101, same assertion left 23, right 0.

What this adds
The PR's Tested section lists the default suite on an RTX 4070 Ti (290 passed) but no run of the fuzzer itself. This adds a Blackwell wave32 host with the fuzzer enabled and VICTORY_REQUIRE_HW_GPU set, so a silent skip would have failed the run. Both fuzzer runs executed on the real D3D12 device and ended at the oracle comparison with a nonzero difference count; the second run still reported 23 differences after the documented AVOID classes. I did not investigate the cause of those differences.

Not tested
Other seeds or run counts, AMD hardware, Intel adapters, Wine, release profile, game data. The default suite at this head was not run here; the non-ignored filter covers emit::oracle only.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR head in a detached worktree, ran the commands above and wrote this report; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-27 18:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/70#issuecomment-7225202368) Ran the differential oracle fuzzer from PR #70 at 62eed99 on an NVIDIA Blackwell part. The PR body lists several oracle differences as still open, so this is a report of what this adapter produced, not a review of the change. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), 16 GB, driver 32.0.16.2124 - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 - Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 19.44.35230, DXC 1.9.2609.5 - Build: debug (test profile), VICTORY_REQUIRE_HW_GPU=1, VICTORY_DXIL from DXC 1.9.2609.5 **Results** - `cargo test -p victory-shader --lib oracle -- --test-threads=4`: 2 passed, 0 failed, 1 ignored (exit 0). The ignored test is oracle_fuzz. - `VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 VICTORY_REQUIRE_HW_GPU=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1`: FAILED, 0 passed, 1 failed, exit 101. The test panicked at oracle_tests.rs:1851 with "exact translations that differ from the oracle": left 171, right 0. - Same command with VICTORY_ORACLE_AVOID set to the five classes named in the PR body (salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data): FAILED, 0 passed, 1 failed, exit 101, same assertion left 23, right 0. **What this adds** The PR's Tested section lists the default suite on an RTX 4070 Ti (290 passed) but no run of the fuzzer itself. This adds a Blackwell wave32 host with the fuzzer enabled and VICTORY_REQUIRE_HW_GPU set, so a silent skip would have failed the run. Both fuzzer runs executed on the real D3D12 device and ended at the oracle comparison with a nonzero difference count; the second run still reported 23 differences after the documented AVOID classes. I did not investigate the cause of those differences. **Not tested** Other seeds or run counts, AMD hardware, Intel adapters, Wine, release profile, game data. The default suite at this head was not run here; the non-ignored filter covers emit::oracle only. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR head in a detached worktree, ran the commands above and wrote this report; no game data was used.
Author
Owner

@⁠simbaui4life on GitHub · 2026-11-27 19:57 UTC · original

Thanks for running it on Blackwell. I reproduced the same command here (RTX 4070 Ti, driver 621.01, Windows 11 26200, VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 VICTORY_REQUIRE_HW_GPU=1) and get the same totals: 171 without the filter and 23 with it. So these are not specific to your card.

The fuzzer is meant to fail while known classes are open: it asserts zero differences so that every remaining one is listed and minimized. With your filter, the 23 are these (wave64 programs count twice, once for the "default" and once for the "exact" form):

#70 (62eed99) #116 (d212aea) #116 with VICTORY_WAVE_WIDE=1
wave32 programs that differ 3 0 0
wave64 programs that differ 10 10 6
number in the assertion 23 20 12
  • The 3 wave32 programs are compares in lane-divergent branches: a v_cmp under narrowed EXEC must leave 0 in the VCC bits of the lanes it skips. #116 fixes them.
  • 4 of the wave64 programs are the same thing in wave64. #116 takes those branches wave-wide only with VICTORY_WAVE_WIDE=1, because a wave64 run as two 32-lane waves needs group barriers there. So they remain by default.
  • The other 6 wave64 programs each minimize to a single v_readfirstlane_b32. On a 32-lane host each half of a wave64 reads its own first lane, so lanes 32–63 get lane 32's value instead of lane 0's (e.g. s20: GPU 0x20, oracle 0x0). This is a known open class with no fix and no VICTORY_ORACLE_AVOID key yet.
  • Without the filter: 171 on #70 and 164 on #116. The rest belong to the classes that #71 and #73 fix and to the ones the PR body lists as open.

🤖 Reproduced and classified with Claude Code

**@⁠simbaui4life** on GitHub · 2026-11-27 19:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/70#issuecomment-7227031174) Thanks for running it on Blackwell. I reproduced the same command here (RTX 4070 Ti, driver 621.01, Windows 11 26200, `VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 VICTORY_REQUIRE_HW_GPU=1`) and get the same totals: 171 without the filter and 23 with it. So these are not specific to your card. The fuzzer is meant to fail while known classes are open: it asserts zero differences so that every remaining one is listed and minimized. With your filter, the 23 are these (wave64 programs count twice, once for the "default" and once for the "exact" form): | | #70 (62eed99) | #116 (d212aea) | #116 with `VICTORY_WAVE_WIDE=1` | |---|---|---|---| | wave32 programs that differ | 3 | 0 | 0 | | wave64 programs that differ | 10 | 10 | 6 | | number in the assertion | 23 | 20 | 12 | - **The 3 wave32 programs** are compares in lane-divergent branches: a `v_cmp` under narrowed EXEC must leave 0 in the VCC bits of the lanes it skips. #116 fixes them. - **4 of the wave64 programs** are the same thing in wave64. #116 takes those branches wave-wide only with `VICTORY_WAVE_WIDE=1`, because a wave64 run as two 32-lane waves needs group barriers there. So they remain by default. - **The other 6 wave64 programs** each minimize to a single `v_readfirstlane_b32`. On a 32-lane host each half of a wave64 reads its own first lane, so lanes 32–63 get lane 32's value instead of lane 0's (e.g. `s20`: GPU 0x20, oracle 0x0). This is a known open class with no fix and no `VICTORY_ORACLE_AVOID` key yet. - **Without the filter:** 171 on #70 and 164 on #116. The rest belong to the classes that #71 and #73 fix and to the ones the PR body lists as open. 🤖 Reproduced and classified with [Claude Code](https://claude.com/claude-code)
github-bot closed this pull request 2026-11-27 21:47:06 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.