d3d12(hwrt): scale BLAS budget up to 6 GiB with DXGI VRAM pressure throttling (D3D12-HWRT-BLAS-BUDGET) #3225
Closed
github-bot
wants to merge 1 commit from
github-bot/gh-3225 into main
AGit
pull from: github-bot/gh-3225
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3225
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3225"
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?
@teamallgit on GitHub · 2026-12-02 20:48 UTC · original
teamallgit:pr/hwrt-blas-budget→main· +177 −19 · 2 files · 1 commits · closed without mergingClaimed in the coordination issue as: D3D12-HWRT-BLAS-BUDGET (#2570)
Fixes: #3135
What and why
d3d12/crates/leonida-gpu/src/hwrt.rspreviously clampedBLAS_BUDGET_MOSTto 1.5 GiB (1536 << 20) and only re-read the DXGI local VRAM budget every 300 frames, without throttling active BLAS or scratch/instance spares when live DXGI VRAM usage rose. On 24–32 GB GPUs (e.g. RTX 4090 / 5090), the 1.5 GiB cap caused continuous BLAS eviction and multi-second host-side rebuild stalls while driving (#3135).This change:
BLAS_BUDGET_MOSTfrom 1.5 GiB to 6 GiB (6144 << 20) so 10% of the DXGI local budget scales naturally on high-VRAM GPUs (~2.2–2.4 GiB on 24 GB cards, ~3.0–3.2 GiB on 32 GB cards) while staying unchanged on 8–16 GB cards.blas_budget_for_usage(local, used, override_bytes)(overflow-safeu128ratio checks) to tighten the BLAS budget under live DXGI VRAM pressure (>=85%-><=768 MiB,>=90%-><=512 MiB,>=95%->256 MiB) and refreshes every 60 frames (BUDGET_LOOK_FRAMES = 60).spare_limitonLeasePool<T>enforced insidegive()and updated on every budget tick (set_spare_limit()), trimming largest idle scratch/instance spares down to96 MiBat>=85%and64 MiBat>=90%(and restoring256 MiBonce pressure clears), retiring resources outside both locks.LEONIDA_HW_RT_BLAS_MB(minimum 256 MiB, overflow-safe) for explicit BLAS cache sizing and documents it ind3d12/docs/switches.md.Tested
Rebased on
main(8d82a34ae), commitbce6a5b15:cargo test --locked -p leonida-gpu --lib hwrt -- --test-threads=1— 24 passed, 0 failed (covers 6 GiB scaling,85%/90%/95%/ over-budget /local == 0boundaries,parse_blas_budget_mbedge cases, andLeasePooltrim + activegive()capping).LeasePool::give()active spare enforcement,switches.mdcount/prose alignment, and parser unit tests; all fixed and re-verified).GPUs tested: n/a (synthetic CPU-only unit tests on Windows 11; no GPU or game files required)
AI-assisted: yes (authored with Gemini in Antigravity and audited by a separate read-only reviewer subagent)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rules added)@merzleckeier on GitHub · 2026-12-02 20:52 UTC · original · reviewed
Source and CPU policy check on
bce6a5b1. Using the exact budget helpers with a local budget of 24,000 MiB, repeated samples one byte below and at 85% alternate the BLAS limit between 2,400 and 768 MiB and the spare limit between 256 and 96 MiB. The existing eviction path evicts toward 90% of the current BLAS limit and rebuilds a retained recipe if it is named again. Since #3135 is about repeated eviction and rebuilding, can you check what happens across repeated pressure crossings and either show the cache remains stable or add a slower recovery threshold? A single boundary test does not exercise that interaction. I ran the extracted CPU policy only, with no GPU or game workload. AI-assisted.@fiestorra on GitHub · 2026-12-02 21:39 UTC · original
VERIFY-3225 — Windows nativo: el presupuesto de BLAS y sus topes, con control que muerde
(this PR)b41763227= currentmainmain—merge-treeclean,git merge --no-ffcleanRan
The one failure is this machine's, unchanged all day (
views_are_made_beside_the_heap_and_copied_in, the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).Negative control (synthetic — the tests ship with the change): I made
blas_budget_for_usageignore its override argument under a test variable, rebuilt and ran →FAILED: blas_budget_tightens_under_vram_pressure_and_respects_override,assertion left == right failed: explicit LEONIDA_HW_RT_BLAS_MB override wins. The test bites.First control attempt, recorded because it was wrong: I patched the env reader (
blas_budget_override) instead of the pure function the test calls, and the test still passed — the test passes the override explicitly (Some(6144 << 20)), so the env reader is not on its path. A control that does not bite is not a control, and I moved it to the function under test.What the change says, from the test's own boundaries: the budget tightens at 85 % (768 MiB), 90 % (512 MiB) and 95 % (256 MiB) of the card's local memory, an over-budget usage is floored at 256 MiB, and an explicit
LEONIDA_HW_RT_BLAS_MBwins but never drops below that floor. Thelease_pooltest covers trimming and the active-spare limit under the same pressure.Stacked, once more
The branch carries #3204's
frame.rs(CAP_UNREAD), so merging it lands #3204 too — the fifth stacked branch tonight.What I could not test
blas_budget_for_usageand the lease pool with synthetic numbers; the GPU's own usage is not measured here.Written with an AI assistant.
@x2Tweek on GitHub · 2026-12-02 21:51 UTC · original
Game run on the RTX 5090 from #3135, with this PR and without my local 6 GB override.
Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main
0d7a451abplus #3113, #3182 and #3204, diag build. This PR merged on top atbce6a5b15, withLEONIDA_HW_RT_BLAS_MBunset. Series X profile, 3840x2160 output, render scale 0.6667,-HardwareRT -SmoothMotion -PrecompileAll -Log, fullscreen. About 5 minutes of city driving.Tests:
cargo test -p leonida-gpu --lib hwrtgives 25 passed and 0 failed.Budget and throttling: the budget came out at 3141 MB (10 % of the card's 31.4 GB). Late in the drive,
with the card at about 24 GB in use, it was trimmed to 3034-3040 MB. Live BLAS memory peaked at about 2.5 GB.
Not one BLAS was evicted for the budget ("evicted 0 (0 MB), 0 evicted now" on every line), against continuous
eviction at the 1.5 GB cap.
time. So 3.1 GB is enough on this card for this drive.
budget stood at 3141 MB with 0.8-1.3 GB live, and the card was idle. New host pipelines were being made around
the second one, so they look unrelated to this PR, but I have not proven it. The local 6 GB run had none, on a
different drive.
From my side, this PR fixes what #3135 reported.
AI-assisted: the build, the test run, the log reading and the write-up were done with Claude Opus 5.5 (Claude
Code); the numbers are the runtime's own log lines from the run above.
@MoonEyes on GitHub · 2026-12-02 22:00 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@lixonik on GitHub · 2026-12-02 22:25 UTC · original
RUN (in game, RTX 5070 12 GB, Hardware RT, 315 s in-world gate) -- PASS on head
bce6a5b15(merged cleanly viagit merge --no-ffontomain8877be372).Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)
python -I scripts/check_no_game_data.py-> PASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md-> PASSLEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --features diagnostics --lib --locked hwrt-> 24 passed, 0 failedcargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-> PASSLive In-Game Gate (
-SeriesS -NoFrameGen, Hardware RT:LEONIDA_HW_RT=1,LEONIDA_AMBIENT=0,LEONIDA_RT_RESOLVE=1,LEONIDA_ACTIVATE_RAYS=1)315 sin world (500.0 stotal,64world samples>= 1000draws, max5,697draws)0/0/0d3d12_run_fps.py): median25.4 fps(39.4 ms; slowest tenth17.7 fps, fastest tenth26.5 fps;3000-4999draws median25.4 fpsacross54samples)hardware DXR 1.1 RT manager initialized (LEONIDA_HW_RT=1) tier=11, adaptervram_budget_mb=11176hardware RT BLAS memory: dynamic budget tracked1078..1117 MBon this 12 GB card, peak live531 MB(4,987BLAS),0evictions (0 MB),929 MBfreed past fence,39,210TLAS marks read /0lostBLAS live 5198(built 19075,refit 343974,refit->rebuild 1149,rehydrated 3312),TLAS live 5(builds 39230),AS memory 532 MB,lifted shaders 14(0software fallbacks)AI-assisted: yes (Antigravity -- Gemini 4 Neon).
@MoonEyes on GitHub · 2026-12-03 07:01 UTC · original
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 09:17 UTC · original
#3225rebasado y empujado:pr-3225-rebased=e7fab42a5— y el recuento no está adivinado: está calculadoEl conflicto era la línea del recuento (
main684/644, su base 683/643), pero esta vez podía derivarlo en vez de elegir:Y su PR añade una fila (
LEONIDA_HW_RT_BLAS_MB, con frase en la última columna), así que el número que toca es 685/645 — y no hizo falta creérmelo: después de insertar su fila, contar el fichero dafilas 685 · con frase 645ycoincide: True.Lo que eso cambia respecto a
#3308: allí tomé la línea demainporque su PR no añadía filas; aquí su PR sí añade una y la cabecera es una función del contenido, así que hay que recalcularla. La receta «tomar la demain» es correcta sólo cuando la PR no añade un interruptor.Los números del rebase:
Y
717contra los715demain: dos tests nuevos, medidos en el diff —hwrt.rstrae los suyos, y son de los que se pueden correr sin el juego (presupuesto de BLAS contra VRAM).Lo que no verifiqué: el comportamiento con una tarjeta real — el presupuesto de BLAS depende de la VRAM y de la presión de DXGI, y aquí sólo se prueba con lo que el test simula.
@merzleckeier on GitHub · 2026-12-03 09:24 UTC · original
I independently replayed
bce6a5b15ontod9b618f1. The only merge conflict was theswitches.mdheader. Resolving it to 685 runtime names and 645 with descriptions produced a page byte-for-byte identical to what the sources generate. The full catalog checker from #3308 passed, along with all 22 catalog tests. Keeping the current main header (684/644) made that checker exit 1. This verifies the proposed documentation resolution on a local replay. GitHub still shows the original PR head as conflicting. AI-assisted with OpenAI Codex.@MoonEyes on GitHub · 2026-12-03 18:03 UTC · original
Thanks for the work on this. This pull request has a merge conflict with the current
mainand has had no new commit, comment or review for more than 5 hours, so I am closing it to keep the list of open pull requests manageable. This is not a judgement of the change. Whenever you like, merge the latestmaininto your branch, resolve the conflict, and reopen it (or open a new pull request that links this one). Please re-run the relevant tests on the new head; a reviewer will look at it when time allows, with no guarantee of timing or outcome.Generated by Claude Code
Pull request closed