mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #380] [CLOSED] HIP: count the desktop's VRAM on Windows (WDDM budget, STRATA_WDDM_BUDGET) #2611
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2611
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/Niko1221/Strata/pull/380
Author: @BlueKingMuch
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:win-budget📝 Commits (1)
07bf060HIP: count the desktop's VRAM on Windows (WDDM budget, STRATA_WDDM_BUDGET)📊 Changes
2 files changed (+102 additions, -0 deletions)
View changed files
📝
include/strata/hip_compat/cuda_runtime.h(+11 -0)📝
src/core/device.cu(+91 -0)📄 Description
On Windows,
hipMemGetInforeports the card's size minus this process's own allocations: ROCclr's PAL backend asks Windows for this process's usage only, so what the desktop and other programs hold on the card is not subtracted. On a card that also drives the desktop the engine counts the ~930 MiB those hold as free,--expert-cache autofills the card past what Windows lets the process keep in VRAM, and WDDM moves part of the engine out to system RAM. On an RX 6800 with setup's configuration this PR takes decode from 30.5 to 41.4 tok/s (medians of 24 requests each).What changes
QueryVideoMemoryInfo). On Windows HIP builds,cudaMemGetInfo, which the HIP shim maps tohipMemGetInfo, now lowershipMemGetInfo's free figure by what the budget withholds: the card's size minus the budget (799 MiB on this card while the process is small, about 1.8 GiB once it holds 11 GiB).--expert-cache autothe existing check after the slots are written does the rest ("only 8 MiB free once the slots are written ... shrinking"), since the budget itself drops once the process holds most of the card (probe below).dxgi.dllis loaded at run time and the card's adapter is found by its LUID, so nothing new is linked. Withoutdxgi.dll, the adapter, or a budget below the card's size,hipMemGetInfo's figure stands.strata: Windows budgets 15569 of this card's 16368 MiB for this process; free VRAM is counted within that (STRATA_WDDM_BUDGET=0: off).STRATA_WDDM_BUDGET=0turns it off.#if defined(STRATA_USE_HIP) && defined(_WIN32), and the shim header is only used by HIP builds.It is on by default, since without it setup's own configuration overfills a card that drives a display; if you prefer it opt-in, that is the
offlambda inmem_get_info.No kernel changes. What changes is the free-VRAM figure and with it how many experts sit in VRAM, as with any other
--expert-cachesize.Measured
RX 6800 16 GB (gfx1030, drives the desktop), Ryzen 7 5800X3D, PCIe 4.0 x16, Windows 11 (build 26300), HIP SDK 7.2, Visual Studio 2026 Build Tools. A local test build of 0.1.31 (
9259cad) with #356, #311 (rebased onto 0.1.31), this commit, #373, #377, an earlier version of #376 (the same Release flags), and a scratch reserve for verify windows (branchwin-scratchon my fork; not proposed, since 0.1.31 did not hang without it). Every comparison in the table is within that build:STRATA_WDDM_BUDGET=0against unset.Qwen3.8-Flash-Next IQ3_XXS with the configuration setup wrote:
--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --max-context 131072 --kv int8 --kv-resident 32768, MTP draft head,pcie_frac0.55 from the probe. Two engine starts per variant, each with four passes overtools/calibrate.py's three prompts, 128 tokens each; the card's memory from Windows' GPU counters after loading.STRATA_WDDM_BUDGET=0)With the budget off the expert cache is 1.78 GiB larger; 902 MiB more of the engine is in VRAM (dedicated) and 929 MiB more in system memory (shared). The two starts of each variant gave the same sizes and memory figures, and their decode medians are within 0.4 tok/s of each other. The prompt path borrows the same 4.44 GiB of cache slots in both and the prompt chunk stays 8192 tokens; long prompts were not measured.
--vram-reserve-mibalone does not help: on a 0.1.30 build,--vram-reserve-mib 1500still left the card at 16037 MiB, since the reserve is taken from the same figure.The budget on this card, from a standalone probe that allocates in steps of 1 GiB (256 MiB past 14 GiB), in MiB:
hipMemGetInfofreeThe allocations past the budget all succeed; whether and how much of that Windows then moves out depends on what else wants the card (in the engine runs above, 929 MiB).
To reproduce:
STRATA_WDDM_BUDGET=0against unset, comparing the engine's dedicated and shared GPU memory between the two (Task Manager's details view or theGPU Process Memorycounters). Shared memory is large in both (the registered expert arena counts there); the difference is what moved.Tested on this card only, with the desktop on it. On a card without a display the budget should sit closer to the card's size, so less would change there; not tested, nor with more than one GPU.
🤖 Generated with Claude Code
https://claude.ai/code/session_015Ld5YDzuKW1hgMVwwgRZDP
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.