leonida-shader: time group packing on the card (SHADER-PACK-TIMING); GPU tests prefer the high-performance adapter #2620
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2620"
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?
Imported from ubiquitarianism/leonida. Originally posted by Param-2811 on 2026-11-29T18:09:29Z.
Claimed in the coordination issue as: SHADER-PACK-TIMING (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7260250260)
What and why
Host::newpicks the high-performance adapter first (EnumAdapterByGpuPreference), then falls back to the default adapter as before. On a laptop with both an integrated GPU and a card, the default adapter is the integrated one, so the GPU tests ran there.TIME_REPEATS, test-only:Host::dispatchruns the dispatch n times between two GPU timestamps, with a UAV barrier after each, and stores the microseconds per dispatch.pack_tests::packing_times, ignored by default: the pack tests' 32-thread console program, run unpacked and packed ×2, ×4 and ×8 over 1,024, 8,192 and 57,600 groups. Every run's stores are checked against what the console would store.Run it with:
cargo test -p leonida-shader --features host --lib packing_times -- --ignored --nocaptureThis does not turn packing on. In #1608, djrolfes's in-game A/B on an RTX 3070 Ti (Wine, VKD3D-Proton) got slower with
LEONIDA_GROUP_PACK=4: GPU wait went from 8.7–14.5 ms to 25–52 ms. The program timed here is the best case (16 VGPRs, almost no arithmetic). The test is a way to check a packing rule on a card before a game run, for example packing only the programs under some VGPR count.Tested
RTX 4060 Laptop GPU (8 GB, Ada), driver 621.01, Windows 11 build 26300. Four runs, the least of three per point, in µs per dispatch:
cargo test -p leonida-shader --features host --lib: 365 passed, 0 failed, 5 ignored, on that card.rustfmt --check.scripts/check_no_game_data.pypasses on both files.GPUs tested: NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.01, Windows 11 (build 26300)
AI-assisted: yes (Claude)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator rule)Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T18:25:08Z.
Independent
packing_timesrun onfe5a7a8amerged ontomain4755667f. CachyOS, Wine 11.22, VKD3D-Proton71cae091, DXVK3.1.1-97-ga78a467cadb22be-pcos, cross-builtdiagprofile. With both adapters visible and no device-name filter, the benchmark selected the RTX 4070 SUPER. I then kept both ICDs loaded and selected each adapter by its DXVK name. Three runs per GPU, using the test’s minimum of three for each data point. Every synthetic output comparison passed.At 1,024 groups, ×4 was consistently slower for 32×1×1 on the RTX (0.95, 0.94, 0.94) and both shapes on Radeon (0.91–0.92). At 57,600 groups, ×4 was near parity across both GPUs and shapes (0.97–1.04). These timings cover the synthetic dispatch benchmark only.
The focused regression run (
emit::pack_tests::) passed all nine regular tests on both revisions.packing_timesis ignored by default. The full base suite reached the time limit and I ended the full PR run to run the matched subset.AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T18:28:57Z.
Independent native Windows 11 + AMD Radeon RX 7900 XTX (
gfx1100, driver32.0.32029.2010, Ryzen 7 7800X3D with integrated Radeon graphics also present, Windows 1110.0.26200) check offe5a7a8afmerged cleanly ontomain4755667f5(no game files):cargo test -p leonida-shader --lib emit::pack_tests -- --nocapture->9 passed; 0 failed; 1 ignored(2.71 s).cargo test -p leonida-shader --lib emit::pack_tests::packing_times -- --ignored --nocapture->1 passed; 0 failed(1.36 s); high-performance adapter selection cleanly picked the discreteAMD Radeon RX 7900 XTXover the integrated GPU:emit/host.rsoremit/pack_tests.rs.AI-assisted: Antigravity (Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-29T20:34:26Z.
Native D3D12 verification on RTX 4090 (NVIDIA 616.64, Windows 11 build 26300, MSVC, Rust 1.98.1). I tested
fe5a7a8afmerged cleanly withedf0ff5d0(tree510ad978). With the Windows SDK 26100 x64dxil.dll(product version 1.9.2602.17), the pack subset passed 9 of 9 regular tests, and four explicitpacking_timesruns passed every synthetic output comparison. The benchmark reported the RTX 4090 as the selected adapter.×8 led at 1,024 groups and was slower than ×4 at 8,192 and 57,600 groups for both shapes. These are synthetic dispatch timings.
One Windows setup finding. The automatically selected SDK 19041 x64 validator (10.0.19041.5609) gave
0xc0000005before a timing result. The CPU-onlya_packed_program_names_its_grid_and_the_group_size_the_console_hasalso exited with0xc0000005with that DLL on both unmodifiededf0ff5d0and the merged tree. Both binaries passed that test with SDK 26100 selected viaLEONIDA_DXIL. This isolates the observed failure to the validator selection, independent of GPU execution.AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by ammonium231 on 2026-11-29T21:24:19Z.
RTX 3090 / 621.40,
fe5a7a8afmerged onto mainedf0ff5d0: pack_tests pass, packing_times runs on the 3090 (4 runs). Steady gain at 8192 groups: k4 1.92–1.94x for [32,1,1], 1.65–1.87x for [8,4,1]. At 57600 it's noisy run to run ([32,1,1] k4 0.56–1.07x), with no consistent gain or loss.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T21:43:11Z.
Partial check by OreoFR on macOS 27.2.1 (26B131), Apple M5, Rust 1.98.1 (d3d12/rust-toolchain.toml), main
060c47160(merges cleanly; does not force a rebase of #2566 ateade9562c), PR headfe5a7a8afemit/host.rsiscfg(all(windows, ...)),pack_tests.rsiscfg(all(test, windows)); the newpacking_timestest is also#[ignore]), so nothing this PR changes is compiled on macOS: leonida-shader 224 passed / 2 ignored on both main and merge.EnumAdapterByGpuPreferencefalls back cleanly toNone;TIME_REPEATSiscfg(test)only. No game data. Several positive native-hardware reports in the comments.Verdict: not testable on macOS (no red possible here); Windows type-check clean.
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by ammonium231 on 2026-11-29T22:57:53Z.
20 more runs, same tree: medians at 57600 are [32,1,1] k2/k4/k8 1.07/1.07/1.11x. [8,4,1] 57600 is bimodal (~37–50 vs ~80–94 us) for k0 and packed alike, so the earlier 0.5x reads as a slow-mode sample, not packing.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T22:58:18Z.
Verified by OreoFR (Windows part; oreofr-mac covered leonida-shader on macOS, where all of this PR is compiled out)
PR head
fe5a7a8afmerged withgit merge --no-ffonto main060c47160, no conflict. Windows 11 Pro 10.0.26300, RTX 4070 Laptop 8 GB + Intel Arc integrated graphics (a laptop with two adapters, the case the adapter change is for), NVIDIA 621.40, Rust 1.98.1. The GPU is used.cargo test -p leonida-shader --locked: 368 passed / 0 failed / 5 ignored (main 368/0/4; the +1 ignored ispacking_times). All 9 regularpack_testspass.packing_times(--features host -- --ignored --nocapture): passes, every output comparison matches,timed on NVIDIA GeForce RTX 4070 Laptop GPU. At 8 192 groups, k2/k4 give 1.47 to 1.49x for [32,1,1] and 1.42x for [8,4,1]. At 57 600 groups the gain is 1.00 to 1.06x, and k8 is slower at 1 024 groups of [8,4,1] (0.78x).#[ignore]and a benchmark. I also ran it with only the adapter hunk ofemit/host.rsrestored to main: it still ran on the RTX 4070 Laptop here (the default adapter of this machine is already the NVIDIA card), so this laptop does not show the difference the change is meant for.eade9562c) rebase needed after this: no (git merge-treeis clean).Verdict: NO RED (green on Windows, benchmark runs on the discrete card).
This verification was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T15:57:00Z.
Verified: PR head merges cleanly with main; 368 passed / 0 failed / 5 ignored for leonida-shader, with 9 pack-tests passing. Independent GPU checks passed on NVIDIA, AMD and Radeon hardware; synthetic benchmark reports are positive where applicable. No game data. AI-assisted review/verification.
Imported from ubiquitarianism/leonida. Originally posted by Default0009 on 2026-12-03T00:09:18Z.
Card: RTX 2070 Super 8 GB (Turing), Windows. packing_times run as cargo test -p leonida-shader --features host --lib packing_times -- --ignored --nocapture, on clean main (
f3865cae8), debug test build, clocks not locked. Least of three runs, microseconds per dispatch, speed-up against unpacked:On Turing the common 32×1×1 shape gains 1.0–1.13× (against 1.5–1.8× on the RTX 4060 Laptop in the PR), and ×8 is slower at 8,192 groups. The one large gain is 8×4×1 at 8,192 groups, where the unpacked time is unusually high. This is MEASURED once, on a 16-register program, so it is the best case. It says nothing about the heavy programs, and 554 programs use over 128 registers.