Skip to content

wave64: halve programs whose every LDS access names only its own lane's words - #158

Open
Koro4e wants to merge 2 commits into
fxceless:mainfrom
Koro4e:wave64-lds-private
Open

Koro4e wants to merge 2 commits into
fxceless:mainfrom
Koro4e:wave64-lds-private

Conversation

@Koro4e

@Koro4e Koro4e commented Nov 24, 2026

Copy link
Copy Markdown

What

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=1 force-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

  • Offline, over 1 163 dumped compute programs: 37 more programs now emit WaveSize 32 than did before (probe: wave_why; verified with dxc -dumpbin on the emitted container).
  • Live, in one session on an RTX 3060: 20+ programs took the new path at runtime (logged as 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.

@ericomeehan

Copy link
Copy Markdown

Thanks for going after the wave64 LDS refusals: they are one of the clearest blockers on 32-lane cards, and wave_why/lds_dump look useful.

One concern with lds_lane_private as 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) * 4 or (tid & 31) * 4 all 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. Because taint ORs its bits, offset_loaded_from_memory + tid also passes (bits 1|4).

A tighter rule could accept only uniform + tid * k with k at least the access size, the same form for every access, and no unknown bit. With that, and the path behind an off-by-default VICTORY_* switch (keyed into the shader cache, as #98 does for VICTORY_PORTABLE_HEAP), it would be much easier to trust. Two small things: the new function sits between lds_meetings and its doc comment, so that comment now documents lds_lane_private; and the eprintln!s could be tracing.

Written with an AI assistant (Claude).

@m335671

m335671 commented Nov 24, 2026

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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 no VICTORY_WAVE_LDS_ASSUME.

compute pipeline before with this PR
2da4beb386509b77 refused (E_INVALIDARG), 63 lines created, first bound at frame 2420
02384a60fda6f2d0, 2cc4c197ee29e291, 369cbe906ea72764, 6b82bc7d22016cb5 refused still refused
host pipeline shaders=[compute 2da4beb386509b77]
first bind ... stage="compute" size=4920 hash=2da4beb386509b77

There 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=1 and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants