Shaders: VICTORY_WAVE_VERIFY=check, a report-only checker that proves wave64 forms meet their group barriers #3336
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3336
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3336"
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?
@AimLogin on GitHub · 2026-11-29 21:56 UTC · original
AimLogin:shader-wave64-group-checker→main· +7136 −1 · 11 files · 1 commits · closed without mergingWhat it changes
On a host of 32-lane waves, a console wave64 compute program runs in one of several forms:
crate::fold);widen: modes All, SafeSingleWave and DriverLoop, and the wide fallback;Several of these forms put group barriers inside control flow that the translator decides per wave. DXIL's contract with the driver is that a group barrier sits only in group-uniform control flow. A barrier that one wave of a group reaches and another does not, or reaches a different number of times, is undefined behaviour. On the card it can hang the group or give a device loss. Nothing in the tree checks this after lowering today.
This PR adds a checker that proves it, report only:
VICTORY_WAVE_VERIFY=checkswitches it on. It is off when the variable is unset or has any other value.W64-VERIFY … pass;fail, with the barrier block, the branch it depends on, what that branch reads, and the roots of its non-uniformity;unmodelled, with the reason.victory translatealso prints aW64-PROGRAM <label>line before each wave64 compute program, so a verdict can be matched to its program.The pieces:
emit/verify_groups.rs: the group verifier. Its model is one host wave per console wave, with branches of four kinds: group-uniform, group vote, wave-predicated, per wave.s_endpgmcounts. This is the formal form of "a barrier only in uniform control flow".is_group_uniform_val. Thread ids, LDS and memory results, lane reads and per-wave joins are not uniform. A scalar load is uniform only at a uniform address in a program that does not write memory there.LOOP_LIMITstops are made explicit. They are modelled conservatively, as leaving the program, asabort_blockdoes.emit/wave_interp.rs(test only): B8, a CPU interpreter that runs a group's waves under several schedules. It is the reference that a proved graph meets under every schedule, and that a divergent one deadlocks.emit/w64_check.rs: the checker and its per-form model.Structured::widebranch is a vote.unmodelled.widen's success return, which covers every wave-wide form, the fallback, the half meets and the pairs;folded;emit_program_plain, which notes the IR and structure it lowers. The note is dropped when it returns, so a later lowering is never checked against another program's IR;group_syncand the title'ss_barrier), and the half-meet and pair-meeting spins.shader_cache.rs:VICTORY_WAVE_VERIFYis inNOT_TRANSLATION, because it changes no translation.KEYED: that would change everyone's key with the switch off.How it was tested
Byte identity (offline census, the switch on and off).
victory translate --list --jobs 1over the title'sshaders.rpf, withVICTORY_HOST_WAVE=32 VICTORY_HOST_MAX_WAVE=32:829188e9: 0 of 25,693 emitted modules differ between the checker on, the checker off and the unpatched build. The--listmodule hashes and theVICTORY_SHADER_CENSUSinstruction counts are both identical.f889bb07withVICTORY_WAVE_FOLDED=1plus #2853 and #2265: 0 of 25,693 modules differ with the checker on.cec481f4, with the upstream default switches: 0 of 25,693 emitted modules differ between the unpatched build and this branch with the checker on.W64-PROGRAMlines and 148 verdicts.clippy::manual_is_multiple_offixes,x % n == 0→x.is_multiple_of(n). They change no behaviour, and the tests were re-run on the final patch.)What it reports on the title (
f889bb07+ FOLDED=1 + #2853 + #2265):s_barrierin a region that a foldeds_cbranch_execzskips when a console wave has no lane left. The branch's condition comes from thread ids (in 4 of them, also a scalar load).widen(mode All) emits a titles_barrierinside a per-lane branch it does not widen. The checker fails it. No title program takes that path today.Unit tests (
cargo test -p victory-shader --lib, no GPU, no game data). Every fixture is hand-written GFX10 machine code or a hand-written group graph. Each negative case has a control that must give the other result:host_widebranch is per wavewidenon the wave OR fixturewidenwith a titles_barrierin a lane branchdx.op.barriersite in production code, so each site is classified (waits for the group or not) before it can go uncountedIn addition:
verify_groupshas 41 tests andwave_interp14, each with negative controls.victory-gpu'severy_switch_of_the_translator_is_in_the_keycovers the new switch.cec481f4:cargo test --release --locked -p victory-shader --lib -- emit::w64_check emit::verify_groups emit::wave_interp: 73 passed;cargo test --release --locked -p victory --bin victory: 79 passed;cargo clippy --locked -p victory-shader -p victory --all-targets: no warning in a file this PR touches.shader_cache.rs:14's unusedAtomicBoolandlower.rs:594's unused import), so a workspace-wide-D warningsrun fails without this PR as well.every_switch_of_the_translator_is_in_the_keyfails oncec481f4with and without this PR, onVICTORY_SCALAR_SPLITS, which is still inKEYEDbut no longer read (#3189; #3061 fixes it). The check this PR's switch needs, that no translator switch is left out of the lists, comes before that assertion and passes.Test details:
VICTORY_HOST_WAVE=32). On a 64-lane host the wave64 forms are not taken.cargo testpassed for the crates it touches: yes (victory-shader and victory oncec481f4). The victory-gpu key test fails on #3189 only (fixed by #3061), as it does without this PR.Limits (stated plainly)
unmodelled. This covers the pair meetings and the half meets. Proving them needs a subgroup model of the meeting words.unmodelled.LOOP_LIMITis modelled as leaving the program, asabort_blockdoes. A per-wave loop ahead of a later barrier therefore fails the barrier. That is conservative, and real on the host: a wave that leaves does not meet the barrier.bitcode::opt. The barrier dedup (#42) only drops barriers inside one DXIL block, which keeps liveness (t8). On the title at829188e9, it changes the barrier count of no checked program (measured withVICTORY_SHADER_OPT=191).victory translateor a cold cache.Provenance and licence
is_group_uniform_val.safe_single_wave_widen(#1006) is a possible cross-check of the uniformity verdicts. It is not used here.Checked for overlap
VICTORY_WAVE_VERIFY: there are none.lane_uniform), #2421 (cross-half barriers; adds barriers, so this checker would see them).🤖 Generated with Claude Code
Pull request closed