Skip to content

recomp: cap per-lane compute size so giant shaders use compact DXIL (#2203) - #2341

Open
zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-size-cap
Open

zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:recomp/per-lane-size-cap

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What is in it
Follow-up to #2203 addressing @tiagonleal's XCL_PER_LANE=1 memory-spike report on giant compute programs (such as 56c0cd3b82a00c6e):

  • After recomp: enable whole-wave branches and dead-SCC elision in split wave64 #2203 enabled whole-wave branches in split-wave64, 56c0cd3b82a00c6e (488,744 B guest code, 14,377 blocks) became accepted by recomp::lower_dxil::compute_with. Because the per-lane form has no compact loop-switch lowering, it emitted 4,563,088 B of plain DXIL (9.5× larger than gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's 478,764 B compact form), causing the NVIDIA driver compiler to spike +18 GiB RAM and OOM.
  • Adds two caps in crates/xcl/src/gpu/recomp/lower_dxil.rs:
    • MAX_INSTS = 20_000 (matching dxil::compact::large's 20,000-instruction threshold): checked right after decode before spawning the 256 MB worker thread or constructing IR, so giant programs immediately fall back to gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's compact form.
    • MAX_DXIL_BYTES = 1 << 20 (1 MiB): post-lowering safety cap in compute_with (all 39 normal per-lane compute shaders in the 2,000-program sample are <= 197 KB).
    • Modifying lower_dxil.rs advances XCL_PER_LANE_SOURCE_ID automatically so any cached multi-megabyte per-lane entries are invalidated on disk.
  • Adds unit test compute_with_refuses_giant_programs_for_compact_fallback covering both caps.

Impact:

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti (driver 621.01), AMD Ryzen 5 7500F, rustc 1.100.0, DXC / dxil.dll 1.9.2602.17, debug & release builds.
  • cargo test --workspace -- --test-threads=4 on 45dbd47: 1436 passed, 0 failed, 47 ignored across 37 test binaries (29 runtime SKIPPED notices from adapter-gated tests); the new compute_with_refuses_giant_programs_for_compact_fallback passes.
  • The translation runs below (--hash, --sample 2000) were done on the pre-rebase head 92437bd; the rebase only merged this PR's test next to a new test in lower_dxil.rs (no code overlap).
  • xcl shaders <pack> --direct --hash 56c0cd3b82a00c6e --lanes --split 1: refused by per-lane (program too large for the per-lane form), compact form 478 KB DXIL, 0 errors.
  • xcl shaders <pack> --direct --lanes --split 1 --sample 2000 --max-bytes 0: 39/205 per-lane compute programs unchanged, 4 giant compute programs capped, 0 validator/panic errors.

Regression run
Baseline (main 568e7db):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR (45dbd47, run with XCL_PER_LANE=1):

xcl-smoke v1
commit: 45dbd47ccdfc6cc7daf14e30700b440c07cb77ef
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1620)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15805 MB

Not tested

  • AMD / Intel Arc GPUs; 300-second extended menu soak with XCL_PER_LANE=1 (verified via single-hash 56c0cd3b82a00c6e routing to compact form + 60-second XCL_PER_LANE=1 smoke run).

AI use

  • Antigravity (Gemini 4 Neon) assisted with measuring 56c0cd3b82a00c6e and the 2,000-program per-lane size distribution, implementing MAX_INSTS / MAX_DXIL_BYTES and the unit test in lower_dxil.rs, and running the test and smoke suites.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

No Linux/Wine report in the thread yet; adding one.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@razormontana

Copy link
Copy Markdown
Contributor

Independent RTX 3070 check of clean PR head 92437bd3ebc7df5504604247055acd93e57fc46f.

Windows 11 Pro build 22631, Core i7-10700K, GeForce RTX 3070 (driver 617.42), Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, release build.

The workspace suite reported 1,273 passed, 0 failed, 46 ignored. Its pass count includes 26 runtime SKIPPED markers (21 native wave64, 3 unsupported per-lane forms, 1 heap-window capability, and 1 reserved cube with mip levels). compute_with_refuses_giant_programs_for_compact_fallback passed, including the 20,000-instruction cutoff and the 1 MiB DXIL size boundary. Coverage here was the synthetic workspace suite with external samples unset.

cargo build --release --offline --locked --workspace
cargo test --release --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output

Codex (GPT-6.2) ran the tests and drafted this report.

@tiagonleal

Copy link
Copy Markdown
Contributor

Test report for #2341 on RTX 5070 Ti (Windows 11): the cap works at translation level and its test passes; I could not reproduce the memory spike on the base today, so the in-game effect is not shown

I reported the XCL_PER_LANE=1 memory jump on #2203; this checks the cap you added in answer.

Tested

  • PR head 92437bd3ebc7df5504604247055acd93e57fc46f (clean worktree, no local changes; merge-base with main 082944135cd2b96288470a595861fa608eee08dc, the base compared below). PR open, head unchanged when I started.
  • Windows 11 Pro 10.0.26300 (Developer Mode on), NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42, 32.0.16.1742), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0, release.
  • cargo test --release -p xcl --lib, test executable: compute_with_refuses_giant_programs_for_compact_fallback: 1 passed, 0 failed. gpu::recomp::lower_dxil: 21 passed, 0 failed, 0 ignored, 17 SKIPPED lines (no wave64, and an f16 case already refused in per-lane form). gpu::recomp: 371 passed, 0 failed, 19 ignored, 23 SKIPPED lines.
  • Translation only (xcl shaders <pack> --direct --hash 56c0cd3b82a00c6e --lanes --split 1): on the base the program is accepted in per-lane form, 4 563 088 B of DXIL against 478 764 B in the split form. On the PR head it is refused: program too large for the per-lane form (0 of 1 compute programs in per-lane form), so it falls to the compact form. Translation 0.26 s both ways.
  • In the title, same way as my recomp: enable whole-wave branches and dead-SCC elision in split wave64 #2203 report (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=0 XCL_COHERENT_MB=512 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_GPU_PROFILE=1 XCL_PER_LANE=1, A pressed at 30 s, 300 s, fresh executable name, own copy of the compute cache per run, memory guard on and unchanged): PR head and base both ran the full 300 s at 30 fps in the menus, process commit peak 16.3 GB (PR) and 16.1 GB (base), no guard cut, no device removal. The 4.27 MB driver compile of 56c0cd3b82a00c6e did not start in either run today, so this run does not show the spike on the base, and says nothing about the cap. (Two earlier runs with XCL_PSO_PRELOAD=0: 14.7 GB both, same.)
  • The driver compile alone (xcl shaders <pack> --measure-pso 56c0cd3b82a00c6e, guarded, per-lane and heap windows on, 300 s budget each): PR head and base looked the same, working set 2.2-3.9 GB through the whole 300 s, still compiling at the budget in both, no spike in that window.
  • Sample of the pack, --lanes --split 1 (200 sampled records, 14 compute programs): per-lane form 3 of 14 on both the PR head and the base, same DXIL size per instruction, so the new caps change nothing in that sample.

