mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5122] [TUI] tune: restart candidates are skipped on a RAM-limited PC because the start guard asks for more free RAM than the base run had #2395
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#2395
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 @Maxrio9 on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5122
Area
[TUI] (the Terminal: strata launch, connect, monitor)
Desktop app, Terminal or source?
Terminal (the
stratacommand)What happened
On a PC with 32 GB of RAM (about 25 GiB usable) and a 32 GB card,
strata launch --tune quick --retune(also--tune-allow-small) with the model stopped first measures only the per-request settings. Both restart candidates it planned were skipped by the memory guard, and the result says "Your current settings are already the fastest we found. Nothing was changed."From the stored result (
<run>.tune.json,result.armsandresult.base):The model was stopped before tuning, as advised in #3490, and nothing else big was running (24.1 GiB available when the guard ran). The base run itself started with 23.1 GiB available, ran fine, and its minimum available memory during the run was 2.7 GiB.
What the code does (read at
v0.2.10;mainis identical for this file):strata_control/autotune.py,_ram_guard()(about lines 268 to 299):need = min_free_ram_mib + delta_mib, thenneed += base_rss(the base run's peak RSS).MIN_FREE_RAM_MIB = 3584(line 35). Forspec3delta is 0, soneed = 22.9 GiB + 3.5 GiB = 26.4 GiB; forprefill_32kdelta is about 4 GiB, so 30.4 GiB. Both exceed the 24.1 GiB this PC has with nothing loaded._memory_overrun()in the same file (about line 692) has the comment "a RAM-bound base can sit below the floor itself" and tolerates a base whose own minimum is under the floor._ram_guardhas no such tolerance, so the pre-start check is stricter than the post-run check, and stricter than what the base run itself met.rss_peak_mibincludes file pages the engine maps (the experts), which the kernel can reclaim; that would explain why the base run started with less available memory thanrss_peak + floorand still ran.Expected: a candidate that adds no memory over the base (here
spec3, delta 0) is tried when the base run could be started on this PC.Actual: it is skipped. On any PC where the base leaves under about 3.5 GiB free (the 32 GB class in
docs/TEST_REQUESTS.md), no restart candidate can run, and the result message does not say that two candidates were not tried.What was measured and what was not: the skipping and the numbers above were reproduced on this PC (twice). The cause in the code and the suggested fix are unconfirmed static analysis: I read the code at
v0.2.10and did not run a change.Suggestion (sketch, not run)
For a candidate with
delta_mib <= 0, compare against the memory the base start was allowed with (facts.avail_gibis already recorded) instead ofbase_rss + floor. Illustration only; field names are not checked against the code:Smaller alternative: keep the guard, but when any planned candidate was skipped for memory, say so in the result ("N settings could not be tried: not enough free memory") instead of "already the fastest we found". The
not_triedoutcome already exists for the case where nothing at all was compared; this would cover the partial case._memory_overrunchecks, which still stop a candidate that really uses more.Smallest steps or command that reproduce it
Needs a PC where the base uses most of the RAM. Seen on 2026-11-03 in three runs: a plain
--tune quick(one candidate planned,prefill_32k, skipped: 26.5 GiB free, 32.3 GiB needed); a run with--tune-allow-smallbut without--retune, which printed "already tuned ... so that result is used and nothing is measured again" (as designed); and the--retune --tune-allow-smallrun quoted above (both planned candidates skipped).Reproduction status
Reproduced locally
Strata version
Strata 0.2.10 · engine 0.1.56
Graphics card, memory and system
RTX PRO 4500 Blackwell 32 GB · 32 GB DDR4-3200, dual channel (about 25 GiB usable) · Ryzen 9 5900X (AVX2) · Arch Linux, kernel 7.2
Model, size and settings
Qwen3.8-Flash-Next IQ3_XXS (ISTA-DASLab) · 64K context ·
--parallel 1 --drafting dflash2· pictures onLogs
The relevant part of
<name>.tune.json(GitHub does not take.jsonattachments), paths removed:tune.json excerpt
@Rhycecomley commented on GitHub (Nov 3, 2026):
Same guard on a second machine, and this one confirms the guess in the report: in
--mmap-expertsmode the base run'srss_peak_mibis mostly the mapped expert files, so_ram_guardasks for memory the engine never needed.Setup: Strata 0.2.10 · engine 0.1.56 (cuda) · RTX 3060 12 GB · Debian 13 VM with 19.5 GiB RAM (no other model loaded during tuning) · Gyro-S, 64K context,
--drafting dflash2, pictures off ·strata launch --preset ... --tune thorough.The server log shows the experts are mapped, not loaded:
From
<name>.tune.json:Thorough mode planned 23 runs and completed 1 (the base), then reported "already the fastest we found".
What shows the peak is file pages: during the base run
topshowed the engine at RES 14.0 GiB with SHR 12.0 GiB, so about 2 GiB was the engine's own (anonymous) memory. MemAvailable never went below 13.4 GiB during the run, which a 15.7 GiB private footprint on a 19.5 GiB machine could not do. Withmin_free_ram_mib3584 +rss_peak15719 = 19303 MiB needed, no restart candidate can start on this machine at all, whatever else is stopped.Suggestion, complementary to the one above (not run against
main): measure the peak as private memory (RssAnon+RssShmemfrom/proc/<pid>/status, summed over the tree, kept as a high-water mark while the run lasts) rather thanps -o rss, at least when the engine runs with--mmap-experts. That keeps the guard's protection for engines that really load into RAM and stops counting page cache the kernel can drop. The partial-result wording suggested above ("N settings could not be tried") would also have made this visible here.@sangharshadhyeta commented on GitHub (Nov 3, 2026):
Until the guard is fixed, you can still test the two skipped candidates by hand. "Nothing was changed" only means they were not tried, not that they lost.
--specto 3 in the model config's "args" (mine is 4), restart, and compare.--prefilltoauto:32768(same syntax as in #4978), restart, and compare.For each, run the same prompt 3 times and take the median decode and prefill. Throw away the first run; it warms the file cache and is always slower.
One tip for 32 GB PCs: I run the server inside a memory cap so a runaway process stops instead of freezing the desktop (two uncapped runs once froze mine):
I have not run this against the tune command itself, only by hand like this. Hope it helps.
@Maxrio9 commented on GitHub (Nov 3, 2026):
Thanks, I tried both by hand (this is the reporter's PC: 32 GB card, 32 GB RAM, Strata 0.2.10 / engine 0.1.56, DFlash2, one request, 64K context, pictures on,
--kv int8). One launch per variant,--seton the launch command, the order control,spec3,prefill_32k, control again. Each variant got 4 prompts of about 7K tokens, 6 generations of 1,200 tokens at temperature 0 (3 prompts, twice), and 3 prompts of about 30K tokens, all read from the engine's own request records. Single machine, small n; treat it as a hint, not a result.spec3: not testable this way. With--set spec=3the launcher wrote--spec 3into the run config, but the engine process was started with--spec 6(checked from its command line and/metrics). So that run is just a second control; DFlash2 seems to set its own window. If the tuner'sspec3arm goes through the same path on DFlash2, it may not be a real candidate there; I have not checked that in the code.prefill_32k(--set prefill=auto:32768, engine command line showed--prefill auto:32768):spec3(really a control)prefill_32kprefill_32kwas slower here: 241 to 277 tok/s, against 654 to 2339 in the nine control runs on similar prompts (time to first token 103 to 160 s against 15 to 47 s). Three runs, one launch, so I would not call the size of the drop reliable, but no control run was that slow.ram_delta_mib=4096; on this 32 GB PC that may matter, but I did not measure it.So on this PC the two skipped candidates would probably not have won, and
prefill_32kmay have lost on long prompts. That says nothing about the guard being too strict for other candidates. Raw rows (per run: prompt tokens, prefill and decode tok/s, time to first token) are in a file I can attach if it helps.@sangharshadhyeta commented on GitHub (Nov 3, 2026):
thanks for testing them.
On my 30 GB PC, two things kept memory under control. One is the 94% cap: systemd-run with MemoryMax and no swap, added after two uncapped runs froze it. The other is in the engine: it keeps a free-RAM floor before each request and hands RAM-tier experts back when something else needs memory. It's a different engine from Strata, so I'm only sharing what worked on a similar RAM budget.
One check on the guard for your PC: whether your engine log says it is mapping the experts (--mmap-experts), and RssAnon against RssFile in /proc//status while the base run is up, would show whether the base run's peak is real memory or mapped file pages.
@Maxrio9 commented on GitHub (Nov 4, 2026):
Thanks for the check. On this PC the answer is the opposite of the 12 GB card in the earlier comment, and it corrects the guess in my report ("rss_peak includes file pages the kernel can reclaim"): that does not hold here.
--mmap-experts. Its command line has--resident-experts, and its log says "resident RAM mode: 20.07 GiB of experts in RAM (page-locked), 14301 in the GPU cache ... (no file reads)"./proc/<engine pid>/statusof the running engine (the plugin-started one with the same model and context; not the tuner's own base run, which I did not catch):RssAnon21.05 GiB,RssFile0.06 GiB,RssShmem0.07 GiB. So the resident set is almost entirely private memory, and the tuner'srss_peak_mibof 23,429 for the base run is real memory, not mapped file pages.MemAvailableon the machine with it running is about 1.6 GiB (of 32 GB).So for this PC the guard is not miscounting page cache. The base run itself dipped to 2.8 GiB available (below the 3.5 GiB floor), and a restart candidate that needs the same memory as the base would be asked for base + floor, more than the 24.1 GiB this PC has free with nothing loaded. That part of my report ("the guard asks for more than the base run had") still stands as arithmetic; what I called a likely cause (reclaimable file pages) is wrong for resident mode, and the earlier comment's private-memory idea applies to
--mmap-experts, not here. A fix would have to handle the two modes differently, or the message should say that the candidates were not tried for lack of RAM. I'll leave the report text as it is and let this comment stand as the correction.@Rhycecomley commented on GitHub (Nov 4, 2026):
Idea: measure what the base run took from the machine, not what its process holds. The engine logs
available X GiB (MemAvailable ...)at start (parsed asfacts.avail_gib,tune_session.py:104), and the session keeps the lowestMemAvailableseen while the engine runs (min_avail_mib,tune_session.py:328). The difference is how much the base run actually took from the machine, and page cache the kernel can drop is already left out, so it works for both modes:Today
_ram_guard(autotune.py:278-282) usesbase_rss + floorinstead: 26.4 and 18.9 GiB, which is why both PCs skip everything. A sketch, not run:Caveats:
_memory_overrunstill catches a candidate that really uses more.avail_gibis logged to 0.1 GiB, and on the resident PC the margin is only about 0.2 GiB, sospec3would just barely pass there. Maybe usemax(taken, rss_anon)if private RSS is ever measured.rss_peak_mib(22.9 GiB) even though RssFile is near zero. I don't have an explanation; possibly part of the page-locked expert memory came out of page cache the machine already had. I'd want someone to check that before relying on it.On
spec3: the engine replacing--spec 3with--spec 6under DFlash2 matches what I see on the 3060. The arm intune_knobs.py:96has onlyclasses=("A", "B")and no drafter condition, so on DFlash2 setups the tuner would probably measure a second copy of the base and call itspec3. If so, it would be worth skipping it there with a reason ("DFlash2 sets its own window") like the other "this engine does not accept ..." skips, so it doesn't use up a slot or a restart.The partial-result wording from the report ("N settings could not be tried: not enough free memory") would still help in both cases; right now
not_tried(autotune.py:640) only triggers when nothing was measured, and the per-request stage counts as something.@Niko1221 commented on GitHub (Nov 5, 2026):
Hello Maxrio9,
Thank you for the long, careful report. In Strata 0.2.11 a restart candidate that adds no memory is judged against the free memory the base run had at its own start, not against the base's peak plus a floor, so those candidates are no longer skipped on a RAM-limited PC. When some candidates are still skipped for memory, the result now says "N settings could not be tried: not enough free memory" instead of "already the fastest we found" (the Terminal's short word is "some not tried"). If your tune still skips candidates it should have tried, please send the tune result file.
The Strata project