[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

Closed
opened 2026-11-04 01:58:57 +07:00 by bsakaguchi · 7 comments
Owner

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 strata command)

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.arms and result.base):

spec3        skipped  not enough free memory to start it safely (24.1 GiB free, 26.4 GiB needed)
prefill_32k  skipped  not enough free memory to start it safely (24.1 GiB free, 30.4 GiB needed)
base run:    rss_peak_mib 23429   min_avail_mib 2799   facts.avail_gib 23.1   decode 139.5 tok/s

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; main is identical for this file):

  • strata_control/autotune.py, _ram_guard() (about lines 268 to 299): need = min_free_ram_mib + delta_mib, then need += base_rss (the base run's peak RSS). MIN_FREE_RAM_MIB = 3584 (line 35). For spec3 delta is 0, so need = 22.9 GiB + 3.5 GiB = 26.4 GiB; for prefill_32k delta 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_guard has no such tolerance, so the pre-start check is stricter than the post-run check, and stricter than what the base run itself met.
  • My guess, not checked: rss_peak_mib includes file pages the engine maps (the experts), which the kernel can reclaim; that would explain why the base run started with less available memory than rss_peak + floor and 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.10 and 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_gib is already recorded) instead of base_rss + floor. Illustration only; field names are not checked against the code:

--- a/strata_control/autotune.py
+++ b/strata_control/autotune.py
@@ _ram_guard
             need = self.o.min_free_ram_mib + delta_mib
             base_rss = self.base_runs[0].rss_peak_mib if self.base_runs else None
             if base_rss:
                 need += base_rss
+            base_avail = self.base_avail_mib   # MemAvailable when the base start was allowed (illustrative name)
+            if base_avail and delta_mib <= 0:
+                need = min(need, base_avail)   # a base that fits, fits again; a RAM-bound base may sit below the floor (see _memory_overrun)

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_tried outcome already exists for the case where nothing at all was compared; this would cover the partial case.

  • The per-request knobs did run, so "already fastest" is true for those; only the two restart candidates were never tried.
  • A stricter guard may be deliberate protection for PCs that do other work ("leave 20% for my work"); the sketch keeps the post-run _memory_overrun checks, which still stop a candidate that really uses more.
  • One machine. We did not test the sketch.

Smallest steps or command that reproduce it

strata launch --stop
strata launch --family qwen --model iq3_xxs --model-path <dir> --context 64k --kv int8 --vision on --parallel 1 --drafting dflash2 \
  --tune quick --tune-allow-small --retune --yes --no-tui
# then read ~/.local/state/strata/launch/<name>.tune.json: result.arms[*].status / reason, result.base.rss_peak_mib / min_avail_mib

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-small but without --retune, which printed "already tuned ... so that result is used and nothing is measured again" (as designed); and the --retune --tune-allow-small run 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 on

Logs

The relevant part of <name>.tune.json (GitHub does not take .json attachments), paths removed:

