d3d12(hwrt): scale BLAS budget up to 6 GiB with DXGI VRAM pressure throttling (D3D12-HWRT-BLAS-BUDGET) #3225
Closed
leonida/mandy
teamallgit wants to merge 0 commits from
pr/hwrt-blas-budget into main
pull from: pr/hwrt-blas-budget
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
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
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3225
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/hwrt-blas-budget"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: D3D12-HWRT-BLAS-BUDGET (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7358311451)
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)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.
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.
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).
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).
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).
#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.
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.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