mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4117] [Engine] Automatically use --resident-experts to prevent startup failure #4908
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#4908
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/4117
Author: @qwertie
Created: 10/25/2026
Status: 🔄 Open
Base:
main← Head:auto-low-ram-mode📝 Commits (3)
d07a3f4engine: when the expert arena cannot fit the RAM available at start, take the resident low-RAM mode instead of failing (STRATA_ARENA_FIT=0 keeps the arena)8f72492engine: the arena-fit switch's line in plain words ("Enabling--resident-expertsmode to compensate.")ba38f17engine: the arena-fit margin is 1 GiB (platform::kArenaFitFloor), not 2.5, so fewer starts that fit by paging other programs out change; docs say which case changes📊 Changes
4 files changed (+80 additions, -11 deletions)
View changed files
📝
docs/DETAILS.md(+10 -0)📝
include/strata/platform/memory.hpp(+11 -0)📝
src/platform/memory_test.cpp(+24 -1)📝
src/program/generate.cpp(+35 -10)📄 Description
Problem and result
The README says Strata "switches to its low-RAM mode by itself" but on many systems it will just fail to start
because it inappropriately decides to copy every expert into RAM unless
--resident-expertsis added by hand.This is because setup decides whether to use
--resident-expertsbased on the PC's total RAM, but drivers andother programs may well make it impossible to load without it (leading to error 1453).
With this change, when the arena cannot fit the RAM available at start with 1 GiB to spare,
the engine enables
--resident-expertsand prints one line:In the nonstandard case that
--expert-profileis disabled it uses--mmap-expertsinstead.Related discussion
https://github.com/Niko1221/Strata/issues/4116
Approach by Opus5.5
I prompted it with possible solutions in my order of preference, saying "Choose the clear winner or my preference if there isn't one":
It chose the third:
depends on the mode:
--kv-grow, the prompt chunk and the arena itself.platform::arena_fits_ramholds the rule. The margin is 1 GiB (platform::kArenaFitFloor, not measured), keptsmall so that as few starts as possible change (see Compatibility).
--resident-expertsnow goes through one helper,take_resident_experts, shared by the flag and the switch, soboth set the same options (including
STRATA_RESIDENT_PINandSTRATA_RESIDENT_HEADROOM_GIB).--mmap-experts,--resident-experts,--resident-budget-gibor--shared-expert-arena, nor on Metal (always mapped).STRATA_ARENA_FIT=0keeps the old behavior.docs/DETAILS.mdgets a paragraph under the low-RAM mode.Compatibility: a start whose arena fits gets the same flags and the same output. One case changes: a start that
works today only because Windows pushes other programs into the page file to make room for the arena now takes the
low-RAM mode instead, because memory that could be paged out is not counted as available. That is likely common on
64 GB PCs (a 16 GB card with 64 GB of RAM gets the arena from setup, and needs 47.8 GiB available at start to keep
it), and the low-RAM mode avoids the minutes of a sluggish PC that the paging causes. How its speed compares there
is not measured. The margin is small (1 GiB) for this reason: a start that fits with a little to spare keeps the
arena.
Validation
All on one PC: Ryzen AI Max+ 395 / Radeon 8060S (gfx1151), 128 GB with a 64 GB BIOS carve-out (Windows sees
63.6 GiB), Windows 11 Pro 10.0.26200. Qwen3.8-Flash-Next IQ3_S with setup's config (
--expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --max-context 204800 --kv int8 --vision --vram-reserve-mib 700, speed projection on).Engines built with
tools\hip\build_windows.bat,STRATA_HIP_ARCHS=gfx1151,STRATA_NO_VISION=1, Visual Studio2026 Build Tools, ROCm 10.2.0a20260930.
Passed:
mainat4b9e05a2(engine 0.1.51) and checked again there: the HIP build,platform_memory_test: OK,and one start with setup's config: "the experts (46.8 GiB) do not fit in RAM available now (31.2 GiB, 1.0 GiB kept
free). Enabling
--resident-expertsmode to compensate.", all 24,576 experts in the GPU cache, ready after about6 minutes, a 400-token answer at 17.8 tok/s. The runs below were made before the rebase, on engine 0.1.49.2.
strata.exe,strata-device.exeand the package. No new warningsbesides the
getenvdeprecation the file already has everywhere.platform_memory_test(HIP build, Windows): the seven newarena_fits_ramcases and the existing ones,platform_memory_test: OK.available), the GPU cache took all 24,576 experts (46.84 GiB), only 3.41 GiB was copied into RAM, the server was
ready after about 6.5 minutes, and a 400-token answer to a 67-token prompt (temperature 0) decoded at 20.4 tok/s.
Two earlier runs of the branch, before the message and the margin changed (31.9 and 30.4 GiB available), switched
the same way and decoded at 18.8, 21.1 and 18.3 tok/s.
Failed:
mainat7dd5cf18without this change, setup's config: 33.3 GiB available, "the expertload was refused: short unbuffered read of layer 0 ... (error 1453)", exit code 1. Engine 0.1.48 failed the same way
on four starts (23.0-37.9 GiB available, at layers 0, 4, 21 and 14). This is the failure the PR fixes.
Not run:
generate.cppis compiled there.memory.hpp(one new inline function) and has its owngenerate.cpp, whichthis PR does not change.
--kv-growand--vram-elastictogether with the switch.Reference run: the unchanged build from
mainwith--resident-expertsadded by hand started (about 7.5 minutes)and decoded the same two answers at 19.3 and 20.3 tok/s. So the switch gives the same speed as the flag. One run of
each; not enough to claim more than that.
Limits
react.
--kv-growneeds every expert in RAM: after the switch it stays off and says so, as with--resident-experts.docs/DETAILS.mdsays--vram-elasticdoes not work with the resident mode either; I did not check how itbehaves after the switch.
low_ram_needed) is unchanged, so the config and setup's messages still describe thearena.
unchanged there.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.