Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

serve: a --resident-budget-gib above the free RAM is a warning at start (#1080)

Niko12219d692d8d0268
diff --git a/serve/server.py b/serve/server.py
index f10bda9b3..9e360e0fd 100644
--- a/serve/server.py
+++ b/serve/server.py
@@ -4695,6 +4695,29 @@ def warn_tight_ram(arena_mib) -> None:
+ "Close other programs, or run START-HERE --setup and pick a smaller size (Q2_0 / IQ2_XS).", flush=True)
+def warn_budget_over_ram(args) -> str | None:
+ """#1080: an explicit `--resident-budget-gib N` bigger than the RAM this PC has free (or than its total beside
+ ~6 GB for everything else) pushes experts into swap or the file tier: decode that is "dead slow" until the number is
+ removed. A warning at start, never a refusal (recommend, never force). -> the sentence printed, or None."""
+ try:
+ budget = float(args[list(args).index("--resident-budget-gib") + 1])
+ except (ValueError, IndexError):
+ return None
+ try:
+ import psutil
+ vm = psutil.virtual_memory()
+ total, free = vm.total / 2**30, vm.available / 2**30
+ except Exception: # noqa: BLE001 - psutil is optional here
+ return None
+ if budget <= free and budget <= total - 6:
+ return None
+ msg = (f"WARNING: the RAM budget for experts is {budget:g} GiB (--resident-budget-gib), but this PC has "
+ f"{free:.0f} GiB free of {total:.0f} GiB: what does not fit goes to swap or is read from disk, which can make "
+ "decoding very slow. Lower it (setup sizes it for this PC) or remove the argument to let the engine choose.")
+ print("[strata] " + msg, flush=True)
+ return msg
+
+
DESKTOP_FREE_MIB = 2048 # #560 #516: below this, an AMD card that also drives a Linux desktop can run out
DESKTOP_RESERVE_MIB = 3072 # what kept KDE/Wayland alive beside a full expert cache in both reports
@@ -5094,6 +5117,7 @@ def main() -> int:
env=vision_env(cfg, env), lazy=lazy)
print("model unloaded; the first request loads it ..." if lazy else
"loading the model (the first start takes a minute or two) ...", flush=True)
+ warn_budget_over_ram(engine_args(cfg) if "args" in cfg else []) # #1080
if layer_split_of(cfg):
try:
split = layer_split_value(cfg) # #644: before the (minutes-long) start
diff --git a/serve/test_server.py b/serve/test_server.py
index 2e9449d58..8a07de829 100644
--- a/serve/test_server.py
+++ b/serve/test_server.py
@@ -4186,6 +4186,32 @@ class VisionCacheEviction(unittest.TestCase):
self.assertFalse(first.exists())
+class BudgetOverRam(unittest.TestCase):
+ """#1080: a RAM budget above what the PC has free is a warning at start, not silence and not a refusal."""
+
+ def run_with(self, budget, total, free):
+ import serve.server as S
+ vm = SimpleNamespace(total=total * 2**30, available=free * 2**30)
+ fake = SimpleNamespace(virtual_memory=lambda: vm)
+ with mock.patch.dict(sys.modules, {"psutil": fake}), contextlib.redirect_stdout(io.StringIO()):
+ return S.warn_budget_over_ram(["--native", "x", "--resident-budget-gib", str(budget)])
+
+ def test_over_free_ram_warns(self):
+ msg = self.run_with(55, 64, 30)
+ self.assertIn("55 GiB", msg)
+ self.assertIn("30 GiB free of 64", msg)
+
+ def test_over_total_less_headroom_warns(self):
+ self.assertIsNotNone(self.run_with(60, 64, 60))
+
+ def test_a_budget_that_fits_is_quiet(self):
+ self.assertIsNone(self.run_with(40, 64, 50))
+
+ def test_no_budget_argument_is_quiet(self):
+ import serve.server as S
+ self.assertIsNone(S.warn_budget_over_ram(["--native", "x"]))
+
+
class LazyVision(unittest.TestCase):
"""#673: with --lazy the image encoder is not started either; it starts with the model, and an encoder that fails
to start leaves nothing running."""