tune.json excerpt
{
  "outcome": "default_confirmed",
  "mode": "quick",
  "base": {
    "decode_tok_s": 139.5,
    "decode_runs": [
      124.4,
      143.0,
      130.9,
      141.2,
      139.5
    ],
    "pp_tok_s": 2261.5,
    "ttft_s": 1.8217999999999999,
    "rss_peak_mib": 23429.0,
    "min_avail_mib": 2799,
    "vram_used_mib": 30313
  },
  "base_facts": {
    "slots": 12995,
    "workers": 11,
    "pcie_gbs": 28.3,
    "pcie_frac": 0.4,
    "chunk": 8192,
    "avail_gib": 23.1,
    "resident_ram": true,
    "hybrid_experts": false,
    "unknown_argument": false
  },
  "arms": [
    {
      "id": "spec3",
      "label": "Shorter speculative window (3 tokens)",
      "status": "skipped",
      "reason": "not enough free memory to start it safely (24.1 GiB free, 26.4 GiB needed)"
    },
    {
      "id": "prefill_32k",
      "label": "Larger prompt chunks (faster very long prompts)",
      "status": "skipped",
      "reason": "not enough free memory to start it safely (24.1 GiB free, 30.4 GiB needed)"
    }
  ],
  "skipped": [
    {
      "id": "kv_resident_64k",
      "label": "Keep more of the conversation in graphics memory",
      "reason": "this PC does not match: ctx ge 128k"
    },
    {
      "id": "adapt_async",
      "label": "Learn which experts to keep while you chat, in the background",
      "reason": "answers would not repeat run to run; tick 'allow settings that are not repeatable' to try it"
    },
    {
      "id": "adapt_tier_fast",
      "label": "Re-balance the expert cache faster",
      "reason": "this engine does not accept --adapt-every, --adapt-swaps, --adapt-decay"
    },
    {
      "id": "adapt_decay_09",
      "label": "Forget old expert use a little faster",
      "reason": "this engine does not accept --adapt-decay"
    },
    {
      "id": "host_core_last",
      "label": "Run the control thread on the last CPU core",
      "reason": "only tried in the thorough tune (it was measured as flat)"
    },
    {
      "id": "kv_grow",
      "label": "Allocate the conversation memory as it grows",
      "reason": "only tried in the thorough tune (it was measured as flat)"
    }
  ]
}
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 `strata` command) ### 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.arms` and `result.base`): ```text spec3 skipped not enough free memory to start it safely (24.1 GiB free, 26.4 GiB needed) prefill_32k skipped not enough free memory to start it safely (24.1 GiB free, 30.4 GiB needed) base run: rss_peak_mib 23429 min_avail_mib 2799 facts.avail_gib 23.1 decode 139.5 tok/s ``` 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`; `main` is identical for this file): - `strata_control/autotune.py`, `_ram_guard()` (about lines 268 to 299): `need = min_free_ram_mib + delta_mib`, then `need += base_rss` (the base run's peak RSS). `MIN_FREE_RAM_MIB = 3584` (line 35). For `spec3` delta is 0, so `need = 22.9 GiB + 3.5 GiB = 26.4 GiB`; for `prefill_32k` delta 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_guard` has no such tolerance, so the pre-start check is stricter than the post-run check, and stricter than what the base run itself met. - My guess, not checked: `rss_peak_mib` includes file pages the engine maps (the experts), which the kernel can reclaim; that would explain why the base run started with less available memory than `rss_peak + floor` and 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.10` and 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_gib` is already recorded) instead of `base_rss + floor`. Illustration only; field names are not checked against the code: ```diff --- a/strata_control/autotune.py +++ b/strata_control/autotune.py @@ _ram_guard need = self.o.min_free_ram_mib + delta_mib base_rss = self.base_runs[0].rss_peak_mib if self.base_runs else None if base_rss: need += base_rss + base_avail = self.base_avail_mib # MemAvailable when the base start was allowed (illustrative name) + if base_avail and delta_mib <= 0: + need = min(need, base_avail) # a base that fits, fits again; a RAM-bound base may sit below the floor (see _memory_overrun) ``` 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_tried` outcome already exists for the case where nothing at all was compared; this would cover the partial case. - The per-request knobs did run, so "already fastest" is true for those; only the two restart candidates were never tried. - A stricter guard may be deliberate protection for PCs that do other work ("leave 20% for my work"); the sketch keeps the post-run `_memory_overrun` checks, which still stop a candidate that really uses more. - One machine. We did not test the sketch. ### Smallest steps or command that reproduce it ```text strata launch --stop strata launch --family qwen --model iq3_xxs --model-path <dir> --context 64k --kv int8 --vision on --parallel 1 --drafting dflash2 \ --tune quick --tune-allow-small --retune --yes --no-tui # then read ~/.local/state/strata/launch/<name>.tune.json: result.arms[*].status / reason, result.base.rss_peak_mib / min_avail_mib ``` 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-small` but without `--retune`, which printed "already tuned ... so that result is used and nothing is measured again" (as designed); and the `--retune --tune-allow-small` run 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 on ### Logs The relevant part of `<name>.tune.json` (GitHub does not take `.json` attachments), paths removed: <details><summary>tune.json excerpt</summary> ```json { "outcome": "default_confirmed", "mode": "quick", "base": { "decode_tok_s": 139.5, "decode_runs": [ 124.4, 143.0, 130.9, 141.2, 139.5 ], "pp_tok_s": 2261.5, "ttft_s": 1.8217999999999999, "rss_peak_mib": 23429.0, "min_avail_mib": 2799, "vram_used_mib": 30313 }, "base_facts": { "slots": 12995, "workers": 11, "pcie_gbs": 28.3, "pcie_frac": 0.4, "chunk": 8192, "avail_gib": 23.1, "resident_ram": true, "hybrid_experts": false, "unknown_argument": false }, "arms": [ { "id": "spec3", "label": "Shorter speculative window (3 tokens)", "status": "skipped", "reason": "not enough free memory to start it safely (24.1 GiB free, 26.4 GiB needed)" }, { "id": "prefill_32k", "label": "Larger prompt chunks (faster very long prompts)", "status": "skipped", "reason": "not enough free memory to start it safely (24.1 GiB free, 30.4 GiB needed)" } ], "skipped": [ { "id": "kv_resident_64k", "label": "Keep more of the conversation in graphics memory", "reason": "this PC does not match: ctx ge 128k" }, { "id": "adapt_async", "label": "Learn which experts to keep while you chat, in the background", "reason": "answers would not repeat run to run; tick 'allow settings that are not repeatable' to try it" }, { "id": "adapt_tier_fast", "label": "Re-balance the expert cache faster", "reason": "this engine does not accept --adapt-every, --adapt-swaps, --adapt-decay" }, { "id": "adapt_decay_09", "label": "Forget old expert use a little faster", "reason": "this engine does not accept --adapt-decay" }, { "id": "host_core_last", "label": "Run the control thread on the last CPU core", "reason": "only tried in the thorough tune (it was measured as flat)" }, { "id": "kv_grow", "label": "Allocate the conversation memory as it grows", "reason": "only tried in the thorough tune (it was measured as flat)" } ] } ``` </details>
Author
Owner

