mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1571] [Bug]: Windows --resident-experts: building the RAM copy keeps experts.bin's mapped pages in the working set until the last layer, available RAM drops to ~0 on a 48 GB PC #625
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#625
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?
Originally created by @LaciciBachuchu on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1571
What happened
On Windows with 48 GB of RAM,
--resident-expertsdrives the PC's available RAM to almost zero for about 20 seconds at the end of every load, while the RAM copy (cache complement) is built. The engine's own sizing is fine (it leaves the 4 GiB headroom against the RAM it finds free); the extra comes from theexperts.binpages the copy reads through the file mapping, which stay in the process working set until the copy is finished.From the source (v0.1.40.3,
src/core/expert_source.cpp,FileExpertSource::pin_cache_complement):direct_is empty (line 2465), which is the case in the resident mode: only the RAM-budget path callsset_unbufferedfirst (program/generate.cpp:4062-4064);madvise(MADV_DONTNEED)+posix_fadvise, around line 2510, inside#if !defined(_WIN32));VirtualUnlockon the full mapping (line 2543).So on Windows the source pages of all 48 layers pile up in the working set on top of the page-locked copy. With ~30 GB available before the copy, that is ~25 GB pinned plus up to ~25 GB of mapped pages. Windows does not count those clean file pages as available until it trims them, and it only trims once memory is nearly gone.
Measured (engine log +
\Memory\Available MBytessampled every ~3 s, strata.exe working set):A second load (started from our launcher) showed the same shape: available RAM 5.6 -> 1.9 -> 0.1 -> 0.9 -> 0.6 -> 0.6 GB over ~20 s, then 6.9 and 13.6 GB once the load finished. A third load, while the desktop and a browser were active, ended with an NVIDIA driver reset (System log: nvlddmkm event 153) about 83 s into the load, right where this happens. That one is a correlation, not a proof, but it is the only nvlddmkm event on this machine in months; ECC counters did not change.
What confirms the cause: trimming strata.exe's working set from outside during the load (
SetProcessWorkingSetSize(handle, -1, -1)every 0.4 s, which only moves unlocked pages to the standby list) kept available RAM at 9.7 GB or more for the whole load, with the same load time (~70 s) and the same3007 of the prompt path's 3007 lendable slots keep their experts in RAM too. It is not a workaround I can keep, though: an antivirus heuristic flagged the helper that opens another process and changes its working set.The workaround we use now is
--resident-budget-gib 27with"env": {"STRATA_UNBUFFERED_LOAD": "1"}. The copy then goes throughread_directand available RAM never drops below ~4.6 GB, but a budget turns the lend region off (lend_from_slot = -1, around line 2147: "A budget turnslendoff"), so every prompt re-reads the lent experts from the drive. The same model, cache and args otherwise:Decode speed is the same in both modes.
Suggested fix
VirtualUnlockon the layer's span, asFileExpertSource::release(layer, expert)already does per expert and as the Linux branch does withmadviseper layer. Alternatively, use theread_directpath for the resident copy too.--resident-budget-gibkeep the lend region in RAM when the budget covers it, so the RAM-budget mode does not pay the drive reads per prompt.Related observations (same PC, not separate bugs)
resident complement 22.30 GiB exceeds available commit (2.28 GiB) minus the 4 GiB safety headroom. The ~22 GB of VRAM counts against commit under WDDM, and the desktop apps held ~40 GB of commit. The engine fell back to plain mapped mode with only a log line, and setup did not warn. A fixed 48 GB page file fixed it. A setup tip, for example "RAM + page file must cover the GPU's VRAM plus the RAM copy", would have saved some time.--low-ram residentwas needed. Perhaps setup could look at available RAM too.tools/iq_pack.py --experts-bin: thenp.memmapread of the 39 GB GGUF grew the packer's working set to ~18 GB (available RAM 21 -> 6.5 GB) before we capped its working set at 3 GB, after which it finished normally in ~2.5 min. This is the same Windows behaviour (mapped pages stay in the working set) in the setup step.Strata version, GPU, OS
0.1.40.3 (ready-made engine,
strata-windows-x64.zip) · RTX 4090 24 GB (ECC on, 22.5 GB usable), driver 616.92, PCIe 4.0 x16 · i7-14700K (AVX2) · 48 GB DDR5-5600 · Windows 11 Pro (26200) · NVMeModel: Qwen3.8-Flash-Next GSQ-RCO IQ2_XS. Engine args:
(
--pcie-frac 0and--pool-workers 19were faster than the probe's 0.55 and setup's 13 on this CPU: +16-32% and +3-10% decode, the same direction as #308.)Thanks for Strata. With the lend region in RAM it reads 200K prompts faster than the dense 27B we use on the same card.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.