Recompiler: compact dispatch can switch in two levels (XCL_COMPACT_NEST) #1692
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1692
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1692"
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?
@Pipodi on GitHub · 2026-11-24 19:20 UTC · original
Pipodi:compact-nest→main· +2477 −55 · 8 files · 7 commits · openStacked on #1448 (
80fac65, itself on #13165328b15); only the top two commits (2e54124,2046259) belong here.The compact form's dispatch loop is one
switchover every case. All cases fall through to one merge block, which has a predecessor per case and a phi operand per predecessor for each of the ~147 loop-carried registers. OnActivateRays(2,516 cases), that is 436,656 merge operands. The NVIDIA driver's time and memory follow them: about 165 s and 8.2 GB for one cold pipeline build (#1269 result).XCL_COMPACT_NEST=<P>(a power of two up to 65536; off when unset or 0) switches oncase >> log2(P)first. Each group of P cases has its own innerswitchand ends inxcl_nb = min(xcl_nb, <blocks>u). Theminstops DXC from folding the groups' exits back into one merge. Without it, the 147 × 2,910 merge comes back. This PR adds the switch, off by default. Turning it on above a case count is a separate PR, after measurements on more programs and GPUs. Part of #1269.What is in it
crates/xcl/src/gpu/recomp/compact.rs:compact_withtakes the group size, andcompact()reads it fromXCL_COMPACT_NESTonce.crates/xcl/src/gpu/recomp/pso.rs: the translated-shader disk cache names a nested compact entry_c_n<P>instead of_c, so a warm flat entry is never loaded for a nested run, or the other way round. Names with the nest off are unchanged.compact::tests::nested_dispatch_groups_the_cases: P = 2, 4, 8, 16, with ceil(cases/P) inner switches, every case once, oneminper group, and the flat text with P = 0.tests_compact::gpu_compact_nested_dispatch: the GPU A/B againsttranslatewith P = 2 and 4, on the synthetic programs (now with #1448'smany_targets, whose case has the[branch] iftree of selects), in every form the adapter runs.compact_sample_big_cs_nested_dxilon the existingXCL_SAMPLE_BIG_CShook: DXC only, nested DXIL under 80 % of the flat compact form's.95e8abc(tests only):nested_matches_flatchecks the nested HLSL against the flat one. The text around the dispatch is the same, the case number is the flat switch's expression, case k sits in group k >> log2(P) with the flat case's address and text, and every group ends inmin(xcl_nb, n)with the loop's own n.nested_dispatch_runs_the_flat_casesruns it on the synthetic programs (P = 1 to 32, both table packings) and checks that it catches a case moved to another group, a changed case text and a changed bound.compact_sample_big_cs_nested_runs_the_flat_casesruns it onXCL_SAMPLE_BIG_CS(CPU only, P = 16, 32, 64).Dispatch::of) reads the nested form too. WithXCL_COMPACT_NESTset for the whole run, the compact tests now check the nested form instead of stopping at the flat switch line (@einfachama found 15 of them doing that).Tested
rustc 1.100.0.2046259(onmainafc5ee8through #13165328b15and #144880fac65), debug:cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4gave 1298 passed, 0 failed, 46 ignored, in 23 result blocks.2e54124's patch is the same as at6ce972cand9c09c8f; only the base moved.9c09c8f(not rerun):cargo test -p xcl --lib compact -- --test-threads=4withXCL_COMPACT_NESTunset,=32and=2: 33 passed, 0 failed, 0 ignored each (SKIPPEDgpu_compact_native_wave64_form: no wave64).lower_dxilper-lane f16/f32 cases (refused by the per-lane form, as onmain); 3 cases that need the D3D12 debug layer / SDK layers, which this machine does not have;heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).compact_withmade to ignore the group size,nested_dispatch_groups_the_casesandgpu_compact_nested_dispatchfail. The GPU test fails on its HLSL-shape assert; its results would be equal either way.xcl shaders <record> --precompile --only cs, a newXCL_DXIL_CACHEper run, on records of three compute programs from the retail title:XCL_COMPACT_NEST=32b370923)b370923. These DXIL numbers were measured at00f10ee, the same patch before the rebase onto #1448's select bound. The bound changes the text ofActivateRaysin both forms (#1448: 2.85 → 2.89 MB flat), so the table is not this head's; it was not rerun.compact_sample_big_cs_nested_dxilon two of these programs (the test's options differ from the precompiler's) gave 874,064 → 566,372 B (65 %) and 811,152 → 516,816 B (64 %). Both pass.ActivateRaysat P = 32 built cold in 37.7–38.2 s with a 1.5 GB peak, against 163–169 s and 8.2 GB flat, on this GPU (#1269 result). That was not rerun on this commit.Regression run
The retail title, 60 s,
XCL_PRESS_AT=16:A(the title takes A at its title screen 16 s in and loads for the rest of the run), no other variables (the default shader cache, warm from earlier runs). Both runs on this machine, with nothing else running.main06c9f55:This PR, head
2046259:The PR's run got 113.4 % of
main's frames and 102.3 % of its peak commit.Not tested
ActivateRaysin the heap form in 31.8 s against 312 s flat. On Linux / RADV (RX 9070 XT), @St5sz2Jk found the nested form slower in the driver: 244 s and a 45.5 GB peak, against 70 s for the flat form with @0naku's switch-tree patch. On an RTX 4060 8 GB, @einfachama builtActivateRaysnested in a title run in 24.9 s from cold. On AMD and RTX 5090, @nnonno91 ran the GPU tests, including the packed table.95e8abc's check compares their nested and flat HLSL whenXCL_SAMPLE_BIG_CSis set; I did not run it with the variable set on this head.9c26337, stacked on #1448's old head42b2f11): it builds the dispatch from the decoded instructions, not from the HLSL (@t4l03's correction). Both PRs changecompact.rsandpso.rsand conflict there (git merge-treeof9c26337and7123faa), so whichever merges second has to reconcile the dispatch emission and the cache names. The two have not been run together.AI use
80fac65), ran the suite on this head, read the diff and wrote this description. A second Opus 5.5 agent reviewed the diff, and another reviewed95e8abc.🤖 Generated with Claude Code
@nnonno91 on GitHub · 2026-11-24 19:35 UTC · original
Independent Windows GPU check of commit
00f10eeceb4b58738610a2138c4361d5f5a69582. Nested dispatch with a densely packed table matched the reference on both AMD and NVIDIA.Tested
XCL_ADAPTER=AMD Radeonand the default compact settings,cargo build --workspace --lockedsucceeded.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 888 passed, 0 failed, 42 ignored. One of the reported passes logged an explicit skip,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.tests_compact.rsand rancargo test --locked -p xcl --lib -- gpu_compact_dense_nested_dispatch --test-threads=1 --nocaptureonce per adapter. Each run reported 2 passed, 0 failed, 0 ignored and no skips. Both used wave32, plus native wave64 on AMD or split wave64 on NVIDIA.gpu_compact_nested_dispatchto callcompact_withwithheavy=0,dense_above=0and groups of 2 or 4. The generated HLSL used both word-spanning extraction and nested switches. Its table data matched the flat dense form (nest=0). Each adapter ran 32 nested kernel configurations across the default and unstructured translation options, matching 4,235,392 result bytes againsttranslateand the flat dense form. The fixture tables contained 28 word-straddling entries across program/form pairs.gpu_compact_compute_dispatchfixture. All four nested compute configurations per adapter matched a CPU calculation for all 256 thread stores and preserved 16 sentinel dwords. Both GPU controls matched the same calculation. The worktree was restored after the targeted checks.Not tested
Retail output, cold compile timing, Intel, or Linux. The combined check forced the packing and grouping through
compact_with.AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) adapted and ran the temporary tests, verified the logs, and wrote this report.
@Pipodi on GitHub · 2026-11-24 19:36 UTC · original
@nnonno91 thanks. Your report covers one of the PR's Not tested points: the nested form with a packed table. You ran it on the GPU and it matched the flat dense form on AMD and NVIDIA, in wave32 and in native wave64 on AMD. That's a check the 4090 here can't make (no wave64). The other points are still open: retail programs on the GPU, AMD timing, and the merge order with #1548.
AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Pipodi on GitHub · 2026-11-24 20:03 UTC · original
@brothernog thanks, that's the first run of #1692 on a retail program on a small card. In the heap form, the driver went from 312 s to 31.8 s and its peak from 3,962 to 850 MB, and both pipelines were accepted. That is about 10× here against 4.4× on the 4090, so the small cards gain the most. On the 4090, the grid in #1269 (7142472413) puts the driver's time at about merge operands^0.8 × blocks. Yours looks steeper than that on this card. I'll use your table as the 8 GB data point when PR 2 (on by default above a case count) is measured.
Note: #1692 is now in conflict with
mainthrough #1316 (#1524 changedconsole_translationinpso.rs). I'll rebase it after #1316's next head.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@Pipodi on GitHub · 2026-11-24 20:20 UTC · original
Rebased onto #1448's new head
42b2f11(on #1316f207df1, onmain85e3826). The new head is7123faa. The commit's patch is the same as00f10ee's, so the tests and measurements made at00f10ee(@0naku, @nnonno91, @brothernog) cover the same code.main85e3826reached 102.7 % ofmain's frames and 99.3 % of its peak commit, with no crash or device removal.The description has the new counts and both blocks.
AI use: Claude Code (Claude Opus 5.5) rebased and wrote this comment. A Claude Sonnet 5.5 subagent ran the suite and the smoke runs.
@t4l03 on GitHub · 2026-11-24 20:30 UTC · original
@Pipodi a clarification for the compatibility note in the description: #1548 at
9c26337collects operands from decoded instructions, groups the block bodies, and only then emits the dispatch switch. Reading the emitted switch was part of the earlier HLSL prototype. I checked the two public heads (9c26337and7123faa) withgit merge-tree; they do conflict incompact.rsandpso.rs. Whichever lands second will need to reconcile dispatch emission and cache names. We have no measurements with both options enabled yet.AI use
Codex (gpt-6.2-sol) checked the source and merge tree and drafted this note.
@Pipodi on GitHub · 2026-11-24 20:31 UTC · original
@t4l03 thank you, you're right. #1548's own commits on top of #1448 (
c934db6,8891798,9c26337) build the dispatch from the decoded instructions and don't parse the HLSL. I've corrected the line in the description. It now says that the two PRs conflict incompact.rsandpso.rs(I see the same withgit merge-treeof9c26337and7123faa), that whichever merges second reconciles the dispatch emission and the cache names, and that they haven't been run together.AI use: Claude Code (Claude Opus 5.5) checked the merge tree and #1548's commits, and wrote this comment.
@einfachama on GitHub · 2026-11-24 21:41 UTC · original
Test report for #1692 with
XCL_COMPACT_NEST=32and heap windows, in title runs of my retail title on an 8 GB NVIDIA card. It covers the "Not tested" item "a title run" for both big programs.15ec6daefb19a780: builds in the driver in 24.9 s from cold, where the other forms I tried on this card did not finish.56c0cd3b82a00c6e: builds in 10.5 s.Setup
mainb9b6ea6(#1288 and #1524 are in it) + #899f3b7dd6+ one local log line (what a bind waits for, logged at the start of the wait; not part of any PR) + #1315 / #13165749171+ #132169a892c+ #1448b370923+ #169200f10ee.resolve_wait_for: both kept,_heldset from #899'salready.main'spub(crate) console_translation: #1316's version kept aspub(crate); the twomaincallers (console_hlsl,measure_pso) passCompactCs::get(), as #1316 does forconsole_to_hlsl.prepare():let program = code;at the top oftranslate.7123faaand #1448's42b2f11have the same patch ids as00f10eeandb370923.XCL_HEAP_WINDOWS=1,XCL_COMPACT_NEST=32,XCL_COMPACT_CSunset (auto),XCL_NETWORK=0,XCL_RUN_SECONDS=420, thread dumps at 100, 130, 160, 200, 260, 340 s. A pressed at 26 s and 30 s; the world load starts by itself at ~66 s.compact30 (SKIPPEDgpu_compact_native_wave64_form: no wave64),nested5,shared_targets1,dense_table1;oversized_structured1,memory_windows7,heap_window2,pso_async8,big_compile8.XCL_COMPACT_NEST=32set for the whole test run, 15compacttests fail. All stop at the same step: they read the HLSL for the flat dispatch lineswitch ((XCL_BT[xcl_b /, which the nested form replaces, and the GPU tests among them panic there before they run.The two programs, nested, in the title
15ec6daefb19a780(record95cc13288a27a96e)56c0cd3b82a00c6e(code hashd122faa48eb0afdc)76699 instructions, 2280459 B HLSL88863 instructions, 737038 B HLSL15ec6daefb19a780in thepc-block form (#1316 + #1321, compact refused at 9 975 table words): 13 297 372 B of DXIL, ~80 s of DXC. Not finished in the driver after 244–327 s, in 3 runs. Basec160d86with #1288.56c0cd3b82a00c6ein #1316's flat compact form: 983 404 B, 23.9 s in the driver. Same base.mainb9b6ea6with #1316 / #1321, no #1448 / #1692;XCL_DIRECT_DXIL=1withXCL_COMPACT_CS=0forced, which is not the default routing; without it neither program goes to the direct translator):15ec6daefb19a780: 8 360 348 B.56c0cd3b82a00c6e: 13 166 716 B.15ec6daefb19a780had not reached the driver).The title: 5 runs
15ec6daefb19a780or56c0cd3b82a00c6e.Not tested
XCL_COMPACT_NEST), and the flat #1448 form of15ec6daefb19a780on this card.AI use
@St5sz2Jk on GitHub · 2026-11-24 21:47 UTC · original
Test report for #1692
7123faaon Linux / RADV (RDNA4), withXCL_COMPACT_NEST=32. It covers part of the Not tested item "AMD, Intel and dxil-spirv". ActivateRays builds in the title, but RADV takes 244 s and the process peaks at 45.5 GB, against 70 s for the flat form with @0naku's switch-tree patch on the same card.Tested
7.3.5-2-cachyos), Wine 11.22.ec207194(dxil-spirv7c048638),-Db_ndebug=true, with @0naku'sfast_dominatesand recursion-fix patches and aLoopMergeTracerfix (#1269, 7144483258). No switch tree: it makes invalid SPIR-V on some graphics shaders (same comment).main4178e88+ #871b66a150+ #684e56dbc3+ #144842b2f11+ #6405d6fac8+ this PR's7123faa(cherry-picked), release, cross-built forx86_64-pc-windows-msvc.XCL_COMPACT_NEST=32,XCL_DIRECT_DXIL=1,XCL_PAGE_BUDGET_MB=4096,XCL_PSO_TRACE=1.ActivateRays(95cc13288a27a96e)NEST=32spirv-valpasses at default limitsdriver compile finish)The rest of the run
MESA_SPIRV_FAIL_DUMP_PATHstayed empty).+0x23cf683) with 56,524 pipelines queued and none compiling (window overlay at about 1,840 s). That is the scheduling stall described in #1269, not something this PR causes.Not tested: other
Pvalues;NESTwith the switch tree; a cold driver cache for the other programs; repeat runs; RDNA2/3.AI use: Claude Code (Claude Opus 5.5) built the trees and vkd3d-proton, ran the offline conversion, read the logs and wrote this report.
@DavidM1911 on GitHub · 2026-11-24 22:02 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
mainincrates/xcl/src/gpu/recomp/mod.rs— needs a rebase before it can be tested.@brothernog on GitHub · 2026-11-24 20:02 UTC · original · edited 2026-11-24 22:53 UTC
Tested
00f10eeon an RTX 3050 8 GB (desktop, Ryzen 7 5800XT) (NVIDIA 610.88, Windows 11 build 26300, DXC 1.9.2602.17, release), with a retail program. This covers part of the Not tested point "retail programs on the GPU", on a smaller card than the 4090.ActivateRays (
95cc13288a27a96e), translated as the runtime does withXCL_COMPACT_CS=1 XCL_HEAP_WINDOWS=1and the translation cache off. Then a coldCreateComputePipelineStatewith the runtime's root signature and samplers, one PSO per process, one run each:XCL_COMPACT_NESTunset)XCL_COMPACT_NEST=32PeakPagefileUsagefromK32GetProcessMemoryInfo, read right after the PSO call (66 MB before it). It may count differently from your 8.2 GB / 1.5 GB figures.XCL_HEAP_WINDOWS=1); the nested-to-flat ratio is close (0.35 here, 0.36 on the 4090).Not tested:
main(kole's 8 GB run ran out of commit in DXC), other values ofP, and a title run.This comment was AI-assisted.
@Pipodi on GitHub · 2026-11-24 23:20 UTC · original
New head
9c09c8f, rebased onto #1448's new head57d7574, which bounds the select list. The nested emission itself is unchanged. Two test changes are in the same commit:XCL_COMPACT_NESTset for the whole run, 15 compact tests stopped at the flat switch line. The tests' HLSL reader (Dispatch::of) now reads the nested form too. With the variable unset,=32and=2,cargo test -p xcl --lib compactgives 33 passed, 0 failed each, so setting it now runs those tests on the nested form.gpu_compact_nested_dispatchnow also runs #1448'smany_targets. Without it, the nested dispatch combined with the select tree was only compared withtranslatewhen the variable was set.Whole suite on
9c09c8f: 990 passed, 0 failed, 42 ignored. The smoke pair againstmain689f2dbis in the description (89.6 % ofmain's frames, no device removal, no crash). The description also links the three test reports: @brothernog (RTX 3050, 31.8 s against 312 s), @einfachama (RTX 4060, 24.9 s in a title run) and @St5sz2Jk (RADV, slower nested: 244 s against 70 s flat with the switch-tree patch). Thanks to all three.Turning the nest on by default is a separate step, claimed on #1269, after measurements on the ~700-case programs.
AI use: Claude Code with Claude Opus 5.5.
@Pipodi on GitHub · 2026-11-25 00:05 UTC · original
Back to draft: since
mainmerged #1836, #1316 (which this PR is stacked on) conflicts withmaininpso.rs(details). This PR's own commits don't touch that code. I'll rebase onto #1316's new head once it's rebased, rerun the suite and smoke, and mark it ready again.AI use: Claude Code with Claude Opus 5.5.
@Swagi-REDACTED on GitHub · 2026-11-25 05:52 UTC · original
Targeted RTX 3060 result for the exact compute record
95cc13288a27a96efrom A newer retail game. This follows the table-cap fallback seen during world loading with #1316.Hardware: Ryzen 7 9800X3D, RTX 3060 12 GB (driver 621.14), approximately 16 GB RAM, Windows 11 Home 26200. Rust 1.95.0 MSVC; DXC/DXIL 1.9.2602.17.
Tested local integration: main
cbc296ab65a2661a61e3e2da109134bcd5319f60plus #1315/#1316, then only the top commits57d7574(#1448) and9c09c8f(#1692), preserving their authors. Local head2ab922a. This is not an unmodified PR-head test: the integration retains main's shared shader cache and direct-DXIL cached-only deferral, has a one-line current mesh-cache signature adjustment, and an optional private live-input harness.With
XCL_COMPACT_CS=autoandXCL_COMPACT_NEST=32:The serialized
_c_n32cache payload contains 1,068,976 bytes of DXIL. In the preceding #1316-based title run, this record's compact translation exceeded the 8,192-word cap (9,979 words), fell back, and entered driver compilation with 10,896,240 bytes of DXIL. It had not finished when that run was intentionally stopped. This is not a completed before/after timing comparison, or an A/B isolating #1692 from #1448.Validation of this integration:
cargo test --locked -p xcl --lib compact -- --test-threads=4: 38 passed, 0 failed, 0 ignored; 1 explicit native-wave64 skip.cargo test --locked -p xcl --lib gpu::recomp::pso::shader_cache_tests -- --test-threads=4: 19 passed, 0 failed, 0 ignored; no explicit skips.cargo test --locked --workspace -- --test-threads=4: 1,190 passed, 0 failed, 46 ignored, across 21 result blocks; 26 explicit skip events included among passes (21 unavailable native-wave64 paths, 3 unsupported per-lane f16 cases, 1 heap-window-disabled case, 1 PSO measurement requiring Windows Developer Mode). Optional game-sample environment variables were unset.cargo build --locked --release --workspacepassed (46.52 s).Not tested: clean main/head smoke pair; completed gameplay/prologue; other GPUs. A new live world-load test is running separately. No game data is attached.
AI use: Codex, GPT-6 (exact serving variant not exposed), integrated the existing patches and ran/wrote this report. This report claims no authorship of the upstream compact-backend changes.
@Pipodi on GitHub · 2026-11-25 06:03 UTC · original
@Swagi-REDACTED, thank you. This is the first RTX 3060 data point for this record, and it is useful for #1448 as well as this PR.
As you say, this is not an A/B of #1692 against #1448. If your live world-load run finishes, a second report is welcome. I'll rebase the whole stack once #1316 is rebased and post the new heads.
AI use: Claude Code with Claude Opus 5.5.
@itsSio on GitHub · 2026-11-25 09:59 UTC · original
Tested
Independent check requested in #1269, on clean PR head
95e8abcfd8eb2da975255e5ea2c85ed2d812f37f, no local patches or merge. Windows 11 Pro 26200 on both systems, x64 MSVC, unoptimized dev/test with debug info off.cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocaptureboth exited 0 on each system.32.0.16.108832.0.16.1088Both runs logged 21 native-wave64 skips, three per-lane f16/f32 refusals, unavailable driver-cache control and unavailable heap windows. The RTX 2080 SUPER also skipped two D3D12 debug-layer tests (
test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state).Focused
cargo test -p xcl --lib --locked gpu::recomp::tests_compact -- --test-threads=1 --nocapture: 25 / 0 / 0 on the Radeon RDNA2 iGPU (32.0.21043.5001, same Ryzen 7 system), with no runtime skips, and 25 / 0 / 0 on the RTX 2080 SUPER with one native-wave64 skip. This includesgpu_compact_nested_dispatchandnested_dispatch_runs_the_flat_cases; environment settings were left at defaults except for adapter and DXC selection.Not tested
Retail smoke or shader samples, full AMD workspace, RADV, Intel, or compile and gameplay performance.
AI use
Ran via Samaritan:
openai/gpt-6.2-sol): ran both Windows checks, verified the raw results and wrote this report.@DavidM1911 on GitHub · 2026-11-26 00:29 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.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.