mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2836] [CLOSED] Windows: make device_free_bytes() unified-memory aware on APUs (Strix Halo gfx1151) #4293
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#4293
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/2836
Author: @moweishun
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:windows-uma-device-free📝 Commits (1)
8166c6cWindows: make device_free_bytes() unified-memory aware on APUs📊 Changes
1 file changed (+29 additions, -12 deletions)
View changed files
📝
src/core/expert_cache.cpp(+29 -12)📄 Description
Windows:
device_free_bytes()is not unified-memory aware, so the auto expert cache cannot size on Strix Halo (gfx1151)Summary
On Windows, an APU with unified memory (Ryzen AI Max+ 395 / Radeon 8060S,
gfx1151) reports a tiny"free VRAM" figure through
cudaMemGetInfo— essentially the free space of the BIOS's dedicatedcarve-out, often well under 2 GiB.
device_free_bytes()(src/core/expert_cache.cpp) only appliesits unified-memory correction (
MemAvailableminus headroom) under#if defined(__linux__), so onWindows the auto expert cache sizes from the small figure and refuses to start
("no VRAM is left for the expert cache"), and an explicit
--expert-cache Nis silently shrunk to0 slots by the sizing pass ("pre-filled 0 of 0 slots from the profile", no "expert cache N slots"
line).
This PR extends the same unified-memory correction to Windows: when the current device reports
integrated graphics, the free figure is raised to
GlobalMemoryStatusEx().ullAvailPhysminus thesame
STRATA_UMA_HEADROOM_GIBheadroom (default 6 GiB). The Linux path is unchanged, and discreteGPUs are unchanged (the integrated check is per device, as before).
What it changes
src/core/expert_cache.cpp,device_free_bytes(): the integrated-GPU detection moves out of the__linux__-only block (HIP exposescudaDevAttrIntegrated), and a_WIN32branch adds theGlobalMemoryStatusExpath beside the Linux/proc/meminfopath. TheSTRATA_UMA_HEADROOM_GIBknob, its default of 6, and its semantics are shared.#include <windows.h>under_WIN32forGlobalMemoryStatusEx.What it leaves alone
/proc/meminfopath, the gfx906 compat exclusion, the headroom default and env knob.unified_memoryfalse → plaincudaMemGetInfo).sycl/src/core/expert_cache.cpp) — not touched.Measured on
Ryzen AI Max+ 395 (Radeon 8060S,
gfx1151, wave32), Windows 11 (build 26100), Adrenalin driver32.0.31041.1004, self-built HIP engine from this tree (
tools/hip/build_windows.bat,STRATA_HIP_ARCHS=gfx1151, ROCm 10.2.0a20260930 wheels), IQ3_S, 200K context, MTP on.Free figure seen by the engine (after the session's allocations), by BIOS carve-out, before the fix:
device_free_bytes()After the fix (16 GB carve-out, 200K): auto sizes 19339 slots (36.84 GiB), pre-fills all of them
from the profile (6.5 s), serves at 40-45 tok/s decode (96.9% cache hit rate), where every
configuration refused to start or shrank to 0 slots before.
Caveats, stated plainly
the driver's shared pool (WDDM GTT backed by the same LPDDR5X). The server's
"0 MiB of VRAM free with everything loaded - LOW" warning still prints (the reserve check reads
the same function, which now reports the large figure and never triggers the shrink loop).
Measured no stalls across benchmark runs; a follow-up that also accounts for the carve-out in the
shrink loop may be worth it, but it is deliberately not in this PR.
cache wants a page file with room.
tools/hip/build_windows.bat's engine printed that noteduring a failed open before the fix; with the fix the auto path converged on the first open.
How it was checked
above). Without the patch, the same tree reproduces the refusals in the table.
src/core/expert_cache.cppis also compiled by the CUDA build; on Windows CUDA there is nointegrated AMD GPU, and on Linux the CUDA build already took the
__linux__path (unchanged).Not built here (no NVIDIA GPU on this PC) — the CUDA path's behaviour for a discrete GPU is
unchanged by construction (the new code only runs when
unified_memoryis true).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.