@Rhycecomley commented on GitHub (Nov 3, 2026):

Same guard on a second machine, and this one confirms the guess in the report: in --mmap-experts mode the base run's rss_peak_mib is mostly the mapped expert files, so _ram_guard asks 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:

[strata] mapping the experts from the model files (about 58 GB, --mmap-experts): they are not loaded into RAM - the OS file cache reads them as the GPU's expert cache fills and as requests need them.
[strata] filling the GPU's expert cache (4782 experts, 4.67 GiB of VRAM) ...

From <name>.tune.json:

base run:  rss_peak_mib 15719   min_avail_mib 13428   facts.avail_gib 15.3   resident_ram false   decode 14.3 tok/s
pin_by_need     skipped  not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed)
host_core_last  skipped  not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed)
kv_grow         skipped  not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed)

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 top showed 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. With min_free_ram_mib 3584 + rss_peak 15719 = 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 + RssShmem from /proc/<pid>/status, summed over the tree, kept as a high-water mark while the run lasts) rather than ps -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.

<!-- gh-comment-id:6606085582 --> @Rhycecomley commented on GitHub (Nov 3, 2026): Same guard on a second machine, and this one confirms the guess in the report: in `--mmap-experts` mode the base run's `rss_peak_mib` is mostly the mapped expert files, so `_ram_guard` asks 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: ```text [strata] mapping the experts from the model files (about 58 GB, --mmap-experts): they are not loaded into RAM - the OS file cache reads them as the GPU's expert cache fills and as requests need them. [strata] filling the GPU's expert cache (4782 experts, 4.67 GiB of VRAM) ... ``` From `<name>.tune.json`: ```text base run: rss_peak_mib 15719 min_avail_mib 13428 facts.avail_gib 15.3 resident_ram false decode 14.3 tok/s pin_by_need skipped not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed) host_core_last skipped not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed) kv_grow skipped not enough free memory to start it safely (16.9 GiB free, 18.9 GiB needed) ``` 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 `top` showed 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. With `min_free_ram_mib` 3584 + `rss_peak` 15719 = 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` + `RssShmem` from `/proc/<pid>/status`, summed over the tree, kept as a high-water mark while the run lasts) rather than `ps -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.
Author
Owner

