wave64: halve programs whose every LDS access names only its own lane's words #158
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!158
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-158"
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?
@Koro4e on GitHub · 2026-11-24 21:58 UTC · original
Koro4e:wave64-lds-private→main· +380 −3 · 6 files · 2 commits · openWhat
Adds an analysis (
lds_lane_private) that lets a console wave64 program run in host waves of 32 even when the group is over 32 threads and LDS is in play — provided every LDS access's address derives only from per-lane values (the entry VGPRs, i.e. the thread id) plus uniforms and constants, and never from memory or another lane's LDS word. Such accesses need no ordering between the host waves: each console lane touches only the words its own address names.Wired into the halving decision next to
lds_ok/lds_meetings.VICTORY_WAVE_LDS_ASSUME=1force-enables it for programs the analysis cannot follow (quarantine keeps a wrong guess contained).Why
Programs with a group over 32 and LDS otherwise stay at WaveSize 64, which a 32-lane host refuses — on NVIDIA these pipelines never come up.
Measured
WaveSize 32than did before (probe:wave_why; verified withdxc -dumpbinon the emitted container).WAVE64-LDS-PRIVATE), where they would have been refused before.The four structure-builder programs are not among them — their LDS is genuinely shared across the console wave (a lane writes a flag at a fixed word, the rest read it) inside divergent regions, so they still need the full treatment. Notes on that, and on everything above, are in
docs/wave64-notes.md.Probes added
lds_dump— decodes a dumped console shader and prints every LDS access with the address computation.validate_dump— validates dumped containers with dxil.dll.wave_why— explains why a program keeps 64-lane waves.No game data of any kind is included — the probes take a file path at runtime.
bare_command_costsays about the indirect clamp #696@ericomeehan on GitHub · 2026-11-24 23:14 UTC · original
Thanks for going after the wave64 LDS refusals: they are one of the clearest blockers on 32-lane cards, and
wave_why/lds_dumplook useful.One concern with
lds_lane_privateas it stands (from reading the diff; I haven't run it): it accepts an address if it depends on the thread id at all (taint & 1 != 0), which doesn't yet show that each lane touches only its own words. For example(tid ^ 32) * 4,(tid + 32) * 4or(tid & 31) * 4all pass, and each makes a lane read or write a word owned by a lane in the other 32-lane half. On the console those lanes run in lockstep and need no barrier; split into two host waves they race, and the result is silently wrong LDS data rather than a fault. Wave-synchronous LDS reductions have exactly this shape. BecausetaintORs its bits,offset_loaded_from_memory + tidalso passes (bits 1|4).A tighter rule could accept only
uniform + tid * kwithkat least the access size, the same form for every access, and no unknown bit. With that, and the path behind an off-by-defaultVICTORY_*switch (keyed into the shader cache, as #98 does forVICTORY_PORTABLE_HEAP), it would be much easier to trust. Two small things: the new function sits betweenlds_meetingsand its doc comment, so that comment now documentslds_lane_private; and theeprintln!s could betracing.Written with an AI assistant (Claude).
@m335671 on GitHub · 2026-11-24 23:47 UTC · original
Test on an RTX 4070 (32-lane waves): this PR makes the driver create one of the compute pipelines that every 32-lane NVIDIA run refuses,
2da4beb386509b77, and changes nothing else in the pack.Tested
3478875, merged with #77, #218, #51 and #81 on2119b0e, compared with the same tree without it.VICTORY_HOST_MAX_WAVE=32 victory translate --list --pipelines <shaders.rpf>, compared program by program by hash.2da4beb386509b77,pipeline: The parameter is incorrect.→pipeline created.02384a60fda6f2d0,2cc4c197ee29e291,369cbe906ea72764and6b82bc7d22016cb5are still refused. That fits what the PR says about LDS shared across the console wave.2da4beb386509b77logsshader translatedandhost pipeline shaders=[compute 2da4beb386509b77]. The refused set drops from 5 to the 4 above.WAVE64-LDS-PRIVATElines.Not tested: that run only reached the profile screen: my scripted presses didn't get past it, and the pipeline was made by the early-start warm-up. So I have not seen this program dispatched in the world, or its output. Other GPUs not tested either.
AI use: the runs were done on my machine. Claude Code (Claude Opus 5.5) built and ran them, compared the outputs and wrote this comment.
@FrancescoGelosoEterea on GitHub · 2026-11-25 00:10 UTC · original
Tested on NVIDIA (32-lane host): this brings up one of the wave64 compute pipelines that this card refused (#7, #11).
Setup: RTX 5070 Ti, driver 621.24, Windows 11, Ryzen 7 9800X3D. Own 1.0.2.1 copy, Series X profile, diagnostics build:
4e17478+ #51 + 15 other open PRs, then #95, #220, this PR (3478875), #187, #234 and #141. The same run script was used before and after, with noVICTORY_WAVE_LDS_ASSUME.2da4beb386509b77E_INVALIDARG), 63 lines02384a60fda6f2d0,2cc4c197ee29e291,369cbe906ea72764,6b82bc7d22016cb5There was no device removal and no crash in a 7-minute run in the world, and the walls and lighting in the prologue room render. The four that are still refused presumably fail the lane-private LDS analysis. If it helps, I can rerun with
VICTORY_WAVE_LDS_ASSUME=1and report whether they come up and render correctly.The fps numbers are not a clean A/B, because other PRs changed in the same build, so I am leaving them out.
@FrancescoGelosoEterea on GitHub · 2026-11-25 02:51 UTC · original
A follow-up on
lds_lane_private. I think it can call a shared LDS word "per-lane".taintfollows every register an instruction reads. For a VALU instruction that writes a VGPR, the IR also lists the destination's old value among its reads, for the lanes outside EXEC that keep it. Sov_mov_b32 v1, 0reads the oldv1. Every VGPR that is not written yet at entry is a program input, so that read gets taint 1. The constant address 0 then comes out "per-lane", and a word every lane shares runs without the barriers.I hit it while writing a test: 64 threads,
v_mov_b32 v1, 0, thends_write_b32 v1, …andds_read_b32 …, v1in a lane branch. This printsWAVE64-LDS-PRIVATE group=64 lds=128and lowers toWaveSize(32)with no barriers. Usingv9for the address gives the same result.A fix that worked for me: in
taint, skip a read of a VGPR that the instruction also writes, when it is a whole-dword VALU write and none of its source operands names that register. That excludes DPP, SDWA,mac,laneand 16-bit ops. That read is only the kept value.With it,
2da4beb386509b77(CS_AlphTransmissionPrefilterMip) is still created on the RTX 5070 Ti, so the program this PR is for keeps working.@Koro4e on GitHub · 2026-11-25 07:14 UTC · original
Thanks @ericomeehan, @m335671 and @FrancescoGelosoEterea — the RTX 4070 and RTX 5070 Ti runs are exactly what this needed: the pipeline this PR brings up on a 32-lane host (
2da4beb386509b77, #7, #11) matches what we see on an RTX 3060 12 GB, where it is created and the world runs without a crash in a 7-minute session.On both review points: taint is gone. You are both right that it could call a shared LDS word "per-lane", and the pushed commit (
452ef2d) replaces the taint walk with a strict form rule:uniform + c·tid + const, all accesses in one form;c≥ the largest access size, and the spread of the uniform bases ≤c, so two lanes — and the two host waves — never touch the same dword;Unknown, so @FrancescoGelosoEterea your case (the destination's old value read for the lanes outside EXEC, an unwritten VGPR acting as an input) can no longer pass: the rule never looks at taint and never accepts a value it cannot see a definition of;v_lshl_add_u32joined the supported ops (the real shaders computebase + (index << c)with it), andv_lshlrev_b32now checks that the constant operand is really the shift;VICTORY_WAVE_LDS_PRIVATE=1, and the switch is part of the shader cache key (upstream's translation fingerprint picks it up from the source now).Honest numbers, so nobody has to find them out the hard way: an offline scan of the 1,163 dumped compute shaders with the strict rule enabled lets 0 of the 37 programs through that the old taint rule passed. The dumps (
lds_dump) show why: the real addresses come from loop-carried bump allocators —v0 = (v1 << 3) + v0, masked with0x3FFFFFFF— which no per-value form rule can prove private. So the strict rule is sound and currently covers nothing; the next step is a loop-carried analysis (a monotone per-lane index with a bounded window), which is a bigger change and belongs in its own PR rather than in a widening of this one.Practical effect of this PR as it stands: wave64 compute without LDS — or with LDS the meetings rule already orders — now runs on 32-lane cards; the LDS-heavy programs keep the old path until the loop analysis lands.
@Koro4e on GitHub · 2026-11-25 09:33 UTC · original
Thanks @ericomeehan, @m335671 and @FrancescoGelosoEterea — the RTX 4070 and RTX 5070 Ti runs are exactly what this needed: the pipeline this PR brings up on a 32-lane host (
2da4beb386509b77, #7, #11) matches what we see on an RTX 3060 12 GB, where it is created and the world runs without a crash in a 7-minute session.On both review points: taint is gone. You are both right that it could call a shared LDS word "per-lane", and the pushed commit (
452ef2d) replaces the taint walk with a strict form rule:uniform + c·tid + const, all accesses in one form;c≥ the largest access size, and the spread of the uniform bases ≤c, so two lanes — and the two host waves — never touch the same dword;Unknown, so @FrancescoGelosoEterea your case (the destination's old value read for the lanes outside EXEC, an unwritten VGPR acting as an input) can no longer pass: the rule never looks at taint and never accepts a value it cannot see a definition of;v_lshl_add_u32joined the supported ops (the real shaders computebase + (index << c)with it), andv_lshlrev_b32now checks that the constant operand is really the shift;VICTORY_WAVE_LDS_PRIVATE=1, and the switch is part of the shader cache key (upstream's translation fingerprint picks it up from the source now).Honest numbers, so nobody has to find them out the hard way: an offline scan of the 1,163 dumped compute shaders with the strict rule enabled lets 0 of the 37 programs through that the old taint rule passed. The dumps (
lds_dump) show why: the real addresses come from loop-carried bump allocators —v0 = (v1 << 3) + v0, masked with0x3FFFFFFF— which no per-value form rule can prove private. So the strict rule is sound and currently covers nothing; the next step is a loop-carried analysis (a monotone per-lane index with a bounded window), which is a bigger change and belongs in its own PR rather than in a widening of this one.Practical effect of this PR as it stands: wave64 compute without LDS — or with LDS the meetings rule already orders — now runs on 32-lane cards; the LDS-heavy programs keep the old path until the loop analysis lands.
@m335671 on GitHub · 2026-11-25 12:09 UTC · original
Offline check of
452ef2don a 32-lane card. With the strict rule,2da4beb386509b77is refused again, with or withoutVICTORY_WAVE_LDS_PRIVATE=1. That fits your scan.Note:
452ef2disn't on this PR's branch yet. The PR still shows3478875as its head, so I fetched the commit from your fork by its hash.Tested
452ef2das it is, on4e17478.VICTORY_HOST_MAX_WAVE=32 victory translate --list --pipelinesover the title's whole shader pack, once without the switch and once withVICTORY_WAVE_LDS_PRIVATE=1.2da4beb386509b773478875(old taint rule, yesterday)452ef2d, switch offpipeline: The parameter is incorrect.452ef2d,VICTORY_WAVE_LDS_PRIVATE=1pipeline: The parameter is incorrect.The two
452ef2dlistings are the same program by program. With the switch on, nothing passes that didn't pass with it off. So as you said, the PR currently brings up nothing on this card, andCS_AlphTransmissionPrefilterMipwaits for the loop-carried analysis. I didn't run it in the title, because offline nothing changes.AI use: Claude Code (Claude Opus 5.5) built and ran the check on my machine, compared the listings and wrote this comment.
@Daolyap on GitHub · 2026-11-25 13:39 UTC · original
A heads-up from combining this with #592 and #500 on
f85101b.Alone, this PR is the biggest gain of the three: on a 32-lane host (
VICTORY_HOST_WAVE=32 VICTORY_WAVE_WHY=1) the corpus goes from 386 compute programs kept at 64 lanes to 354.But with #592 merged as well, #592's test
emit::wave64_tests::a_branch_that_writes_lds_two_different_values_keeps_64_lanesfails (the program comes out at 32 lanes instead of 64). It passes with #592 alone and with #500 + #592, so the change in behaviour comes from this PR. That test's program writes a flag at a constant LDS address in a lane branch, reads it, then writes a second, different value. Splitting that into two host waves lets one wave read the other's write out of order.From reading
lds_lane_private: it takes a program as private when every LDS address has a per-lane taint (t & 1). Two things there may be worth a look:t == 5) still passes, though the comment says unknown isn't provable;tid >> 5ortid & 0are per-lane-derived but shared).I haven't pinned down which path makes the test program split, so treat this as a pointer rather than a diagnosis.
AI-assisted (Claude Code).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.