Not tested

  • That the memory spike is gone with the cap: I could not reproduce it on the base today (the giant is no longer compiled in my menu runs), so a before/after in the title is missing. My earlier spike was measured on 5478c4a7.
  • The 2,000-program claim (only the 200-record sample above), world runs, AMD, runs longer than 300 s.

Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 92437bd3ebc7df5504604247055acd93e57fc46f (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1271 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's test passed: gpu::recomp::lower_dxil::tests::compute_with_refuses_giant_programs_for_compact_fallback.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 92437bd3ebc7df5504604247055acd93e57fc46f
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1604 (PresentX 1604)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14365 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source-level defect found. Giant-program refusal occurs before per-lane lowering and falls through to the existing direct_compute translator/auto-compact path; cache identity invalidates stale per-lane results. Current Windows CI and AMD smoke evidence are green. Nonblocking coverage gap: unit tests stop at refusal rather than proving end-to-end direct_compute fallback accepts the giant program, though external translation evidence covers it. I found no blocker.

@zondy1i
zondy1i force-pushed the recomp/per-lane-size-cap branch from 92437bd to 45dbd47 Compare November 26, 2026 02:52
@zondy1i

zondy1i commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (b49be183); the only conflict was in the test module of lower_dxil.rs (both sides appended a test at the end, kept both). Re-ran the full workspace suite (1436 passed, 0 failed) and a 60 s XCL_PER_LANE=1 smoke on the new head 45dbd47; description updated with the new smoke block.

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.

7 participants