@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.

  • spec3: set --spec to 3 in the model config's "args" (mine is 4), restart, and compare.
  • prefill_32k: set --prefill to auto: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):

systemd-run --scope -p MemoryMax=$(awk '/MemTotal/ {printf "%dK", $2 * 0.94}' /proc/meminfo) -p MemorySwapMax=0 <your usual launch command>

I have not run this against the tune command itself, only by hand like this. Hope it helps.

<!-- gh-comment-id:6608138620 --> @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. - spec3: set `--spec` to 3 in the model config's "args" (mine is 4), restart, and compare. - prefill_32k: set `--prefill` to `auto: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): ```bash systemd-run --scope -p MemoryMax=$(awk '/MemTotal/ {printf "%dK", $2 * 0.94}' /proc/meminfo) -p MemorySwapMax=0 <your usual launch command> ``` I have not run this against the tune command itself, only by hand like this. Hope it helps. - Sangharsh. I keep a fork for this kind of PC (12 GB card, 30 GB RAM): https://github.com/sangharshadhyeta/Strata-HotRod
Author
Owner

@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, --set on 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=3 the launcher wrote --spec 3 into 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's spec3 arm 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):

prompts ~7K tokens, prefill tok/s (median, range) prompts ~30K tokens, prefill tok/s decode tok/s, 6 runs (median, range)
control 1 765 (350 to 1622) 975 (654 to 2339) 120 (109 to 127)
spec3 (really a control) 779 (642 to 968) 1525 (1142 to 1819) 128 (115 to 153)
prefill_32k 716 (336 to 1920) 270 (241 to 277) 134 (125 to 149)
control 2 1191 (548 to 2660) 1425 (1226 to 1973) 139 (134 to 143)
  • On about 30K-token prompts prefill_32k was 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.
  • On about 7K-token prompts and on decode the variant sits inside the spread of the controls. Prefill varies a lot even between identical launches (350 to 2660 tok/s), so I would not trust a gain or loss under about 2x on prefill, or under about 15% on decode, from this setup.
  • I have no explanation. The arm is listed with 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_32k may 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.

<!-- gh-comment-id:6610471259 --> @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, `--set` on 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=3` the launcher wrote `--spec 3` into 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's `spec3` arm 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`):** | | prompts ~7K tokens, prefill tok/s (median, range) | prompts ~30K tokens, prefill tok/s | decode tok/s, 6 runs (median, range) | |---|---|---|---| | control 1 | 765 (350 to 1622) | 975 (654 to 2339) | 120 (109 to 127) | | `spec3` (really a control) | 779 (642 to 968) | 1525 (1142 to 1819) | 128 (115 to 153) | | `prefill_32k` | 716 (336 to 1920) | 270 (241 to 277) | 134 (125 to 149) | | control 2 | 1191 (548 to 2660) | 1425 (1226 to 1973) | 139 (134 to 143) | - On about 30K-token prompts `prefill_32k` was 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. - On about 7K-token prompts and on decode the variant sits inside the spread of the controls. Prefill varies a lot even between identical launches (350 to 2660 tok/s), so I would not trust a gain or loss under about 2x on prefill, or under about 15% on decode, from this setup. - I have no explanation. The arm is listed with `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_32k` may 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.
Author
Owner

@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.

<!-- gh-comment-id:6614479362 --> @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/<engine pid>/status while the base run is up, would show whether the base run's peak is real memory or mapped file pages.
Author
Owner

@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.

  • The engine runs in the resident RAM mode, not --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>/status of 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): RssAnon 21.05 GiB, RssFile 0.06 GiB, RssShmem 0.07 GiB. So the resident set is almost entirely private memory, and the tuner's rss_peak_mib of 23,429 for the base run is real memory, not mapped file pages. MemAvailable on 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.

