wave64 on 32-lane hosts: s_bcnt1 of a mask complement misses the lanes outside a partial group (32 instead of 64) #3916
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#3916
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@dyshay on GitHub · 2026-11-30 11:30 UTC · original
What is wrong
A console wave64 compute program whose group is not a multiple of 64 threads (a group of 96: the second console wave has lanes 0..31 only) counts the bits of a complemented lane mask wrong when it goes through the plain wave64-on-wave32 lowering, which is the default path since folding was turned off by default (
5c262d7b).On RDNA2 the SGPR pair holds all 64 bits. Lanes that do not exist in a partial wave are outside EXEC: a VALU compare writes 0 there, and
s_not_b64(ors_orn2_b64,s_nand_b64, ...) sets those bits like any other.s_bcnt1_i32_b64ands_ff1_i32_b64then count/find them.The lowering reads a mask as a number by taking a ballot of the lanes' booleans (
Lower::mask_dwordincrates/victory-shader/src/emit/lower.rs). Two things go wrong for a partial group:structure.rs) takes EXEC on entry as every lane (Bool::TRUE), sos_not_b64of a compare is just!laneand looks like a mask set only where lanes run (Structured::active). The ballot only has the lanes that exist, so the bits of the missing lanes are 0 where the console has 1. (s_andn2_b64 exec, vccis the same lane boolean to the structure, but its console value has 0 there, so the lane boolean alone cannot give the answer.)Lower::exchange_halves) reads that half's dword from LDS though nothing writes it: whatever LDS held. The doc comment says the missing half "gets 0", but nothing makes it so.Repro
Program (raw GCN, as in
folded_tests.rs):group of 96 threads, wave64, through
emit()with the default switches (folding off), host of 32-lane waves.s_bcnt1Wave 0 is right. The folded form (
VICTORY_WAVE_FOLDED=1) is right (a_mask_with_lanes_outside_exec_is_read_as_the_consoles_number).Which programs could be affected
Wave64 compute programs translated in the plain form on 32-lane hosts (NVIDIA, Intel) whose group size is not a multiple of 64, or that are dispatched by a thread count with a partial last group (
USER_DISPATCH_THREADS_X, lanes kept underpartial_active), and that read as a number a lane mask holding lanes outside EXEC: the complement of a compare counted or searched (s_bcnt1,s_ff1,v_mbcnt, scalar compares of the mask). Typically "how many lanes failed the test" in compaction or classification code. Masks that are only ANDed with EXEC are not affected by (1), but every mask read as a number in such a group is exposed to (2).@github-actions[bot] on GitHub · 2026-11-30 11:30 UTC · original
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
@cloph-dsp on GitHub · 2026-11-30 11:32 UTC · original
finding: wave64-on-wave32 mask-as-number for a partial group is a real source-level gap and your raw-GCN repro needs no title data, so it is in principle locally testable here. Holding off on an implementation: the fix spans three lowering layers (structure.rs treating entry EXEC as every lane, Lower::mask_dword's whole/ballot path, and Lower::exchange_halves reading an unwritten LDS half), and the right contract for lanes outside EXEC in the plain (non-folded) path is a maintainer design call. I do not want to add a format/behaviour PR that conflicts with the folded path's existing answer. If you can say which layer you intend to own, I can take the remaining one with a synthetic test. No game data used or uploaded. AI-assisted: Hy4 flash.
@dyshay on GitHub · 2026-11-30 11:39 UTC · original
@cloph-dsp thanks for looking. The PR linked here, #3917, already takes all three layers in one change: lanes outside the group get the console's bits reconstructed from the mask's instructions (entry EXEC and compares/carries 0; s_not/and/or/xor/andn2/orn2/nand/nor/xnor/cselect, saveexec and constants followed),
mask_dwordapplies them before the ballot for lanes past the dispatch and after the exchange for those past the group, andexchange_halvesreads 0 for a missing upper half. The folded path isn't touched. A mask from a join or a load keeps the old behaviour (0 there), and the SCC of a mask op read as data (scc_some) is likely wrong the same way. That second one is open if you'd like to take it with a synthetic test. A review of #3917's contract for lanes outside EXEC would also be very welcome.@tyr0nsur on GitHub · 2026-11-30 19:51 UTC · original
I took the
scc_somepart: #4400, stacked on #3917. With a group of 96 and every lane passing the compare, SCC ofs_not_b64 vccwas 0 in the second console wave where the console has 1. It now takes the lanes outside the group fromoutside_pair, the same waymask_dworddoes. The test is infolded_tests.rs. It passes on an RTX 4060 (32-lane host waves, default switches), and all 464victory-shaderlib tests pass. A review of how it picks the mask behind SCC (scc_mask: the lowest scalar destination, EXEC for a saveexec) would be welcome.AI-assisted with Claude Code.