Shaders: wave64 compute programs on hosts of 32-lane waves #1960
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!1960
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1960"
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?
@RaghavVijayanand on GitHub · 2026-11-25 01:45 UTC · original
RaghavVijayanand:shader/wave64-on-wave32→main· +1420 −49 · 8 files · 2 commits · closed without mergingWave64 compute programs that read other lanes declare
WaveSize(64), so pipeline creation fails on GPUs with only 32-lane waves (all NVIDIA GPUs, for example). The README listed this as "some compute programs need a GPU with 64-lane waves". Two commits.Shaders (
emit/lower/wave64.rs): on a 32-lane host, the program declaresWaveSize(32)and each console wave becomes two host waves, with thread ids kept in the console's lane order.ds_swizzle,v_writelane,v_mbcnt, and a lane's mask bit.v_readlaneat any lane,v_readfirstlane, whole-wave reductions, and prefix sums.ds_bpermute_b32(reads any of the 64 lanes) now reads through the exchange. It has a new test,permutes_read_lanes_of_the_other_half, with 128, 96 and 64 threads and full and partial EXEC.waveGetLaneIndex(1e923ad) is kept, in the one place that now makes host lane indices.v_readfirstlaneread the host's first active lane, which can be outside EXEC. It now reads the first lane of the guard's ballot. Main's own fix for pixel helper lanes is applied on top.GPU: host creation reads OPTIONS1
WaveLaneCountMin/Maxand tells the translator whether the host has 64-lane waves. The shader cache key differs for 32-lane hosts. The README entry is updated.Tests: the new
emit/wave64_tests.rs(9 tests) hand-assembles wave64 programs and checks every lane against a CPU model of the console wave. One test checks the in-file assembler against the repo's decoder.s_bcnt1/s_ff1/v_mbcnt,v_readlaneat fixed and SGPR lanes,v_readfirstlaneunder narrowed EXEC,v_writelane, DPP/permlane prefix sums, reductions, and a ballot after divergence.WaveSize(64)path. WARP (4 lanes) is skipped. Each test asserts that the 32-lane path ran on at least one device.Rebased onto current main (
940d32f). On this machine, 5 tests fail on main itself, with or without this change:descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views, the twostride_tests::a_heap_buffer_read_*tests, andsynthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with-D warnings, with and without--all-features.github-bot referenced this pull request2026-11-26 05:10:48 +00:00
@upipibi on GitHub · 2026-11-25 01:51 UTC · original
Overlap note, from reading, not a run: #1890 (opened earlier) runs wave64 compute programs on 32-lane hosts the same way:
WaveSize(32), each console wave as two host waves, cross-lane reads combined through group-shared memory. I verified it on an RTX 3070 (32-lane only) there. #1929 is a rebase of the earlier #233 with the same aim. This branch is based onffe310eand conflicts withmain. Three versions of one change would be hard to review, so it may be worth comparing against #1890 before rebasing.AI-assisted (Claude Code).
@Headache3318 on GitHub · 2026-11-25 01:59 UTC · original
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
e852943applied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass.cargo clippy -p victory-shader --all-targets -- -D warnings: 3 errors (vs 4 on main). The PR net-reduces clippy errors by fixing unused imports.Not tested: Windows MSVC build, the title itself. AI-assisted.
@Marvisak on GitHub · 2026-11-25 02:19 UTC · original · edited 2026-11-25 18:18 UTC
Automated triage for the maintainers.
Needs rebase.
mainhas moved, and this branch now conflicts with it inREADME.md. It will be reviewed again once it is rebased.The earlier notes still apply:
emit::wave64_teststests that panic on the WARP-only CI runner ("no SM 6.6 device ran the program") should skip when no hardware adapter can run them.split_ids(see #2126) and a device hang inCS_ComputeImposterTransformon an RTX 2080 stack. Both are worth addressing in the rebase.Generated by Claude Code
@Creaa on GitHub · 2026-11-25 03:41 UTC · original
Test report: this PR on Windows with an NVIDIA GPU (RTX 4070, 32-lane waves only). Head
fc61f2e, merged locally ontomain940d32ftogether with #1763 and #1751 (no conflicts), so that the title boots on this card (#1952) and the view heap keeps its dynamic slots.Setup: RTX 4070 12 GB, driver 617.14, i7-13700F, 32 GB RAM, Windows 11 build 26300, Rust 1.98.1 (pinned).
Tests (
cargo test --workspace --locked --no-fail-fast, debug):emit::wave64_testspass on the GPU, includinglane_reads_reach_the_other_half,ballots_span_both_halves_of_the_wave,permutes_read_lanes_of_the_other_halfandwhole_wave_reductions_and_prefix_sums_join_the_halves. The 3 failures are onmaintoo: the twoemit::stride_testsof #1835 andemit::synthetic_tests::gathers_at_a_level_match_the_hardware.mainalone on the same card: 696 passed, 5 failed, 10 ignored.translate --cache --pipelineson the title's shader pack, same card:mainSo the host no longer refuses wave64 compute pipelines; the cases this PR refuses on purpose (divergent ballots, lane reads in loops, LDS in a wave64 wave of more than 32 threads) now show up as about 300 compute programs that do not translate.
Title run: the splash and loading screens at 30 fps as before; at the first in-engine cutscene the frame rate falls to 0.1 fps with about 10 s of GPU time per frame and a black, then grey screen with no visible 3D objects, then the device hangs (246 s). That is the same as without this PR on this card, and matches #898, so it is not something this PR changes.
Not tested: other NVIDIA cards and drivers, this PR on its own (the title does not boot on this card without #1763 or another fix for #1952).
AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and runs on my machine and drafted this comment; I checked it before posting.
@MrEjecutor on GitHub · 2026-11-25 06:34 UTC · original · edited 2026-11-25 09:31 UTC
Offline data from an RTX 5060 Ti (Blackwell, 32-lane only): +90 compute pipelines, none lost; the shader-binning chain still stops at its third program
Setup: RTX 5060 Ti 16 GB, driver 621.24, Windows 11 26200, head
fc61f2eon its base940d32f, release build,victory translate --validate --pipelines --listover the title's files, compared program by program with the same run on940d32f.One thing first, because it made my first run read "no change": the
--validate --pipelinesmode builds the shader crate's ownHost, notvictory-gpu's, soset_host_wave64(false)is never called there and it translates as for a 64-lane host (the default). My first run gave exactly themaincounts for that reason. For the numbers below I set it tofalsein that mode with a local switch (not part of this PR, not posted). The--cachewarm-up goes another way, so it may not be affected; I did not check that.940d32fpipeline: The parameter is incorrectbeforeThe chain I was looking at is
shader_binning_utils. On this card, with it refused, the colour targets of a world frame hold only small objects while depth holds the whole view (Marvisak/VIctory#1968):940d32fCS_GenerateShaderBinsCS_GenerateShaderBins_TiledCS_GenerateShaderBinOffsetsThe two other wave64 approaches I measured the same way stop at the same program: #1929 (on its base
42363ab) refuses all three in emit, and a port of #189 (on70564ae) creates the first two and refuses the third ("a 64-lane wave ballot in divergent control flow"). So on 32-lane cards the third program is the one left in that chain for all three.Edit: for comparison, the fork
fxceless/victory-forkat310c6eb(offline, translating as for a 32-lane host with itsVICTORY_HOST_WAVE=32,VICTORY_WAVE_WHY=1) creates pipelines for all three, but the third only through its last-resort approximate mode: every exact retry stops (lane reads in a half-wave, a lane mask exchanged where not every lane runs, a first-lane read where not every lane runs), and the one that goes through makes each host wave of 32 take masks and lane reads over its own lanes only. So nobody has an exact form of that program for 32-lane hosts yet, as far as I can tell. A guess I have not checked: if its offsets come out wrong that way, some bins would be left unshaded, which could be why large surfaces are missing in places in the fork's picture on this card.Not tested: a game run with this PR (Creaa's RTX 4070 run above already shows the world the same as without it); the
--cachepath; other cards.AI use: Claude Code built, ran and wrote this; checked by mrejecutor. No game data attached.
@0xkn0wh3r3 on GitHub · 2026-11-25 06:53 UTC · original
Tested this on an RTX 5070 Ti (driver 621.24, 32-lane waves only). It runs wave64 compute there, and all ten
wave64_testspass. One group layout comes out wrong, though.What I ran. A console wave64 compute program in a 128-thread group (two console waves). Each thread stores, at its flat id, its console lane (
v_mbcnt_lo/hi) and its wave's lane count (s_bcnt1_i32_b64ofexec). On the console every thread should getflat % 64and 64. Translated withset_host_wave64(false), as the host sets it on this card:fc61f2e)Why. For some 2-D groups, NVIDIA does not fill a host wave with 32 consecutive flat ids. It fills it with a 16x2 tile of the group. I probed this with plain HLSL on the same card: a 32x2 group's first wave holds ids 0-15 and 32-47. 2-D groups 24, 32 or 64 wide, or not a power of two wide, are laid out this way. 1-D groups and 8x8, 16x16 and 16x8 groups are in order.
split_idstakes the half and the console wave's base from the host's first flat id (waveReadLaneFirst(flattenedThreadIdInGroup)), andthread_idrounds that same id down. With tiles, two host waves round to the same base: they are paired into the wrong console waves and given the same ids.A fix. #2126 hits the same assumption for wave32 programs that read lanes. It gives every host wave its own aligned run of ids with a group-shared ticket: each full wave's first lane adds the wave size to a zeroed counter, and the one partial wave takes the last run. 1-D groups keep the rounding. With that relabelled id (
console_flat),split_idsbecomes:With both PRs and this change merged, all three shapes match the console on the RTX 5070 Ti, and this PR's ten tests still pass. That combination is on
0xkn0wh3r3/VIctorybranchdemo, with the test above asemit::lane_order_tests::a_wave64_program_runs_as_the_console_runs_it_on_a_32_lane_host.Whichever of the two lands second needs the change. If this one goes first, its split could take the same ticket on its own, keeping the rounding for 1-D groups.
@Machad3x on GitHub · 2026-11-25 10:09 UTC · original
In-title run on an RTX 3080 Ti (32-lane waves only): refused pipelines go from 157 to 0; GPU work per frame goes up
Setup: RTX 3080 Ti 12 GB, driver 621.24, Windows 11 26300, Series X profile, diag build,
VICTORY_SHADER_LOOP_LIMIT=4096, scripted Enter presses, cache filled withtranslate --cache.main940d32f+ #1763 + #1751 + #1800 + #1906 + #2098 + #1762 (the stack from my comment on #1968), then the same plus #688 and this PR (fc61f2e). Cherry-picked without conflicts. One 7-minute run each, so run-to-run variation is not measured, and the second build differs by #688 too.host pipeline refusedE_INVALIDARG)translate --cache, containers refuseddoes not translatelines in the runTdrDelayis 10 s on this machine)The most frequent new refusal reasons at run time:
LDS shared without barriers by a wave64 group of 33 to 64 threads, on a host without 64-lane wavesa wave64 cross-lane operation spanning both halves, on a host without 64-lane waves, where not every thread of the group arrives oncea 16-bit wave reduction in a wave64 program, on a host without 64-lane wavesI did not identify which programs make the slow submissions. With the default 2 s TDR delay, submissions of 3.5 s could reset the driver.
AI-assisted (Claude Code); measured on my own machine.
@stem23456-coder on GitHub · 2026-11-25 16:18 UTC · original
@RaghavVijayanand @0xkn0wh3r3, could whichever PR lands second carry the
split_idschange and the 128-thread regression test fromdemo? I combined #1960 (fc61f2e) and #2126 (e214ce4) locally. The only merge conflict was inLower::thread_id. Keeping its call toconsole_flat()letssplit_idsderive both the half (id & 32) and the wave base (id & !63) from the same Xbox thread ID. Fix in demo · Regression testI ran the emitted DXIL through a CPU model of four 32-lane waves. In a
32×4group with16×2host tiles, #1960 alone wrote 64 of 128 output slots, each twice. With the port, every slot was written once with(id % 64, 64)for128×1,16×8and32×4. Both 2-D cases passed for all 24 ticket orders. The Windows test also type-checked forx86_64-pc-windows-msvc. Original RTX 5070 Ti runLocal checks and comment prepared with Codex on macOS arm64.
@lhnizdo on GitHub · 2026-11-25 18:11 UTC · original
Tested against the title on a 32-lane-only card: RTX 2080, driver 32.0.16.1742, Windows 10 19045. The stack is
main940d32fplus #2460, #2461, #2462 and #2464, with this PR merged on top. The only conflict was inshader_cache.rs, where both add a line before translating, and I kept both.Compute pipelines,
translate --pipelineslimited to compute programs:E_INVALIDARG,WaveSize(64))That's 87 more working compute pipelines, and none handed to the driver that it refuses. The 307 refusals:
The 191 look like what #192 targets.
One note for measuring:
translatenever callsset_host_wave64, sotranslate --pipelinesstill translates for 64-lane waves even on a 32-lane card. I added a local switch to set it before translating; without that, the numbers above don't change.In the game (diag build, scripted Enter presses, DRED on):
DXGI_ERROR_DEVICE_HUNG). DRED had adispatch 1x1x1ofbillboard_nobump:CS_ComputeImposterTransform(hashe30970f1727063fd) in flight. The same program ran without trouble in runs of the same stack without this PR, and it was never refused there, so this PR changes it even though it isn't one of the newly enabled wave64 programs.My guess, unconfirmed: the change to
v_readfirstlaneunder a lane guard (reading the first lane of the guard's ballot), which applies at every wave size. I haven't narrowed it down further. It may be worth checking that program's translation with and without the PR.🤖 Generated with Claude Code. The measurements were made by Claude Code on my machine.
@lhnizdo on GitHub · 2026-11-25 18:51 UTC · original
Correction to my comment above: the hang isn't in
CS_ComputeImposterTransform.That program is small, with no loops and no cross-lane operations, so it can't spin the GPU itself. DRED just listed it among the commands of the hung list. A second run with this PR (plus #192) hung the same way, about 3 minutes in. This time DRED's report says the list stopped at command 4862 of 12115, in a run of commands that starts with a
dispatch 45x1x1of compute28918b7150a7aad5, alongside dispatches ofcaa78b8ca62bc3d6(21 to 34 groups).Both of those are refused by the driver without this PR (
WaveSize(64)on a 32-lane card) and run with it. So the hang is most likely in one of the wave64 programs this PR newly enables:28918b7150a7aad5orcaa78b8ca62bc3d6. I haven't confirmed which, or narrowed it down inside them.Also, for anyone looking at the
building/INSTANCE_LISTpool exhaustion (#698): with this PR theInstanceCullingGrassandSimplefamilies run on a 32-lane card.Prop,SlodandTreeare still refused, for a cross-lane operation spanning both halves "where not every thread of the group arrives once" and for LDS shared without barriers.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 01:45 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@catminou4 on GitHub · 2026-11-25 03:32 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. Wave64 compute programs on hosts of 32-lane waves — third PR in this cluster (#1890, #1929 flagged earlier); emulation strategy must be consistent across the three.
@Creaa on GitHub · 2026-11-26 09:59 UTC · original
@RaghavVijayanand measurements only, no code proposal: where this PR's wave64 split still refuses compute programs on a 32-lane host, and why I think none of them is a safe case for the current barrier design.
Setup: this PR's head
fc61f2e,emit::set_host_wave64(false), offlinevictory translate --listover a retail shader pack (compute only for the counts below). Local diagnostics only (not pushed): the instruction being lowered and the IR block whenevery_threadrefuses, and the kind of branch that lets a path skip that block. RTX 4070 machine, but this is translation, not GPU execution.Sample: the 81 compute programs that #2176 (+ #3115) refuse first at
s_ff1_i32_b64. On this PR 6 of them emit; the other 75 all stop atNOT_EVERY_THREAD:every_threadrefusess_ff1_i32_b64s_bcnt1_i32_b64v_readfirstlane_b32s_or_saveexec_b64Why the block is not "every thread once":
Atom::Lane, a VALU compare) lets paths bypass the block. A half wave in which no lane meets the condition skips the block entirely (EXEC empty), so the group would not reach the two syncs the same number of times. That looks like real divergence, not a gap in the analysis.while EXEC != 0 { first = s_ff1(EXEC); ... }), whose trip count depends on each wave's (half's) data, so it is not equal across the group either.So I did not find a small, provably safe subset to carve out of these 75; exact coverage would seem to need the exchange at a group-uniform point before the branch (e.g. a whole-wave ballot hoisted above the
if, read inside it), or an approach like #233's. Just data in case it helps with the design; the per-program breakdown is available if useful.AI use: Claude Code (Claude Opus 5.5) instrumented the translator locally, ran the measurement and drafted this note; the measurement setup was prepared with OpenAI Codex (GPT-6.2 Astra).
@RaghavVijayanand on GitHub · 2026-11-26 10:18 UTC · original
Superseded by #3147, which carries this branch rebased onto current
main. The rebase followsmain'sds_bpermute(reads stay within the 32-lane half), andv_readfirstlanereads the first lane of EXEC again after #2468. All 16wave64_testspass there. Thanks to everyone who tested this one; your reports helped.Pull request closed