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 reliability: Ensure MTP and vision taken into consideration.

Resynthbd44c3a6853a
diff --git a/doc/env_vars.md b/doc/env_vars.md
index 3ecfe6e..b2537c4 100644
--- a/doc/env_vars.md
+++ b/doc/env_vars.md
@@ -734,12 +734,17 @@ cache or reserve slab are allocated; `warn` only logs the table; `off` disables
The guard is read-only and never changes allocator settings or outputs. See
`KYOJIN_OOM_GUARD_*` below and `doc/split.md` for the flags.
-### `KYOJIN_OOM_GUARD_RESERVE_GIB` (default: `4.5` unified, `0.8` dedicated)
-
-Per-device headroom kept out of the pre-flight capacity. Accepts the split's device-selector
-syntax, for example `gfx1151=4.5,gfx1201=0.8`; `cuda:N`, a UUID or a name substring also work.
-A bare number applies to every device. The part0 load slab (`--part0-reserve-gb`) is estimated
-separately and is not double-counted.
+### `KYOJIN_OOM_GUARD_RESERVE_GIB` (default: `8.0` unified, `0.8` dedicated)
+
+Per-device free-memory floor kept out of the pre-flight capacity. On a unified device this is
+one subtraction from the GTT pool, not a second reserve on top of the 113.3 GiB ceiling: the
+measured 128K N=5 load completed with **8.7 GiB** GTT free, while the fatal MTP-on event ran
+at about **4.3 GiB** free. Eight GiB is the measured boundary (0.7 GiB below the known-safe
+point, 3.7 GiB above the fatal one), so MTP-on that needs more space is refused and moved to
+a larger part0 N. Accepts the split's device-selector syntax, for example
+`gfx1151=8,gfx1201=0.8`; `cuda:N`, a UUID or a name substring also work. A bare number applies
+to every device. The part0 load slab (`--part0-reserve-gb`) is estimated separately and is not
+double-counted.
### `KYOJIN_OOM_GUARD_WORKSPACE_GIB` (default: `2.0` bulk device, `1.5` other)
@@ -759,17 +764,18 @@ Extra per-device capacity margin on top of the reserve and workspace.
Per-device free-memory floor used by the pre-flight guard and by the supervisor when a serve
script passes it through. Same selector syntax as the reserve. `0` disables the floor.
-### `KYOJIN_OOM_GUARD_HOST_FLOOR_GIB` (default: `6`)
+### `KYOJIN_OOM_GUARD_HOST_FLOOR_GIB` (default: `7`)
Host `MemAvailable` floor used when a unified device is part of the load; the summed GTT
footprint must fit in `MemAvailable - floor`. `exllamav3/guard.py` uses the same default for its
-external host floor.
+external host floor. Seven GiB is measured: the completed MTP-on N=7 8K run bottomed at
+7.26 GiB host available and 7.10 GiB GTT free; the fatal N=6 run was at ~4.3 GiB GTT free.
### `KYOJIN_OOM_GUARD_USABLE_CEILING_GIB` (default: `113.3`)
Observed usable ceiling of a 118 GiB unified device. The guard caps a unified device's planned
-capacity at this value; the default reserve of 4.5 GiB is already the raw-minus-usable gap, so
-the reserve is not subtracted twice. Raise it only after measuring the actual ceiling.
+capacity at this value after the reserve is subtracted. The 8 GiB unified reserve is the
+measured free-memory floor; the ceiling remains a hard upper bound for larger reported pools. Raise it only after measuring the actual ceiling.
### `KYOJIN_OOM_GUARD_TOLERANCE_GIB` (default: `0.25`)
diff --git a/doc/split.md b/doc/split.md
index 0f1b93b..2c3977a 100644
--- a/doc/split.md
+++ b/doc/split.md
@@ -55,7 +55,7 @@ KYOJIN_PART1_DEVICE=gfx1151 \
| `--split-graphs auto\|on\|off` | - | reserved for per-segment capture; split currently runs graphs off |
| `--expandable-segments auto\|on\|off` | `KYOJIN_EXPANDABLE_SEGMENTS` | allocator mode, applied before `import exllamav3`; `auto` only turns it off for large-context unified loads |
| `--oom-guard auto\|warn\|off` | `KYOJIN_OOM_GUARD` | pre-flight per-device guard (`auto` refuses, `warn` logs, `off` disables) |
-| `--oom-guard-reserve-gib` | `KYOJIN_OOM_GUARD_RESERVE_GIB` | per-device headroom, e.g. `gfx1151=4.5,gfx1201=0.8` (default 4.5 unified / 0.8 dedicated) |
+| `--oom-guard-reserve-gib` | `KYOJIN_OOM_GUARD_RESERVE_GIB` | per-device free floor, e.g. `gfx1151=8,gfx1201=0.8` (default 8.0 unified / 0.8 dedicated) |
| `--oom-guard-workspace-gib` | `KYOJIN_OOM_GUARD_WORKSPACE_GIB` | per-device prefill workspace margin (default 2.0 bulk / 1.5 other) |
| `--oom-guard-safety-gib` | `KYOJIN_OOM_GUARD_SAFETY_GIB` | extra per-device capacity margin |
| `--oom-guard-device-floor` | `KYOJIN_OOM_GUARD_DEVICE_FLOOR` | per-device free-memory floor, shared with the supervisor |
@@ -96,23 +96,30 @@ The measured 118 GiB Strix Halo iGPU has a usable ceiling of about **113.3 GiB**
~4.5 GiB gap is driver/allocator overhead, not free capacity). Recorded failure points on
the measured GLM pack: 128K split runs complete (peak ~110.7 GiB on the iGPU); a 512K
cache needs `expandable_segments:False` to load; 640K is killed by the supervisor before
-a torch OOM; 768K hard-locked the box. Do not probe above 128K for MTP-on runs.
+a torch OOM; 768K hard-locked the box. A 2026-11-16 8K MTP-on N=6 probe still caused a
+kernel OOM at ~113.7 GiB GPU-active / ~4.3 GiB GTT free with the old 4.5 GiB reserve and
+6 GiB host floor. The measured fix is: pre-flight reserve 8 GiB (MTP-on N=6 is refused and
+N=7 is recommended), supervisor GTT floor 7 GiB (N=7 8K completed at 7.10 GiB free) and
+host floor 7 GiB (completed at 7.2 GiB available). With `--oom-guard warn`, the old N=6
+case is SIGKILLed by the supervisor at 6.8 GiB GTT free / 8.1 GiB host available instead
+of invoking the kernel OOM killer. Longer MTP-on contexts still need the guard's
+recommendation rather than a hand-picked N, and the supervisor must stay armed.
### Pre-flight guard
The loader estimates each device's footprint from actual bytes: layer/endcap/component
weights, KV/recurrent cache, the part0 reserve slab and a prefill workspace margin. It
compares that with the device's usable/free memory and, for unified devices, with host
-`MemAvailable - 6 GiB`. `--oom-guard auto` (the split default) refuses before allocating
+`MemAvailable - 7 GiB`. `--oom-guard auto` (the split default) refuses before allocating
weights, cache or slabs, and prints a per-device table plus the chosen N/context and the
largest N/context that fits. `warn` only logs; `off` disables it. The check is read-only:
it changes no allocator setting and no split-off path.
-Defaults are tuning values, not architecture rules: `4.5` GiB reserve on a unified/GTT
-device, `0.8` GiB on dedicated VRAM, `2.0`/`1.5` GiB prefill workspace on the bulk/other
-device (calibrated: 4.0 GiB refused measured-good 8K MTP-on/128K points and 2.0 brackets
-their peaks), and a `6` GiB host floor. All accept per-device selector lists, e.g.
-`--oom-guard-reserve-gib gfx1151=4.5,gfx1201=0.8`.
+Defaults are measured boundaries, not architecture rules: `8.0` GiB free on a unified/GTT
+device (128K N=5 completed with 8.7 GiB free; the fatal MTP-on run had ~4.3 GiB free),
+`0.8` GiB on dedicated VRAM, `2.0`/`1.5` GiB prefill workspace on the bulk/other device,
+and a `7` GiB host floor as the last resort. All accept per-device selector lists, e.g.
+`--oom-guard-reserve-gib gfx1151=8,gfx1201=0.8`.
### Allocator mode
@@ -137,8 +144,11 @@ python exllamav3/guard.py --floor-gib 6 --device-floor-gib 4 \
--fadvise-dir /path/to/model -- python tools/glm/serve.py ...
```
-Per-device supervisor floors use `--device-floor card1=4.5,nvidia:0=2` (or
-`--device-floor-gib` for every watched device); the supervisor has no torch selector, so
+Per-device supervisor floors use `--device-floor card0=8,nvidia:0=2` (or
+`--device-floor-gib` for every watched device). On an APU the supervisor automatically keeps
+a **7 GiB GTT free floor** when no explicit device floor is given. This is the measured
+boundary: MTP-on N=7 8K completed at 7.10 GiB GTT free, 128K N=5 at 8.7 GiB, and the fatal
+MTP-on N=6 event was ~4.3 GiB free. the supervisor has no torch selector, so
`cardN`, `nvidia:N`, `amd`, `nvidia` and `default` are accepted, and it degrades to the host
floor when a per-device query is unavailable. On a host with several visible devices a
global `--device-floor-gib` is ignored (with a warning): use explicit selectors so an
diff --git a/doc/strix-halo.md b/doc/strix-halo.md
index a73ecea..08e990a 100644
--- a/doc/strix-halo.md
+++ b/doc/strix-halo.md
@@ -238,9 +238,11 @@ about **113.3 GiB**; the gap is driver/allocator overhead. Large loads should us
pre-flight guard and the external supervisor described in [split.md](split.md#memory-and-capacity):
- `--oom-guard auto` (split default) estimates weights, cache, slab and workspace per
- device and refuses a load that cannot fit before allocating anything. The workspace
- default is 2.0 GiB on the bulk device and 1.5 GiB on the other (calibrated on this box). The workspace
- default is 2.0 GiB on the bulk device and 1.5 GiB on the other (calibrated on this box).
+ device and refuses a load that cannot fit before allocating anything. The unified free floor is 7.0 GiB (the MTP-on N=7 8K load completed at 7.1 GiB GTT free and
+ the 128K N=5 load at 8.7 GiB; the fatal MTP-on N=6 event had ~4.3 GiB). The workspace default is 2.0 GiB on the bulk device and
+ 1.5 GiB on the other. The unified free floor is 7.0 GiB (the MTP-on N=7 8K load completed at 7.1 GiB GTT free and
+ the 128K N=5 load at 8.7 GiB; the fatal MTP-on N=6 event had ~4.3 GiB). The workspace default is 2.0 GiB on the bulk device and
+ 1.5 GiB on the other.
- `--expandable-segments off` (or `EXL3_EXPANDABLE_SEGMENTS=0`) recovers about 0.5 GiB of
allocator fragmentation around a large cache (the 512K GLM case), not capacity.
- `python exllamav3/guard.py --floor-gib 6 --device-floor-gib 4 --fadvise-dir <model> -- ...`
@@ -248,8 +250,10 @@ pre-flight guard and the external supervisor described in [split.md](split.md#me
The serve scripts wrap this with `MEMGUARD=auto|1|0`.
Cutoffs observed on GLM: 128K split is the validated long-context point; 640K is refused
-by the pre-flight guard; 768K previously hard-locked the box. Do not probe above 128K with
-MTP on.
+by the pre-flight guard; 768K previously hard-locked the box. An 8K MTP-on N=6 probe
+OOM-killed the kernel at ~4.3 GiB GTT free; the guard now refuses it and N=7 completes at
+7.10 GiB free. Do not hand-pick an N for MTP-on: use the guard's largest-N/context output
+and keep the supervisor armed (auto GTT floor 7 GiB).
## Build
diff --git a/examples/mimo_v2_6/serve.sh b/examples/mimo_v2_6/serve.sh
index 73614ca..a9e7e7d 100755
--- a/examples/mimo_v2_6/serve.sh
+++ b/examples/mimo_v2_6/serve.sh
@@ -118,7 +118,7 @@ DYNAMIC_DRAFT="${DYNAMIC_DRAFT:-1}"
DRAFT_CACHE_MODE="${DRAFT_CACHE_MODE:-FP16}"
DRAFT_RING="${DRAFT_RING:-1}"
MEMGUARD="${MEMGUARD:-auto}"
-MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-8}"
+MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-7}"
MEMGUARD_DEVICE_FLOOR="${MEMGUARD_DEVICE_FLOOR:-0}"
MIN_AVAIL_GIB="${MIN_AVAIL_GIB:-12}"
FOREGROUND="${FOREGROUND:-1}"
diff --git a/exllamav3/guard.py b/exllamav3/guard.py
index c383389..f2ff048 100755
--- a/exllamav3/guard.py
+++ b/exllamav3/guard.py
@@ -121,15 +121,9 @@ def _read_int(path: str) -> int | None:
return None
-def amd_device_free() -> dict[str, int]:
- """Free memory of every AMD DRM card, in bytes.
-
- An APU's unified pool is the GTT aperture, whose total is close to host RAM. A
- discrete card also exposes ``mem_info_gtt_*`` (a host-RAM aperture), but its real
- budget is VRAM, so choose by pool size rather than by file presence.
- """
- out: dict[str, int] = {}
- host_total = meminfo().get("MemTotal", 0)
+def amd_device_memory() -> dict[str, dict[str, object]]:
+ """Free/total memory and APU-vs-dedicated classification for every AMD card."""
+ out: dict[str, dict[str, object]] = {}
for card in sorted(glob.glob("/sys/class/drm/card[0-9]*")):
device = os.path.join(card, "device")
name = os.path.basename(card)
@@ -138,17 +132,26 @@ def amd_device_free() -> dict[str, int]:
vram_total = _read_int(os.path.join(device, "mem_info_vram_total"))
vram_used = _read_int(os.path.join(device, "mem_info_vram_used"))
total = used = None
- if gtt_total is not None and host_total and gtt_total >= 0.9 * host_total:
- total, used = gtt_total, gtt_used
- elif vram_total is not None:
+ # A discrete card has a significant VRAM pool; an APU's VRAM is a small
+ # carve-out and its real budget is the GTT aperture.
+ dedicated = (vram_total is not None and vram_total >= 8 * 1024 ** 3
+ and gtt_total is not None and vram_total >= 0.05 * gtt_total)
+ if dedicated:
total, used = vram_total, vram_used
elif gtt_total is not None:
total, used = gtt_total, gtt_used
+ elif vram_total is not None:
+ total, used = vram_total, vram_used
if total is not None and used is not None:
- out[name] = max(0, total - used)
+ out[name] = {"free": max(0, total - used), "total": total,
+ "dedicated": bool(dedicated)}
return out
+def amd_device_free() -> dict[str, int]:
+ return {name: int(info["free"]) for name, info in amd_device_memory().items()}
+
+
_NVIDIA_CACHE: dict[str, object] = {"t": -1e9, "data": {}, "unavailable": False,
"last_try": -1e9}
NVIDIA_QUERY_INTERVAL_S = 5.0
@@ -231,6 +234,24 @@ def floor_for(name: str, floors: dict[str, float]) -> float:
return floors.get("default", 0.0)
+AUTO_UNIFIED_DEVICE_FLOOR_GIB = 7.0
+
+
+def auto_unified_floors(floors: dict[str, float]) -> tuple[dict[str, float], bool]:
+ """Use the measured unified GTT free floor when the operator gave no device floor.
+
+ The 128K N=5 load completed with ~8.7 GiB GTT free and MTP-on N=7 8K completed at
+ ~7.1 GiB; the fatal MTP-on event had only ~4.3 GiB. Seven GiB is the measured
+ boundary, not a generic cushion.
+ """
+ if floors:
+ return floors, False
+ devices = amd_device_memory()
+ auto = {name: AUTO_UNIFIED_DEVICE_FLOOR_GIB for name, info in devices.items()
+ if not bool(info["dedicated"])}
+ return auto, bool(auto)
+
+
def effective_floor(name: str, floors: dict[str, float], multiple: bool) -> float:
"""A global floor is not safe on a multi-device host: use explicit selectors."""
key = name.lower()
@@ -245,7 +266,7 @@ def effective_floor(name: str, floors: dict[str, float], multiple: bool) -> floa
def main() -> int:
ap = argparse.ArgumentParser(add_help = True)
- ap.add_argument("--floor-gib", type = float, default = 6.0)
+ ap.add_argument("--floor-gib", type = float, default = 7.0)
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)
@@ -266,12 +287,15 @@ def main() -> int:
"in-process hook could run. Doing it from the supervisor covers every loader.",
)
ap.add_argument("--fadvise-every", type = float, default = 5.0)
+ ap.add_argument("--sample-every", type = float, default = 5.0,
+ help = "append a MemAvailable/MemFree/GTT sample to --log this often")
ap.add_argument("--selftest", action = "store_true")
ap.add_argument("cmd", nargs = argparse.REMAINDER)
args = ap.parse_args()
log = Logger(args.log)
floors = parse_device_floors(args.device_floor, args.device_floor_gib)
+ floors, auto_floors = auto_unified_floors(floors)
if args.selftest:
mi = meminfo()
@@ -303,6 +327,9 @@ def main() -> int:
f"MemAvailable {fmt_gib(mi.get('MemAvailable', 0))} GiB, Cached {fmt_gib(mi.get('Cached', 0))} GiB"
)
if floors:
+ if auto_floors:
+ log("auto unified/GTT floor: " + ", ".join(
+ f"{name}={value:.1f} GiB" for name, value in sorted(floors.items())))
dev = device_free(floors)
if dev:
multiple = len(dev) > 1
@@ -335,6 +362,7 @@ def main() -> int:
last_warn = 0.0
last_beat = 0.0
last_fadv = 0.0
+ last_sample = 0.0
killed = False
device_warned = False
@@ -379,6 +407,19 @@ def main() -> int:
rss = proc_rss(child.pid)
peak_rss = max(peak_rss, rss)
now = time.time()
+ mono = time.monotonic()
+ dev = device_free(floors, now = mono) if (floors or args.sample_every > 0) else {}
+
+ if (args.sample_every > 0 and now - last_sample >= args.sample_every):
+ last_sample = now
+ device_text = " ".join(
+ f"{name}_free={free / GIB:.2f}" for name, free in sorted(dev.items()))
+ log(f"sample t+{now - t0:.1f}s MemAvailable={avail / GIB:.2f} "
+ f"MemFree={mi.get('MemFree', 0) / GIB:.2f} "
+ f"Cached={mi.get('Cached', 0) / GIB:.2f} "
+ f"Dirty={mi.get('Dirty', 0) / GIB:.2f} "
+ f"Unevictable={mi.get('Unevictable', 0) / GIB:.2f} "
+ f"{device_text}".rstrip())
if avail < floor:
log(
@@ -404,7 +445,6 @@ def main() -> int:
break
if floors:
- dev = device_free(floors, now = now)
if not dev and not device_warned:
device_warned = True
log("device-floor query unavailable; falling back to the host floor")
diff --git a/exllamav3/memory_guard.py b/exllamav3/memory_guard.py
index 35af88d..31af569 100644
--- a/exllamav3/memory_guard.py
+++ b/exllamav3/memory_guard.py
@@ -11,10 +11,10 @@ nothing. It never allocates, changes an allocator setting or mutates the plan.
The arithmetic is kept in one place so the split adapters cannot drift:
* dedicated VRAM: ``capacity = min(total, free) - reserve - safety - floor``
-* unified/GTT: the observed usable ceiling (default 113.3 GiB of a reported 118 GiB,
- i.e. the ~4.5 GiB reserve) is the hard cap; the current free memory is a second cap:
- ``capacity = min(usable_ceiling, free - reserve) - safety - floor``. The reserve is
- not subtracted twice: the ceiling already accounts for the unified overhead.
+* unified/GTT: ``capacity = min(total, free) - reserve``, capped by the observed usable
+ ceiling (default 113.3 GiB). The measured 8 GiB unified reserve is the free-memory
+ floor, not a second subtraction on top of the ceiling; the 128K N=5 load completed at
+ 8.7 GiB GTT free and the fatal MTP-on event had ~4.3 GiB.
* unified devices additionally consume the host pool, so the summed GTT footprint is
compared with ``MemAvailable - host_floor``.
@@ -31,13 +31,13 @@ from dataclasses import dataclass, field
GIB = 1024 ** 3
# Calibrated, overridable tuning values from the measured Strix Halo + RX 9070 pair.
-DEFAULT_UNIFIED_RESERVE_GIB = 4.5
+DEFAULT_UNIFIED_RESERVE_GIB = 8.0
DEFAULT_DEDICATED_RESERVE_GIB = 0.8
DEFAULT_BULK_WORKSPACE_GIB = 2.0
DEFAULT_OTHER_WORKSPACE_GIB = 1.5
DEFAULT_SAFETY_GIB = 0.0
DEFAULT_DEVICE_FLOOR_GIB = 0.0
-DEFAULT_HOST_FLOOR_GIB = 6.0
+DEFAULT_HOST_FLOOR_GIB = 7.0
DEFAULT_UNIFIED_CEILING_GIB = 113.3
# Do not refuse a load that misses the estimate by a hair: the estimator is byte
@@ -325,24 +325,20 @@ class DeviceFootprint:
def capacity_bytes(self, unified_ceiling_gib: float) -> int | None:
"""Usable bytes for this device, or None when nothing can be probed."""
reserve = int(self.reserve_bytes)
- if self.unified:
- hard = int(unified_ceiling_gib * GIB)
- if self.total_bytes is not None:
- hard = min(hard, int(self.total_bytes))
- if self.free_bytes is not None:
- hard = min(hard, int(self.free_bytes) - reserve)
- else:
- hard -= reserve
+ if self.total_bytes is None and self.free_bytes is None:
+ return None
+ if self.free_bytes is None:
+ base = int(self.total_bytes)
+ elif self.total_bytes is None:
+ base = int(self.free_bytes)
else:
- if self.total_bytes is None and self.free_bytes is None:
- return None
- if self.free_bytes is None:
- base = int(self.total_bytes)
- elif self.total_bytes is None:
- base = int(self.free_bytes)
- else:
- base = min(int(self.total_bytes), int(self.free_bytes))
- hard = base - reserve
+ base = min(int(self.total_bytes), int(self.free_bytes))
+ # The reserve is the free-memory floor we keep below the device's usable
+ # capacity. For a unified device that floor covers both the GTT pool and the
+ # host kernel's own allocation needs, so it is one subtraction, not two.
+ hard = base - reserve
+ if self.unified:
+ hard = min(hard, int(unified_ceiling_gib * GIB))
hard -= int(self.safety_bytes) + int(self.floor_bytes)
return max(0, hard)
diff --git a/exllamav3/serve_split.py b/exllamav3/serve_split.py
index 93e947b..c9ea8ec 100644
--- a/exllamav3/serve_split.py
+++ b/exllamav3/serve_split.py
@@ -301,7 +301,7 @@ def add_split_arguments(parser: argparse.ArgumentParser) -> None:
"KYOJIN_OOM_GUARD, else auto for split and warn for single-device)")
parser.add_argument("--oom-guard-reserve-gib", type = str, default = None,
help = "per-device headroom, e.g. 4.5 or cuda:0=4.5,cuda:1=0.8 "
- "(default: KYOJIN_OOM_GUARD_RESERVE_GIB, else 4.5 unified / 0.8 dedicated)")
+ "(default: KYOJIN_OOM_GUARD_RESERVE_GIB, else 8.0 unified / 0.8 dedicated)")
parser.add_argument("--oom-guard-workspace-gib", type = str, default = None,
help = "per-device prefill workspace margin, e.g. cuda:0=4,cuda:1=3.5 "
"(default: KYOJIN_OOM_GUARD_WORKSPACE_GIB, else 4.0 bulk / 3.5 other)")
diff --git a/tests/test_memory_guard_cpu.py b/tests/test_memory_guard_cpu.py
index 6667186..635f963 100644
--- a/tests/test_memory_guard_cpu.py
+++ b/tests/test_memory_guard_cpu.py
@@ -77,7 +77,7 @@ def test_budget_defaults_follow_unified_and_bulk(mg):
budget = mg.DeviceBudget(mode = "auto")
resolved = budget.resolve(infos, lambda key: int(key.split(":")[1]),
unified = {0: False, 1: True}, bulk_index = 1)
- assert resolved["reserve"] == {0: 0.8, 1: 4.5}
+ assert resolved["reserve"] == {0: 0.8, 1: 8.0}
assert resolved["workspace"] == {0: 1.5, 1: 2.0}
assert resolved["safety"] == {0: 0.0, 1: 0.0}
assert resolved["device_floor"] == {0: 0.0, 1: 0.0}
@@ -124,6 +124,15 @@ def test_unified_capacity_uses_the_usable_ceiling_without_double_counting(mg):
assert fp3.capacity_bytes(113.3) == int(95.5 * GIB)
+def test_measured_unified_reserve_leaves_seven_gib_of_free_pool(mg):
+ # 118 GiB GTT total, 8 GiB pre-flight reserve -> 110 GiB planned, still under the
+ # 113.3 GiB hard ceiling; the supervisor's last-resort GTT floor is 7 GiB.
+ fp = _footprint(mg, reserve_bytes = int(8.0 * GIB), weights_bytes = int(107 * GIB),
+ workspace_bytes = int(2 * GIB))
+ assert fp.capacity_bytes(113.3) == int(110 * GIB)
+ assert fp.need_bytes == int(109 * GIB)
+
+
def test_dedicated_capacity_subtracts_reserve_and_floor(mg):
fp = _footprint(mg, arch = "gfx1201", unified = False, total_bytes = int(15.92 * GIB),
free_bytes = int(15.92 * GIB), reserve_bytes = int(0.8 * GIB),
@@ -243,6 +252,18 @@ def test_unified_detection_does_not_flag_a_large_dedicated_gpu(mg, monkeypatch):
assert mg.is_unified_device(0, "gfx1151", 80 * GIB) is True
+def test_auto_unified_floor_only_targets_the_apu(guard_mod, monkeypatch):
+ monkeypatch.setattr(guard_mod, "amd_device_memory", lambda: {
+ "card0": {"free": 118 * GIB, "total": 118 * GIB, "dedicated": False},
+ "card1": {"free": 16 * GIB, "total": 16 * GIB, "dedicated": True},
+ })
+ floors, active = guard_mod.auto_unified_floors({})
+ assert active and floors == {"card0": 7.0}
+ explicit = {"card0": 3.0}
+ floors, active = guard_mod.auto_unified_floors(explicit)
+ assert not active and floors == explicit
+
+
def test_effective_floor_ignores_global_floor_on_multiple_devices(guard_mod):
floors = guard_mod.parse_device_floors([], global_gib = 4.0)
assert guard_mod.effective_floor("card0", floors, multiple = False) == 4.0
diff --git a/tools/glm/serve_lane.sh b/tools/glm/serve_lane.sh
index f6488c3..1927980 100755
--- a/tools/glm/serve_lane.sh
+++ b/tools/glm/serve_lane.sh
@@ -9,7 +9,7 @@ mkdir -p "$TMPDIR"
# External supervisor (exllamav3/guard.py): the reliable backstop for a unified pool.
# auto = a unified/GTT device is visible, or the model is large enough to threaten it.
MEMGUARD="${MEMGUARD:-auto}"
-MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-6}"
+MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-7}"
MEMGUARD_DEVICE_FLOOR="${MEMGUARD_DEVICE_FLOOR:-0}"
MODEL=""
args=("$@")
diff --git a/tools/mimo/serve_lane.sh b/tools/mimo/serve_lane.sh
index c87697d..3fa92ad 100755
--- a/tools/mimo/serve_lane.sh
+++ b/tools/mimo/serve_lane.sh
@@ -8,7 +8,7 @@ mkdir -p "$TMPDIR"
# External supervisor: unified-memory boxes do not reliably OOM-kill.
MEMGUARD="${MEMGUARD:-auto}"
-MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-6}"
+MEMGUARD_FLOOR="${MEMGUARD_FLOOR:-7}"
MEMGUARD_DEVICE_FLOOR="${MEMGUARD_DEVICE_FLOOR:-0}"
MODEL=""
mg_args=("$@")
diff --git a/tools/strix_halo/split_eval.py b/tools/strix_halo/split_eval.py
index f193a45..ac20bc4 100644
--- a/tools/strix_halo/split_eval.py
+++ b/tools/strix_halo/split_eval.py
@@ -437,6 +437,21 @@ def main() -> None:
cache = Cache(model, max_num_tokens = args.max_ctx + 4096, max_history = max_history,
max_batch_size = 1, **qkw)
+ # Declare every component before build so the pre-flight guard sees the MTP
+ # and vision footprints too; previously they were added after the text load.
+ draft = draft_cache = None
+ if args.num_draft > 0:
+ draft = Model.from_config(config, component = "mtp")
+ draft_cache = Cache(draft, max_num_tokens = args.max_ctx + 4096, max_history = max_history,
+ max_batch_size = 1, **qkw)
+ vision = None
+ vision_error = None
+ if not args.no_vision:
+ try:
+ vision = Model.from_config(config, component = "vision")
+ except Exception as exc: # noqa: BLE001
+ vision_error = exc
+
plan = None
text_map = None
if not args.baseline:
@@ -457,6 +472,10 @@ def main() -> None:
devices, endcaps = args.endcaps == "on", part0_layers = args.part0_layers,
part0_reserve_gb = 0.0 if args.no_budget else args.part0_reserve_gb,
part1_reserve_gb = args.part1_reserve_gb, guard_budget = budget)
+ if draft is not None:
+ plan.add("mtp", draft, config = config, cache = draft_cache, load_order = 1)
+ if vision is not None:
+ plan.add("vision", vision, config = config, load_order = 2)
plan.add("text", model, config = config, cache = cache, load_order = 0)
plan.build()
text_map = plan.map("text")
@@ -474,26 +493,20 @@ def main() -> None:
if plan is not None:
plan.record_load("text", load_s)
- draft = draft_cache = None
- if args.num_draft > 0:
- draft = Model.from_config(config, component = "mtp")
- draft_cache = Cache(draft, max_num_tokens = args.max_ctx + 4096, max_history = max_history,
- max_batch_size = 1, **qkw)
+ if draft is not None:
t1 = time.perf_counter()
if plan is not None:
- plan.add("mtp", draft, config = config, cache = draft_cache, load_order = 1)
draft.load(device_map = plan.map("mtp"), progressbar = True, max_chunk_size = 4096)
plan.record_load("mtp", time.perf_counter() - t1)
else:
draft.load(device = "cuda:0", progressbar = True)
print(f"[eval] drafter loaded in {time.perf_counter() - t1:.1f} s", flush = True)
- vision = None
- if not args.no_vision:
+ if vision_error is not None:
+ print(f"[eval] vision not loaded: {type(vision_error).__name__}: {vision_error}", flush = True)
+ elif vision is not None:
try:
- vision = Model.from_config(config, component = "vision")
if plan is not None:
- plan.add("vision", vision, config = config, load_order = 2)
t1 = time.perf_counter()
vision.load(device_map = plan.map("vision"), progressbar = True)
plan.record_load("vision", time.perf_counter() - t1)
diff --git a/tools/strix_halo/split_load.py b/tools/strix_halo/split_load.py
index c9b6e69..7e119c8 100644
--- a/tools/strix_halo/split_load.py
+++ b/tools/strix_halo/split_load.py
@@ -126,8 +126,26 @@ def main() -> None:
budget.safety = args.oom_guard_safety_gib
if args.oom_guard_device_floor is not None:
budget.device_floor = args.oom_guard_device_floor
+ # Declare MTP/vision before build so the pre-flight guard includes them.
+ draft = draft_cache = None
+ if args.num_draft > 0:
+ draft = Model.from_config(config, component="mtp")
+ draft_cache = Cache(draft, max_num_tokens=args.cache_size + 4096,
+ max_history=max_history, max_batch_size=1, **qkw)
+ vision = None
+ vision_error = None
+ if not args.no_vision:
+ try:
+ vision = Model.from_config(config, component="vision")
+ except Exception as exc: # noqa: BLE001
+ vision_error = exc
+
plan = SplitPlan(devices, endcaps=endcaps, part0_layers=args.part0_layers,
part0_reserve_gb=args.part0_reserve_gb, guard_budget=budget)
+ if draft is not None:
+ plan.add("mtp", draft, config=config, cache=draft_cache, load_order=1)
+ if vision is not None:
+ plan.add("vision", vision, config=config, load_order=2)
plan.add("text", model, config=config, cache=cache, load_order=0)
plan.build()
text_map = plan.map("text")
@@ -141,22 +159,16 @@ def main() -> None:
t_model = time.perf_counter() - t0
plan.record_load("text", t_model)
- draft = draft_cache = None
- if args.num_draft > 0:
- draft = Model.from_config(config, component="mtp")
- draft_cache = Cache(draft, max_num_tokens=args.cache_size + 4096,
- max_history=max_history, max_batch_size=1, **qkw)
- plan.add("mtp", draft, config=config, cache=draft_cache, load_order=1)
+ if draft is not None:
t1 = time.perf_counter()
draft.load(device_map=plan.map("mtp"), progressbar=True, max_chunk_size=4096)
plan.record_load("mtp", time.perf_counter() - t1)
print(f"[split] drafter loaded in {time.perf_counter() - t1:.1f} s", flush=True)
- vision = None
- if not args.no_vision:
+ if vision_error is not None:
+ print(f"[split] vision not loaded: {type(vision_error).__name__}: {vision_error}", flush=True)
+ elif vision is not None:
try:
- vision = Model.from_config(config, component="vision")
- plan.add("vision", vision, config=config, load_order=2)
t1 = time.perf_counter()
vision.load(device_map=plan.map("vision"), progressbar=True)
plan.record_load("vision", time.perf_counter() - t1)