Repository navigation
HIP: count the desktop's VRAM on Windows (WDDM budget, STRATA_WDDM_BUDGET) - #380
Closed
BlueKingMuch wants to merge 1 commit into
Closed
BlueKingMuch wants to merge 1 commit into
BlueKingMuch wants to merge 1 commit into
Conversation
…DGET)
On Windows, hipMemGetInfo (ROCclr's PAL backend) reports the card's size
minus this process's own allocations; 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, and
--expert-cache auto fills the card past what Windows lets the process
keep in VRAM: WDDM moves part of it out to system RAM. On an RX 6800
(HIP SDK 7.2) with setup's configuration: a 9.83 GiB cache, the card at
16132 of its 16368 MiB, 929 MiB more of the engine in system RAM than
with this change, 30.1-31.0 tok/s decode. On a 0.1.30 build,
--vram-reserve-mib 1500 left the card as full (16037 MiB), since the
reserve is taken from the same figure.
Windows gives every process a video memory budget that does account
for the others (DXGI QueryVideoMemoryInfo). On that card it is 799 MiB
below the card's size while the process is small and about 1.8 GiB
below once it holds 11 GiB; allocations past it still succeed.
cudaMemGetInfo, which the HIP shim maps to hipMemGetInfo, now lowers
hipMemGetInfo's free figure by what the budget withholds (the card's
size minus the budget), on Windows only. What is sized from it then
stays within the budget: --expert-cache auto sizes the cache from it,
and the existing check after the slots are written shrinks it ("only
8 MiB free once the slots are written ... shrinking"): an 8.05 GiB
cache, the card at 15230 MiB, 40.6-41.5 tok/s.
Lowering HIP's own figure, instead of taking the budget minus DXGI's
usage, keeps memory the HIP runtime has freed but still caches counted
as free, as HIP counts it.
dxgi.dll is loaded at run time, so nothing new is linked; the adapter
is found by the device's LUID. Without dxgi.dll, the adapter or a
budget below the card's size, hipMemGetInfo's figure stands. The first
query logs the budget once. STRATA_WDDM_BUDGET=0 turns it off. CUDA
and Linux builds are unchanged.
Claude-Session: https://claude.ai/code/session_015Ld5YDzuKW1hgMVwwgRZDP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 1, 2026
Niko1221
added a commit
that referenced
this pull request
Oct 2, 2026
…d the host-timed PCIe probe (#377) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0154bwiad8gY7wRehCXy27pN
Owner
|
Released in 0.1.37 as is (rebased; the device listing that main gained since kept beside it). Merged under your name (GitHub doesn't show it as merged because it went in by hand). Thank you! |
Niko1221
added a commit
that referenced
this pull request
Oct 6, 2026
…d the host-timed PCIe probe (#377)
Niko1221
added a commit
that referenced
this pull request
Oct 6, 2026
anon761
pushed a commit
to anon761/Strata-upstream
that referenced
this pull request
Oct 6, 2026
…#380) and the host-timed PCIe probe (Niko1221#377)
anon761
pushed a commit
to anon761/Strata-upstream
that referenced
this pull request
Oct 6, 2026
…MD counts the desktop's VRAM (Niko1221#380 Niko1221#377 Niko1221#497), a steadier PCIe probe (Niko1221#485), fixes Niko1221#496 Niko1221#495 Niko1221#498 Niko1221#505 Niko1221#493; setup requires it
anon761
pushed a commit
to anon761/Strata-upstream
that referenced
this pull request
Oct 6, 2026
…#380) and the host-timed PCIe probe (Niko1221#377) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0154bwiad8gY7wRehCXy27pN
anon761
pushed a commit
to anon761/Strata-upstream
that referenced
this pull request
Oct 6, 2026
…MD counts the desktop's VRAM (Niko1221#380 Niko1221#377 Niko1221#497), a steadier PCIe probe (Niko1221#485), fixes Niko1221#496 Niko1221#495 Niko1221#498 Niko1221#505 Niko1221#493; setup requires it Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0154bwiad8gY7wRehCXy27pN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (branch
win-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