Add CPU-only execution-equivalence tests for Wave32 shader SSA and structured EXEC #2090
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2090
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2090"
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?
@chaseb64 on GitHub · 2026-11-25 04:35 UTC · original
chaseb64:shader/wave32-execution-equivalence→main· +1837 −0 · 6 files · 3 commits · openSummary
Add a CPU-only differential checker for synthetic Wave32 integer programs with uniform branches, EXEC narrowing and restoration, and bounded loops. Each executor observes the final 32 dwords in v2.
The default suite includes a fixed generated corpus of 128 seeds (10,000–10,127). Every case must complete and agree at both transformed stages, with the seed and outcome reported on failure. The larger campaign runs on demand. Test and replay commands are in
crates/victory-shader/tests/equivalence/README.md.Test design
Grammar and observation. The program concatenates per-lane arithmetic, uniform two-arm branches, masked regions and counted loops with one to six trips. A loop body can contain branches and masked regions. Narrowed EXEC permits only per-lane arithmetic, under a guard or after a forward EXECZ skip, and each region restores its saved EXEC. Vector operations set or add a constant, add v1, or XOR with v1. Constants are 0–64 and addition wraps at 32 bits. A mask can come from the input scalar, an unsigned
threshold < v0comparison, or a uniform join between them. The initial v0, v1 and v2 values are distinct. The scalar roles are the input mask (s0), branch selector (s1), loop counter (s2), saved EXEC (s3) and joined mask (s4). EXEC starts full, with scratch scalar registers, VCC and SCC starting at zero. The finalv_mov_b32 v2,v0observes all 32 lanes exactly once after full EXEC returns. Intermediate flag and register state, branch traces, and instruction counts are outside that observation. A source wave may visit a block that an individual structured lane skips.Independent comparison. The reference interprets typed instructions with absolute branch targets, its own scalar registers and full lane arrays. It updates active lanes only. The encoder separately writes little-endian GFX10 words with signed relative branch displacements. The SSA evaluator consumes the decoded fields, actual operand bindings, phis, predecessors and exits from
ir::build(bytes, false, 3). The structured evaluator walks individual lanes through the exits and guards returned bystructure::structure, using its boolean-node and mask-phi mappings. Both transformed evaluators operate on compiler output and the input fixture. They never inspect the source instruction stream. All three share the input fixture, the final observation and Rust integer arithmetic. Hand-written cases check the meaning of the generated instruction stream.Campaign and reducer. A decimal SplitMix64 seed reconstructs the program and inputs. The opt-in campaign begins at zero by default and caps the search at 10,000 cases or 30 minutes, checking the deadline between bounded cases. Each execution allows 1,024 source instructions or block visits, per lane in structured execution. The summary counts agreement and each inconclusive or failing outcome separately. An SSA agreement still counts if a later stage fails. A semantic difference reports its seed, stage, first differing lane and both dwords. The reducer uses the original inputs, rebuilds branch targets after each edit, and removes regions or masked operations or shortens loop bounds. It keeps an edit only if the same stage, lane and values still disagree. This gives a local minimum under those edits. An injected guard fault exercises reduction, while other mutations exercise loop backedges, inactive-lane writes and structured branch destinations.
Evidence
On native Apple Silicon macOS with pinned Rust 1.98.1, the baseline had 144 library tests pass and two benchmarks ignored. With the checker, all 144 library tests and 12 new focused tests passed.
Replacing a loop-carried phi's backedge input changed lane 0 from 9 to 3. Removing a structured write guard changed lane 1 from 1 to 17. The reducer preserved that exact difference while shrinking eight instructions to five. Both unmodified transformations matched the reference.
Seeds 0 through 9,999 agreed at both stages. Counts for refusals, unsupported cases, exhausted limits, invalid executions, compiler errors, panics and mismatches were all zero. Seed 42 also replayed individually.
An independent Windows review of the initial checker ran 128 fresh seeds (10,000–10,127). All agreed at both stages. Those seeds now run in the default suite. Independent review
Clippy and the asset-policy check passed. Upstream Windows CI passed on
42bd6f5, including the fixed corpus. Windows CIThe README-only follow-up passed the native equivalence suite (13 passed, one opt-in campaign ignored) and
cargo xtask policy(188 files checked).Merge Danger
Reversibility. Reverting the PR removes the checker.
Scope. The six added files live under the shader crate's integration tests. The synthetic grammar covers the stated Wave32 integer and control-flow subset through structurization. Nested loops, Wave64, floating point, memory, textures, barriers, derivatives, discards, cross-lane operations, arbitrary scalar side effects under narrowed EXEC, and mask-as-data uses are outside the grammar. Emitted host code and GPU execution are outside the comparison.
AI-assisted using OpenAI Codex. GPT-6.2 Astra (High) implemented the checker. GPT-6.2 Sol (High) added the fixed corpus, and GPT-6.2 Sol prepared the documentation revision. Existing coordination claim.
@jeremygold02 on GitHub · 2026-11-25 04:40 UTC · original
Triage verdict — Keep the CPU differential suite (
82291ac)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@Marvisak on GitHub · 2026-11-25 10:18 UTC · original · edited 2026-11-26 04:21 UTC
Automated triage for the maintainers.
Merge candidate. Thanks for trimming the docs:
tests/equivalence/README.mdis now 17 lines with just the commands, and the test code and fixed corpus are unchanged since the last review. The suite only touches tests: a reference interpreter for a Wave32 integer/EXEC subset compared against SSA evaluation ofir::buildand lane-by-lane evaluation ofstructure::structure, with the fixed corpus running by default and the larger campaign#[ignore]d.CI: passing.
Generated by Claude Code
@chaseb64 on GitHub · 2026-11-26 03:18 UTC · original
Thanks for the feedback. In
7d85912, I cut the README from 74 lines to 17 and kept the test and replay commands. The grammar, independent comparison, and reducer rationale are now in the PR description. The fixed corpus and test code are unchanged.git diff --checkpassed, the native equivalence suite passed 13 tests with the opt-in campaign ignored, andcargo xtask policypassed all 188 files.AI-assisted using OpenAI Codex (GPT-6.2 Sol for the documentation revision).
@DenRakEiw on GitHub · 2026-11-25 04:44 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --test equivalence— 12 passed, 0 failed (1 ignored)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (189 files ok)Clean, fast CPU-only execution-equivalence test suite verifying Wave32 shader SSA and structured EXEC semantics. Looks great.
AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 05:09 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Note: 13 additional execution-equivalence tests also passed. CPU-only execution-equivalence tests for Wave32 shader SW — +13 tests in a second binary, all green on macOS; exactly the kind of portable coverage this crate needs.
@fuzeofficlal on GitHub · 2026-11-26 18:59 UTC · original · approved these changes
Verified
7d85912fa58e09cbb2f7e4c6d52278701011172ccleanly merged ontomain(63bcca43) on Windows 11 x64:rustfmt --edition 2024 --checkon all 5 added.rsfiles undercrates/victory-shader/tests/: clean (exit 0).cargo test -p xtask --locked policy::tests::repository_passes_policy:1 passed(asset policy: 197 files ok).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features): clean.cargo test --locked -p victory-shader --test equivalence: 13 passed; 0 failed; 1 ignored (search::campaign) in 0.11s, with all 128 seeds infixed_generated_corpus_agreesand all fault-injection cases passing deterministically across source, SSA, and structured EXEC evaluators.Non-blocking coverage note: the generated Wave32 subset currently emits compares only under full
EXECwithout checkingSCCfroms_and_saveexec_b32/s_add_u32, which leaves room for future expansion. Ready to merge.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.