<!-- gh-comment-id:6628188604 --> @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. - The engine runs in the resident RAM mode, not `--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>/status` of 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): `RssAnon` 21.05 GiB, `RssFile` 0.06 GiB, `RssShmem` 0.07 GiB. So the resident set is almost entirely private memory, and the tuner's `rss_peak_mib` of 23,429 for the base run is real memory, not mapped file pages. `MemAvailable` on 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.
Author
Owner

@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 as facts.avail_gib, tune_session.py:104), and the session keeps the lowest MemAvailable seen 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:

                        avail at start   min avail   taken     + floor 3.5   free at guard   result
resident (this report)  23.1 GiB         2.7 GiB     20.4 GiB  23.9 GiB      24.1 GiB        spec3 fits; prefill_32k (+4 GiB = 27.9) still skipped
mmap (my VM)            15.3 GiB         13.1 GiB    2.2 GiB   5.7 GiB       16.9 GiB        all three fit

Today _ram_guard (autotune.py:278-282) uses base_rss + floor instead: 26.4 and 18.9 GiB, which is why both PCs skip everything. A sketch, not run:

             need = self.o.min_free_ram_mib + delta_mib
             base_rss = self.base_runs[0].rss_peak_mib if self.base_runs else None
-            if base_rss:
-                need += base_rss
+            taken = self._base_taken_mib()   # facts.avail_gib*1024 - min_avail_mib of the first base run, or None
+            if taken is not None:
+                need += taken
+            elif base_rss:
+                need += base_rss

Caveats:

  • Anything else that allocates during the base run counts as "taken", so this estimate leans high, which is the safe side. Something that frees memory during the run would make it lean low; _memory_overrun still catches a candidate that really uses more.
  • avail_gib is logged to 0.1 GiB, and on the resident PC the margin is only about 0.2 GiB, so spec3 would just barely pass there. Maybe use max(taken, rss_anon) if private RSS is ever measured.
  • On the resident PC "taken" (20.4 GiB) is about 2.5 GiB less than 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 3 with --spec 6 under DFlash2 matches what I see on the 3060. The arm in tune_knobs.py:96 has only classes=("A", "B") and no drafter condition, so on DFlash2 setups the tuner would probably measure a second copy of the base and call it spec3. 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.

<!-- gh-comment-id:6635144726 --> @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 as `facts.avail_gib`, `tune_session.py:104`), and the session keeps the lowest `MemAvailable` seen 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: ```text avail at start min avail taken + floor 3.5 free at guard result resident (this report) 23.1 GiB 2.7 GiB 20.4 GiB 23.9 GiB 24.1 GiB spec3 fits; prefill_32k (+4 GiB = 27.9) still skipped mmap (my VM) 15.3 GiB 13.1 GiB 2.2 GiB 5.7 GiB 16.9 GiB all three fit ``` Today `_ram_guard` (`autotune.py:278-282`) uses `base_rss + floor` instead: 26.4 and 18.9 GiB, which is why both PCs skip everything. A sketch, not run: ```diff need = self.o.min_free_ram_mib + delta_mib base_rss = self.base_runs[0].rss_peak_mib if self.base_runs else None - if base_rss: - need += base_rss + taken = self._base_taken_mib() # facts.avail_gib*1024 - min_avail_mib of the first base run, or None + if taken is not None: + need += taken + elif base_rss: + need += base_rss ``` Caveats: - Anything else that allocates during the base run counts as "taken", so this estimate leans high, which is the safe side. Something that *frees* memory during the run would make it lean low; `_memory_overrun` still catches a candidate that really uses more. - `avail_gib` is logged to 0.1 GiB, and on the resident PC the margin is only about 0.2 GiB, so `spec3` would just barely pass there. Maybe use `max(taken, rss_anon)` if private RSS is ever measured. - On the resident PC "taken" (20.4 GiB) is about 2.5 GiB less than `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 3` with `--spec 6` under DFlash2 matches what I see on the 3060. The arm in `tune_knobs.py:96` has only `classes=("A", "B")` and no drafter condition, so on DFlash2 setups the tuner would probably measure a second copy of the base and call it `spec3`. 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.
Author
Owner

@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

<!-- gh-comment-id:6658444324 --> @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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2395
No description provided.