serve: the run config's "slot_cache_mib" starts the Inkling engine with --slot-cache-mib (#7620); settings register entry

"slot_cache_mib": N (MiB of host RAM, 0 or absent = off, the default) in the run config becomes `--slot-cache-mib N` for strata-inkling, only for an engine
that has the option (the flag's name is looked for in the program, as for --tail-role-token; an older engine refuses an option it does not know), and an
option the person put in the arguments wins. The key is in the editable run-config keys. STRATA_INK_SLOT_CACHE_MIB is in the settings register (opt-in)
and docs/SETTINGS.md; the register's line numbers moved with the serve-loop change of the previous commit.

Tests: serve/test_inkling_slot_cache_args.py (engine with and without the option, off values, the person's own flag, a missing program, the key).
This commit is contained in:
Niko1221 committed 2026-12-02 13:20:37 +01:00
1 parent 21699a4c08
commit 85cad3f51c
5 files changed
+403 -293

No files matched your search

+6 -5
View File
@@ -10,7 +10,7 @@ debugging and are kept in `terminal/data/settings-register.json`.
A number or a word is set like any environment variable, for example `STRATA_KVA=1`. In the Terminal, `strata launch --set NAME=value`
puts it in the model's run configuration.
## Switches you can turn on (453)
## Switches you can turn on (454)
Off unless you set them. The last column says where each one is described.
@@ -179,6 +179,7 @@ Off unless you set them. The last column says where each one is described.
| `STRATA_INK_R9700_TGRAPH_WARM` | on / off | AMD | - |
| `STRATA_INK_R9700_TREE_FP8_MOE` | text | AMD | - |
| `STRATA_INK_RAM_CAP_MB` | number | NVIDIA and AMD | - |
| `STRATA_INK_SLOT_CACHE_MIB` | number | NVIDIA and AMD | - |
| `STRATA_INK_SM120_BEAM` | number | NVIDIA | - |
| `STRATA_INK_SM120_BSPEC_KD` | number | NVIDIA and AMD | - |
| `STRATA_INK_SM120_C64_DRAFT_K` | number | NVIDIA | - |
@@ -509,8 +510,8 @@ version made it the default.
| `STRATA_IGPU_DEFAULTS` | on / off | NVIDIA and AMD | v0.2.16 | [AMD_HIP.md](AMD_HIP.md) |
| `STRATA_IGPU_PROMPT_SET` | on / off | NVIDIA and AMD | v0.2.16 | [AMD_HIP.md](AMD_HIP.md), [RADEON_780M.md](RADEON_780M.md), [release-notes-0.2.1.md](release-notes-0.2.1.md) |
| `STRATA_IL_PAD` | number | NVIDIA and AMD | v0.2.16 | - |
| `STRATA_INK_5090_DRAFTPOL` | text | NVIDIA | - | - |
| `STRATA_INK_5090_PF_ATOMIC` | on / off | NVIDIA and AMD | - | - |
| `STRATA_INK_5090_DRAFTPOL` | text | NVIDIA | v0.2.24 | - |
| `STRATA_INK_5090_PF_ATOMIC` | on / off | NVIDIA and AMD | v0.2.24 | - |
| `STRATA_INK_CHUNK_AUTO` | number | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_EXACT_GRAPH` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_EXACT_ROWS` | on / off | AMD | v0.2.21 | - |
@@ -521,13 +522,13 @@ version made it the default.
| `STRATA_INK_IQ_TC` | on / off | NVIDIA and AMD | v0.2.23 | - |
| `STRATA_INK_IQ_TC_MASK` | number | NVIDIA and AMD | v0.2.23 | - |
| `STRATA_INK_KEEP_MAPPED_PAGES` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_KV_VMM` | on / off | NVIDIA and AMD | - | [INKLING_KV.md](INKLING_KV.md) |
| `STRATA_INK_KV_VMM` | on / off | NVIDIA and AMD | v0.2.24 | [INKLING_KV.md](INKLING_KV.md) |
| `STRATA_INK_MOE_V1` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_NO_CAND` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_OOM_RETRY` | number | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_PF_TILE` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_PIN_GB` | on / off | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_PREFILL_MIN_SLOT` | number | NVIDIA and AMD | - | - |
| `STRATA_INK_PREFILL_MIN_SLOT` | number | NVIDIA and AMD | v0.2.24 | - |
| `STRATA_INK_PROMOTE_ASYNC` | text | AMD | v0.2.21 | - |
| `STRATA_INK_Q80_TC` | number | NVIDIA and AMD | v0.2.21 | - |
| `STRATA_INK_Q8_0_DENSE` | on / off | NVIDIA and AMD | v0.2.21 | - |
File diff suppressed because it is too large. Load diff
+22
View File
@@ -323,9 +323,31 @@ def engine_args(cfg: dict, exe: str | None = None, *, announce: bool = True) ->
if announce:
print(f"[strata] {NO_IMAGES_NOTE}", flush=True)
args = fit_vision_reader(args, cfg, info, announce)
args = slot_cache_args(args, cfg, exe, announce)
return args
def slot_cache_args(args: list, cfg: dict, exe: str | None, announce: bool = True) -> list:
"""#7620: the run config's "slot_cache_mib" (host RAM for conversations the engine parks instead of overwriting, MiB; 0 / absent = off, the default) as
`--slot-cache-mib N`, only for an engine that has the option (an older one refuses an option it does not know): the flag's name is looked for in the
program, as effort_end_args does for --tail-role-token. An option already in the arguments (the person's own) wins."""
mib = cfg.get("slot_cache_mib")
if isinstance(mib, bool) or not isinstance(mib, int) or mib <= 0 or "--slot-cache-mib" in args:
return args
try:
with open(str(exe), "rb") as f:
known = b"--slot-cache-mib" in f.read()
except (OSError, TypeError):
known = False
if not known:
if announce:
print('[strata] "slot_cache_mib" is set, but this engine has no --slot-cache-mib: conversations are not parked (update Strata)', flush=True)
return args
if announce:
print(f"[strata] slot cache: up to {mib} MiB of RAM keep a conversation the engine would overwrite (a title, a summary, a helper), and put it back", flush=True)
return args + ["--slot-cache-mib", str(mib)]
def detected_reader(cfg: dict) -> tuple[str | None, float]:
"""(the picture reader this machine's rule gives (strata_control/vision_reader.py inkling_reader) for a run config that has none, the card's memory in GiB):
from the backend and the card's total memory (NVML, the amdgpu files). (None, 0.0) where it cannot be told: several cards, no reading, the CPU engine;
+1
View File
@@ -30,6 +30,7 @@ EDITABLE = [
"Anthropic requests that do not ask for thinking: think as the model does (model) or not (on_request)"),
("effort_position", ("enum", ["start", "end"]),
"Where a non-default reasoning effort goes: start (the default) or end (keeps the cache when it changes)"),
("slot_cache_mib", "int>=0", "Inkling-2-Mini: MiB of RAM that keep a conversation the engine would overwrite (a title, a summary, a helper) and put it back; 0 or empty: off"),
("aliases", "names", "Other model names the server lists and answers to (comma-separated)"),
("idle_unload_s", "num>=0", "Unload the model after this many seconds without requests (0 or empty: never)"),
("mtp", "bool", "Draft layer (MTP): off starts the engine without it (about 1 GB less graphics memory, slower words per second); "
@@ -0,0 +1,53 @@
"""#7620: the run config's "slot_cache_mib" becomes `--slot-cache-mib N` for an Inkling engine that has the option, and only then.
python -m pytest serve/test_inkling_slot_cache_args.py
"""
from __future__ import annotations
import sys
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from serve import inkling_kind, runconfig # noqa: E402
class SlotCacheArgs(unittest.TestCase):
def exe(self, with_flag: bool) -> str:
d = Path(tempfile.mkdtemp())
self.addCleanup(lambda: [p.unlink() for p in d.iterdir()] or d.rmdir())
p = d / "strata-inkling"
p.write_bytes(b"\x7fELF ... --tail-role-token ... " + (b"--slot-cache-mib " if with_flag else b"") + b"... end")
return str(p)
def test_an_engine_with_the_option_gets_it(self):
out = inkling_kind.slot_cache_args(["--native", "m"], {"slot_cache_mib": 2048}, self.exe(True), announce=False)
self.assertEqual(out, ["--native", "m", "--slot-cache-mib", "2048"])
def test_an_engine_without_it_is_left_alone(self):
args = ["--native", "m"]
self.assertEqual(inkling_kind.slot_cache_args(args, {"slot_cache_mib": 2048}, self.exe(False), announce=False), args)
def test_nothing_is_added_when_the_key_is_off_or_not_a_number(self):
exe = self.exe(True)
for value in (None, 0, -5, "2048", True, 1.5):
cfg = {} if value is None else {"slot_cache_mib": value}
self.assertEqual(inkling_kind.slot_cache_args(["--native", "m"], cfg, exe, announce=False), ["--native", "m"], value)
def test_the_persons_own_option_wins(self):
args = ["--native", "m", "--slot-cache-mib", "512"]
self.assertEqual(inkling_kind.slot_cache_args(args, {"slot_cache_mib": 2048}, self.exe(True), announce=False), args)
def test_a_missing_program_is_no_error(self):
self.assertEqual(inkling_kind.slot_cache_args(["--native", "m"], {"slot_cache_mib": 2048}, "/no/such/exe", announce=False), ["--native", "m"])
self.assertEqual(inkling_kind.slot_cache_args(["--native", "m"], {"slot_cache_mib": 2048}, None, announce=False), ["--native", "m"])
def test_the_key_is_a_known_run_config_key(self):
self.assertIn("slot_cache_mib", [row[0] for row in runconfig.EDITABLE])
if __name__ == "__main__":
unittest.main()