Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

OOM guard: leave dedicated GPUs near-full and fix unified caps

Resynth336f8e6cbb0d
diff --git a/doc/env_vars.md b/doc/env_vars.md
index 64db030..a2e3fcd 100644
--- a/doc/env_vars.md
+++ b/doc/env_vars.md
@@ -718,12 +718,14 @@ it does not add capacity. Set it in the lane profile before `import exllamav3` f
Pre-flight memory guard: `auto` refuses a load whose measured weights, cache, part0 slab and
prefill workspace do not fit before allocating anything; `off` disables the check. The guard is
-read-only and never changes allocator settings or outputs.
+read-only and never changes allocator settings or outputs. `1`/`true`/`yes`/`on` are accepted as
+`auto`, and `0`/`false`/`no`/`none` as `off`, matching the launcher-style `MEMGUARD=0/1` values.
-There is no per-device GTT or VRAM reserve. Each device's cap is its own reported
-`min(mem_get_info().free, mem_get_info().total)`. A dedicated-VRAM allocation failure is a
-process-level error; the host floor is what protects the unified-memory box from kernel
-starvation.
+There is no per-device GTT or VRAM reserve. Dedicated GPUs are limited by their free VRAM;
+unified-memory devices also account for reclaimable page cache and the shared host floor, so
+cached model shards do not make a fitting load look too large. A dedicated-VRAM allocation
+failure is a process-level error; the host floor is what protects the unified-memory box from
+kernel starvation.
### `MEMGUARD_FLOOR` (default: `8`)
@@ -731,7 +733,8 @@ The host `MemAvailable` floor, used by both the pre-flight guard and `exllamav3/
The preflight plans against `MemAvailable - (floor + margin)`; the supervisor SIGKILLs when
`MemAvailable < floor`. The name is the established memguard variable, so existing lanes
keep working. Raise it for a hungrier OS or more background services; lower it only after
-measuring.
+measuring. A non-numeric value is reported on stderr and falls back to the default, rather
+than silently changing the safety floor.
### `KYOJIN_OOM_GUARD_PREFLIGHT_MARGIN_GIB` (default: `1`)
@@ -744,7 +747,7 @@ exactly at the floor.
Estimated transient prefill workspace added to unified (integrated-memory) device footprints;
dedicated devices use 0. The default 2.0 GiB is a planning estimate, not a universal measurement.
This is model/context dependent; raise it for a model with a larger prefill scratch area. It is
-not a reserve: the device cap remains its own reported free memory.
+not a reserve.
### `EXL3_LOAD_ARENA` (default: `1`)
diff --git a/doc/split.md b/doc/split.md
index 43e0b32..505058b 100644
--- a/doc/split.md
+++ b/doc/split.md
@@ -90,14 +90,18 @@ Text endcaps are selected by a class/key allowlist, not by per-model placement i
### Pre-flight guard
The guard estimates each device's footprint from actual bytes: weights, KV/recurrent cache,
-the part0 load slab and, on unified-memory devices only, a prefill workspace. The device cap is
-the device itself:
+the part0 load slab and, on unified-memory devices only, a prefill workspace. The caps are:
```text
-device_cap = min(mem_get_info().free, mem_get_info().total)
-host_cap = MemAvailable - (host_floor + preflight_margin)
+dedicated device_cap = min(mem_get_info().free, mem_get_info().total)
+unified device_cap = min(total, max(mem_get_info().free, MemAvailable))
+host_cap = MemAvailable - (host_floor + preflight_margin)
```
+On unified devices, `MemAvailable` covers reclaimable page cache, which some runtimes report as
+used device memory; `total` bounds the visible aperture. A component added after the target load
+may also reuse the process's cached allocator blocks; treat that part as a planning estimate.
+
Dedicated devices plan without a workspace: `auto` refuses only a hard overcommit of
weights+cache+slab, and does not refuse a load that merely leaves less than the workspace
estimate. A dedicated prefill allocation failure is a process-level error. Unified devices add
@@ -115,8 +119,8 @@ table plus the chosen N/context and the largest N/context that fits. `off` disab
check is read-only. For MTP-on, use the guard's recommendation instead of hand-picking N:
the drafter and its cache change the memory budget.
-The preflight's device caps are the devices' own free/full memory; the host cap follows
-the configured floor. A load that reaches the host floor is stopped by the supervisor.
+The device caps and the host cap are checked separately; a load that reaches the host floor is
+stopped by the supervisor.
### Allocator mode
diff --git a/examples/mimo_v2_6/serve.sh b/examples/mimo_v2_6/serve.sh
index c44f27b..1bb1dd6 100755
--- a/examples/mimo_v2_6/serve.sh
+++ b/examples/mimo_v2_6/serve.sh
@@ -238,9 +238,9 @@ export EXL3_DFLASH_RING="$DRAFT_RING"
export EXL3_LOAD_DEVICE="${EXL3_LOAD_DEVICE-cuda:0}"
[ -n "$EXL3_LOAD_DEVICE" ] && echo " -- EXL3_LOAD_DEVICE=$EXL3_LOAD_DEVICE (single-device load)"
-# memguard: SIGKILL the server's process group if MemAvailable or a device's free
-# memory falls below its floor, and fadvise(DONTNEED) the shards every 5 s so the
-# ~86 GiB of buffered-pread page cache never shadows the same weights in one pool.
+# memguard: SIGKILL the server's process group if host MemAvailable falls below
+# its floor, and fadvise(DONTNEED) the shards every 5 s so the ~86 GiB of
+# buffered-pread page cache never shadows the same weights in one pool.
use_mg=0
case "$MEMGUARD" in
1) use_mg=1 ;;
diff --git a/exllamav3/device_map.py b/exllamav3/device_map.py
index 2469ab1..19265f5 100644
--- a/exllamav3/device_map.py
+++ b/exllamav3/device_map.py
@@ -48,6 +48,7 @@ from .memory_guard import (
OOMGuard,
check_single_device,
device_free_bytes,
+ device_reusable_bytes,
device_total_bytes,
host_available_bytes,
)
@@ -1024,7 +1025,11 @@ class SplitPlan:
return out
def _guard_probe(self) -> dict[int, tuple[int | None, int | None]]:
- return {index: (device_total_bytes(index), device_free_bytes(index))
+ # Before any load the raw free number is the honest cap. Once a target is
+ # resident, a late component (MTP, vision) can reuse the allocator's cached
+ # blocks; raw free would refuse a load that fits.
+ usable = device_reusable_bytes if self.records else device_free_bytes
+ return {index: (device_total_bytes(index), usable(index))
for index in self._guard_device_ids()}
def _largest_guard_n(self, guard: OOMGuard, probe, host_available, infos,
diff --git a/exllamav3/guard.py b/exllamav3/guard.py
index 37ac112..8cfa4e2 100755
--- a/exllamav3/guard.py
+++ b/exllamav3/guard.py
@@ -26,6 +26,7 @@ Options
--interval S poll period in seconds (default 0.5)
--warn-gib F log a warning below this (default floor + 8)
--log PATH also append the trace here
+ --log-max-mb F rotate --log to PATH.1 at F MiB (default 16; 0 off)
--grace S seconds to wait after SIGKILL (default 30)
--sample-every S append a host-memory sample to the log every S seconds
--fadvise-dir DIR release DIR/*.safetensors page cache periodically
@@ -102,19 +103,61 @@ def _open_log(path: str):
class Logger:
- def __init__(self, path: str | None):
+ def __init__(self, path: str | None, max_bytes: int = 16 * 1024 * 1024):
+ self.path = path
+ self.max_bytes = max(0, int(max_bytes))
+ self.size = 0
self.fh = None
if path:
+ try:
+ self.size = os.path.getsize(path)
+ except OSError:
+ self.size = 0
try:
self.fh = _open_log(path)
except OSError as exc:
print(f"[guard] cannot open log {path}: {exc}", file = sys.stderr, flush = True)
+ def _rotate(self) -> None:
+ if not self.fh or not self.path:
+ return
+ self.fh.close()
+ try:
+ os.replace(self.path, self.path + ".1")
+ except OSError as exc:
+ # A failed rename (PATH.1 is a directory, a pinned file, ...) must not
+ # defeat the cap: truncate the log instead of growing without bound.
+ print(f"[guard] could not rotate {self.path} ({exc}); truncating log",
+ file = sys.stderr, flush = True)
+ try:
+ flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
+ if hasattr(os, "O_NOFOLLOW"):
+ flags |= os.O_NOFOLLOW
+ fd = os.open(self.path, flags, 0o600)
+ self.fh = os.fdopen(fd, "a", buffering = 1)
+ self.size = 0
+ except OSError as reopen_exc:
+ self.fh = None
+ print(f"[guard] cannot reopen log {self.path}: {reopen_exc}",
+ file = sys.stderr, flush = True)
+ return
+ try:
+ self.fh = _open_log(self.path)
+ self.size = 0
+ except OSError as exc:
+ self.fh = None
+ print(f"[guard] cannot reopen log {self.path}: {exc}", file = sys.stderr, flush = True)
+
def __call__(self, msg: str) -> None:
line = f"[guard {time.strftime('%H:%M:%S')}] {msg}"
print(line, file = sys.stderr, flush = True)
if self.fh:
- self.fh.write(line + "\n")
+ data = line + "\n"
+ if self.max_bytes and self.size + len(data) > self.max_bytes:
+ self._rotate()
+ if self.fh:
+ self.fh.write(data)
+ self.size += len(data)
def kill_tree(pid: int, sig: int) -> None:
@@ -134,6 +177,8 @@ def main() -> int:
ap.add_argument("--warn-gib", type = float, default = None)
ap.add_argument("--interval", type = float, default = 0.5)
ap.add_argument("--log", type = str, default = None)
+ ap.add_argument("--log-max-mb", type = float, default = 16.0,
+ help = "rotate --log to PATH.1 when it reaches this size (0 disables)")
ap.add_argument("--grace", type = float, default = 30.0)
ap.add_argument("--label", type = str, default = None)
ap.add_argument("--sample-every", type = float, default = 0.0,
@@ -153,7 +198,7 @@ def main() -> int:
ap.add_argument("cmd", nargs = argparse.REMAINDER)
args = ap.parse_args()
- log = Logger(args.log)
+ log = Logger(args.log, max_bytes = int(max(0.0, args.log_max_mb) * 1024 ** 2))
if args.selftest:
mi = meminfo()
diff --git a/exllamav3/guard_common.py b/exllamav3/guard_common.py
index a13b9e2..1ecfe52 100644
--- a/exllamav3/guard_common.py
+++ b/exllamav3/guard_common.py
@@ -6,7 +6,9 @@ supervisor can start without importing torch or the package.
from __future__ import annotations
+import math
import os
+import sys
DEFAULT_HOST_FLOOR_GIB = 8.0
@@ -20,7 +22,12 @@ def host_floor_from_env() -> float:
value = os.environ.get("MEMGUARD_FLOOR")
if value:
try:
- return max(0.0, float(value))
+ floor = float(value)
except ValueError:
- pass
+ floor = None
+ if floor is None or not math.isfinite(floor):
+ print(f"[memguard] ignoring invalid MEMGUARD_FLOOR={value!r}; "
+ f"using {DEFAULT_HOST_FLOOR_GIB:g} GiB", file = sys.stderr, flush = True)
+ return DEFAULT_HOST_FLOOR_GIB
+ return max(0.0, floor)
return DEFAULT_HOST_FLOOR_GIB
diff --git a/exllamav3/memory_guard.py b/exllamav3/memory_guard.py
index 1c4649a..6924a17 100644
--- a/exllamav3/memory_guard.py
+++ b/exllamav3/memory_guard.py
@@ -32,6 +32,11 @@ except ImportError: # loaded as a standalon
GIB = 1024 ** 3
MODES = ("auto", "off")
+MODE_ALIASES = {
+ "auto": "auto", "on": "auto", "1": "auto", "true": "auto", "yes": "auto",
+ "off": "off", "0": "off", "false": "off", "no": "off", "none": "off",
+ "disabled": "off",
+}
DEFAULT_PREFLIGHT_MARGIN_GIB = 1.0
DEFAULT_WORKSPACE_GIB = 2.0
@@ -55,9 +60,16 @@ class GuardPolicy:
workspace_gib: float = DEFAULT_WORKSPACE_GIB
def __post_init__(self) -> None:
- self.mode = (self.mode or "auto").strip().lower()
- if self.mode not in MODES:
- raise ValueError(f"oom guard mode must be one of {MODES}, not {self.mode!r}")
+ key = str(self.mode).strip().lower() if self.mode is not None else "auto"
+ if not key:
+ key = "auto"
+ mode = MODE_ALIASES.get(key)
+ if mode is None:
+ accepted = ", ".join(sorted(MODE_ALIASES))
+ raise ValueError(
+ f"oom guard mode must be one of {MODES} "
+ f"(aliases: {accepted}), not {key!r}")
+ self.mode = mode
self.host_floor_gib = max(0.0, float(self.host_floor_gib))
self.preflight_margin_gib = max(0.0, float(self.preflight_margin_gib))
self.workspace_gib = max(0.0, float(self.workspace_gib))
@@ -134,6 +146,28 @@ def device_free_bytes(index: int) -> int | None:
return None
+def device_reusable_bytes(index: int) -> int | None:
+ """Device free bytes plus this process's cached-but-unused allocator blocks.
+
+ ``mem_get_info`` reports driver-free memory, so blocks the caching allocator
+ has reserved but not allocated look used. A component added after the target
+ load (MTP, vision) can reuse those blocks, and raw free would refuse a load
+ that fits. Falls back to raw free when the allocator counters are unavailable.
+ """
+ try:
+ torch = _torch()
+ free, _total = torch.cuda.mem_get_info(int(index))
+ free = int(free)
+ try:
+ reserved = int(torch.cuda.memory_reserved(int(index)))
+ allocated = int(torch.cuda.memory_allocated(int(index)))
+ except Exception: # noqa: BLE001 - counters are optional
+ return free
+ return free + max(0, reserved - allocated)
+ except Exception: # noqa: BLE001 - unavailable probe
+ return None
+
+
def is_unified_device(index: int) -> bool:
"""True only when the runtime reports unified/integrated memory for the device.
@@ -170,15 +204,25 @@ class DeviceFootprint:
return (int(self.weights_bytes) + int(self.cache_bytes)
+ int(self.slab_bytes) + int(self.workspace_bytes))
- def capacity_bytes(self) -> int | None:
- """The device cap is its own free/total memory; no device reserve."""
- if self.total_bytes is None and self.free_bytes is None:
+ def capacity_bytes(self, host_available: int | None = None) -> int | None:
+ """The device cap, bounded by its aperture and (on unified) the host pool.
+
+ A unified device shares the host pool, and some runtimes report MemFree,
+ so a growing page cache looks like used device memory. The host view is
+ an alternative bound there because those pages are reclaimable; ``total``
+ still clamps the device's visible aperture. Dedicated devices keep the
+ raw free/total cap.
+ """
+ free = self.free_bytes
+ if self.unified and host_available is not None:
+ free = int(host_available) if free is None else max(int(free), int(host_available))
+ if self.total_bytes is None and free is None:
return None
- if self.free_bytes is None:
+ if free is None:
return int(self.total_bytes)
if self.total_bytes is None:
- return int(self.free_bytes)
- return min(int(self.total_bytes), int(self.free_bytes))
+ return int(free)
+ return min(int(self.total_bytes), int(free))
def describe(self) -> str:
parts = [f"cuda:{self.index}"]
@@ -305,13 +349,15 @@ class OOMGuard:
def evaluate(self, footprints: Iterable[DeviceFootprint],
host_available: int | None = None) -> GuardReport:
footprints = list(footprints)
- results = [DeviceResult(fp, fp.capacity_bytes()) for fp in footprints]
+ unified = [fp for fp in footprints if fp.unified]
+ if unified and host_available is None:
+ host_available = host_available_bytes()
+ results = [DeviceResult(fp, fp.capacity_bytes(host_available if fp.unified else None))
+ for fp in footprints]
host = None
- if any(fp.unified for fp in footprints):
- if host_available is None:
- host_available = host_available_bytes()
+ if unified:
host = HostResult(available_bytes = host_available,
- need_bytes = sum(fp.need_bytes for fp in footprints if fp.unified),
+ need_bytes = sum(fp.need_bytes for fp in unified),
floor_bytes = int(self.policy.preflight_host_floor_gib * GIB))
return GuardReport(device_results = results, host_result = host)
diff --git a/tests/test_memory_guard_cpu.py b/tests/test_memory_guard_cpu.py
index 975f715..a9c9894 100644
--- a/tests/test_memory_guard_cpu.py
+++ b/tests/test_memory_guard_cpu.py
@@ -225,8 +225,84 @@ def test_unified_footprint_adds_the_workspace_and_plans_against_host(mg, monkeyp
assert fp.workspace_bytes == 5 * GIB
-def test_supervisor_host_floor_is_env_tunable(guard_mod, monkeypatch):
+def test_unified_capacity_uses_reclaimable_host_memory(mg, monkeypatch):
+ monkeypatch.setattr(mg, "is_unified_device", lambda _i: True)
+ guard = _guard(mg)
+
+ # A runtime that reports MemFree makes page cache look like used device memory.
+ fp = guard.footprint(0, total_bytes = 118 * GIB, free_bytes = 10 * GIB,
+ weights_bytes = 108 * GIB)
+ report = guard.check([fp], host_available = 120 * GIB)
+ assert report.ok
+ # MemAvailable is the alternative bound, clamped by the visible aperture.
+ assert report.device_results[0].capacity_bytes == 118 * GIB
+
+ # A genuine host deficit is still refused.
+ with pytest.raises(mg.OOMGuardError, match = "deficit"):
+ guard.check([fp], host_available = 110 * GIB)
+
+
+def test_guard_mode_accepts_boolean_like_values(mg, monkeypatch):
+ for value in ("0", "false", "no", "off", "disabled", " FALSE ", 0, False):
+ assert mg.GuardPolicy(mode = value).mode == "off"
+ for value in ("1", "true", "yes", "on", "auto", 1, True):
+ assert mg.GuardPolicy(mode = value).mode == "auto"
+ with pytest.raises(ValueError, match = "oom guard mode"):
+ mg.GuardPolicy(mode = "maybe")
+
+ monkeypatch.setenv("KYOJIN_OOM_GUARD", "0")
+ assert mg.GuardPolicy.from_env().mode == "off"
+
+
+def test_reusable_device_bytes_adds_cached_allocator_blocks(mg, monkeypatch):
+ monkeypatch.setattr(mg, "_torch", lambda: SimpleNamespace(cuda = SimpleNamespace(
+ mem_get_info = lambda _i: (5 * GIB, 16 * GIB),
+ memory_reserved = lambda _i: 3 * GIB,
+ memory_allocated = lambda _i: GIB)))
+ assert mg.device_reusable_bytes(0) == 7 * GIB
+
+ # Missing counters fall back to raw free; a failed probe means no opinion.
+ def boom(_i):
+ raise RuntimeError("no counters")
+
+ monkeypatch.setattr(mg, "_torch", lambda: SimpleNamespace(cuda = SimpleNamespace(
+ mem_get_info = lambda _i: (5 * GIB, 16 * GIB),
+ memory_reserved = boom,
+ memory_allocated = boom)))
+ assert mg.device_reusable_bytes(0) == 5 * GIB
+
+ monkeypatch.setattr(mg, "_torch", lambda: SimpleNamespace(cuda = SimpleNamespace(
+ mem_get_info = boom)))
+ assert mg.device_reusable_bytes(0) is None
+
+
+def test_supervisor_host_floor_is_env_tunable(guard_mod, monkeypatch, capsys):
monkeypatch.delenv("MEMGUARD_FLOOR", raising=False)
assert guard_mod.host_floor_from_env() == 8.0
monkeypatch.setenv("MEMGUARD_FLOOR", "9.5")
assert guard_mod.host_floor_from_env() == 9.5
+
+ # A safety setting must not silently fall back after a typo, and non-finite
+ # values must not disable the floor (nan) or crash the lane (inf).
+ for value in ("eight", "nan", "inf", "-inf", "1e999"):
+ monkeypatch.setenv("MEMGUARD_FLOOR", value)
+ assert guard_mod.host_floor_from_env() == 8.0
+ assert "MEMGUARD_FLOOR" in capsys.readouterr().err
+
+
+def test_supervisor_log_rotates_at_the_size_cap(guard_mod, tmp_path):
+ path = tmp_path / "memguard.log"
+ log = guard_mod.Logger(str(path), max_bytes = 200)
+ for i in range(20):
+ log(f"line {i} " + "x" * 20)
+ assert (tmp_path / "memguard.log.1").exists()
+ assert path.exists() and path.stat().st_size <= 200
+
+
+def test_supervisor_log_rotation_failure_still_caps_the_file(guard_mod, tmp_path):
+ path = tmp_path / "memguard.log"
+ (tmp_path / "memguard.log.1").mkdir() # makes os.replace fail
+ log = guard_mod.Logger(str(path), max_bytes = 200)
+ for i in range(20):
+ log(f"line {i} " + "x" * 20)
+ assert path.exists() and path.stat().st_size <= 200
diff --git a/tests/test_split_plan_cpu.py b/tests/test_split_plan_cpu.py
index a586b5e..2c6847c 100644
--- a/tests/test_split_plan_cpu.py
+++ b/tests/test_split_plan_cpu.py
@@ -744,6 +744,8 @@ def _fake_guard_probe(dm, monkeypatch, *, mg, part0_total=16 * 1024 ** 3,
lambda i: part0_total if i == 1 else part1_total)
monkeypatch.setattr(dm, "device_free_bytes",
lambda i: part0_total if i == 1 else part1_total)
+ monkeypatch.setattr(dm, "device_reusable_bytes",
+ lambda i: part0_total if i == 1 else part1_total)
monkeypatch.setattr(mg, "is_unified_device", lambda i: i == 0)
monkeypatch.setattr(dm, "host_available_bytes", lambda: host_available)
@@ -790,6 +792,63 @@ def test_split_plan_guard_passes_or_refuses_before_allocation(split_modules, mon
assert off.guard_report is None
+def test_preload_guard_uses_raw_free_not_allocator_cached(split_modules, monkeypatch):
+ """Before a target is resident, cached blocks do not make a load fit."""
+ dm, _bridge, _split = split_modules
+ mg = __import__("exllamav3.memory_guard", fromlist = ["OOMGuardError"])
+ gib = dm.GIB
+
+ text = FakeModel([FakeModule(f"layer.{i}", layer_idx = i) for i in range(4)])
+ text_cfg = FakeConfig({f"layer.{i}": gib // 2 for i in range(4)})
+ _fake_guard_probe(dm, monkeypatch, mg=mg)
+ monkeypatch.setattr(dm, "device_free_bytes", lambda _i: gib // 10)
+ monkeypatch.setattr(dm, "device_reusable_bytes", lambda _i: 16 * gib)
+
+ plan = dm.SplitPlan(_devices(dm), endcaps = True, part0_layers = 2,
+ guard = dm.OOMGuard(dm.GuardPolicy(mode = "auto"),
+ logger = lambda *_a: None),
+ logger = lambda *_a: None)
+ plan.add("text", text, config = text_cfg)
+ with pytest.raises(mg.OOMGuardError, match = "deficit"):
+ plan.build()
+
+
+def test_late_component_uses_allocator_cached_bytes(split_modules, monkeypatch):
+ """After the target load, reuse the allocator's cached blocks, not raw free."""
+ dm, _bridge, _split = split_modules
+ mg = __import__("exllamav3.memory_guard", fromlist = ["OOMGuardError"])
+ gib = dm.GIB
+
+ text = FakeModel([FakeModule(f"layer.{i}", layer_idx = i) for i in range(4)])
+ text_cfg = FakeConfig({f"layer.{i}": gib // 2 for i in range(4)})
+ mtp = FakeModel([FakeModule("mtp.block.0", layer_idx = 0), FakeModule("mtp.head")])
+ mtp_cfg = FakeConfig({"mtp.block.0": 3 * gib, "mtp.head": gib})
+
+ _fake_guard_probe(dm, monkeypatch, mg=mg)
+ plan = dm.SplitPlan(_devices(dm), endcaps = True, part0_layers = 2,
+ guard = dm.OOMGuard(dm.GuardPolicy(mode = "auto"),
+ logger = lambda *_a: None),
+ logger = lambda *_a: None)
+ plan.add("text", text, config = text_cfg)
+ plan.build()
+ assert plan.guard_report is not None and plan.guard_report.ok
+ plan.record_load("text", 1.0)
+
+ # Driver-free is 1 GiB, but the allocator holds 15 GiB of reusable cached blocks.
+ raw_free = 1 * gib
+ monkeypatch.setattr(dm, "device_free_bytes", lambda _i: raw_free)
+ monkeypatch.setattr(dm, "device_reusable_bytes", lambda _i: 16 * gib)
+ plan.add("mtp", mtp, config = mtp_cfg)
+ assert plan.guard_report is not None and plan.guard_report.ok
+ part0 = next(r for r in plan.guard_report.device_results if r.footprint.index == 1)
+ assert part0.footprint.need_bytes > raw_free
+ assert part0.capacity_bytes == 16 * gib
+
+ # The same component is refused when only raw free is reported.
+ monkeypatch.setattr(dm, "device_reusable_bytes", lambda _i: raw_free)
+ with pytest.raises(mg.OOMGuardError, match = "deficit"):
+ plan.check_guard()
+
def test_guard_mode_is_normalized_from_env_style_values(split_modules):
_dm, _bridge, split = split_modules
assert split.SplitSettings(part0_layers = 1, oom_guard = "OFF").guard_mode == "off"
diff --git a/tools/glm/serve_lane.sh b/tools/glm/serve_lane.sh
index 122134a..3131599 100755
--- a/tools/glm/serve_lane.sh
+++ b/tools/glm/serve_lane.sh
@@ -7,7 +7,8 @@ export EXL3_ROOT="$LANE_ROOT" EXL3_REPO="$LANE_ROOT" PYTHONPATH="$LANE_ROOT" TMP
mkdir -p "$TMPDIR"
# External supervisor (exllamav3/guard.py): the reliable backstop for a unified pool.
-# auto = arm on Linux when /proc/meminfo is readable (the previous memguard behavior).
+# auto = arm on Linux when /proc/meminfo is readable. Set MEMGUARD=0 to run without
+# a supervisor (the old lane behavior); the supervisor is otherwise on by default.
MEMGUARD="${MEMGUARD:-auto}"
MODEL=""
args=("$@")
diff --git a/tools/mimo/serve_lane.sh b/tools/mimo/serve_lane.sh
index bdb8f19..143c9f3 100755
--- a/tools/mimo/serve_lane.sh
+++ b/tools/mimo/serve_lane.sh
@@ -6,7 +6,8 @@ source "$LANE_ROOT/tools/strix_halo/env.sh"
export EXL3_ROOT="$LANE_ROOT" EXL3_REPO="$LANE_ROOT" PYTHONPATH="$LANE_ROOT" TMPDIR="$LANE_ROOT/scratch/msrv-lane" TQDM_DISABLE=1
mkdir -p "$TMPDIR"
-# External supervisor: unified-memory boxes do not reliably OOM-kill.
+# External supervisor: unified-memory boxes do not reliably OOM-kill. auto = arm on
+# Linux when /proc/meminfo is readable; set MEMGUARD=0 to run without a supervisor.
MEMGUARD="${MEMGUARD:-auto}"
MODEL=""
mg_args=("$@")