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.
Contiguous layer split
The layer split places the first N transformer layers of a model on one GPU (part0) and
the remaining layers on another (part1) in a single process. It is for models that do not
fit on one device, or for pairing a small fast card with a large unified-memory device.
Status: GLM-5.3-Flash is measured and supported by the GLM server. Qwen3.8-Flash-Next and DeepSeek-V4.1-Flash adapters are staged; Flint and Mimo use the generic model path. See Model support.
How it works
part0: layers 0..N-1 + endcaps part1: layers N..last
\______________________________________/
host-staged crossings
part0 and part1 are positions in the layer order, not device indices. Either physical
device can serve either part.
Every tensor that crosses the split goes through an asynchronous host-staged bridge:
src tensor --D2H--> pinned slot ring --H2D--> dst tensor
Both legs are enqueued on the two devices' compute streams, so the host does not wait. The
destination is a fresh allocation. KYOJIN_BRIDGE=0 disables the bridge; cross-device
moves then use to_device with a blocking host bounce instead of probing or using a direct
peer copy. An explicit EXLLAMA_NO_P2P_COPY still wins.
Measured configuration: an RX 9070 (gfx1201, 15.92 GiB) over USB4 as part0 and a
118 GiB Strix Halo iGPU (gfx1151) as part1. The numbers below are measurements from
that pair, not assumptions of the interface.
Quick start
The GLM server and the split harnesses accept the flags below. The environment-only path is useful for wrappers that cannot pass CLI flags:
KYOJIN_PART0_LAYERS=6 \
KYOJIN_PART0_DEVICE=gfx1201 \
KYOJIN_PART1_DEVICE=gfx1151 \
python tools/glm/serve.py --model /path/to/model
Interface
| Flag | Environment fallback | Meaning |
|---|---|---|
--part0-layers auto|N |
KYOJIN_PART0_LAYERS |
first N transformer layers on part0; 0 = split off |
--part1-device auto|cuda:N|gfxXXXX|uuid|name |
KYOJIN_PART1_DEVICE |
part1 device (auto = cuda:0) |
--part0-device auto|cuda:N|gfxXXXX|uuid|name |
KYOJIN_PART0_DEVICE |
part0 device (auto = the only other device when two are visible) |
--endcaps on|off |
KYOJIN_ENDCAPS |
keep text endcaps and whole MTP/vision components on part0 (default on) |
--part0-reserve-gb |
KYOJIN_PART0_RESERVE_GB |
VRAM held as a load-time slab on part0 for workspace (default 1.2) |
--split-preset auto|glm|qwen|ds41|none |
KYOJIN_SPLIT_PRESET |
per-model unsafe-environment preset; GLM needs none today |
--split-graphs auto|on|off |
- | reserved for per-segment capture; split currently runs graphs off |
--oom-guard auto|off |
KYOJIN_OOM_GUARD |
pre-flight memory guard (auto refuses, off disables) |
cuda:N is the torch device index after HIP_VISIBLE_DEVICES, not the rocm-smi
index. Explicit selectors win in either position: part0=cuda:1/part1=cuda:0 and
part0=cuda:0/part1=cuda:1 are both valid. With exactly two visible devices, a part0-only
selector still works and part1=auto takes the other device. Two selectors that resolve to
the same device fail, and a one-device split fails with a clear error. With more than two
visible devices, auto requires an explicit selector and prints the inventory.
KYOJIN_PART0_LAYERS and KYOJIN_PART1_DEVICE also work in model_init.init paths
(examples and evaluation tools) without CLI flags. The legacy EXL3_LOAD_SPLIT budget knob
is not part of this interface and must not be combined with the new map.
What gets placed
| Where | Contents |
|---|---|
part0 |
first N text layers; with --endcaps on, the text allowlist (norm/hc/lm_head-like) and whole non-CPU MTP/vision components |
part1 |
remaining text layers; MTP/vision when endcaps are off; unknown non-layer modules |
| CPU | the shared embed_tokens (prefer_cpu) stays host-side by design |
| cache | each KV/recurrent layer follows its owning layer; a placement audit prints after load |
| bridge | one bridge per config, covering the target, drafter and vision |
Text endcaps are selected by a class/key allowlist, not by per-model placement in the core. “Whole component” means all non-CPU modules of that component.
Memory and capacity
- The
part0reserve is an inert load-time slab, not a process-wide allocator cap. It removes bytes from the pool while the model loads and is released at the firstpart1module. Size it to the part0 card. - Split mode runs eager. Whole-forward and per-block graphs are disabled; per-segment capture is not implemented yet.
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 caps are:
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
the configurable workspace estimate and must also satisfy the host cap; only the unified
footprints are summed against the host.
There is no GTT or VRAM reserve. A dedicated-VRAM allocation failure is a process-level
error; the host floor is what prevents a unified-memory box from starving. The only
tunables are MEMGUARD_FLOOR (default 8), the planning margin (default 1)
and the unified prefill workspace (default 2.0 GiB). The host floor is shared with the
supervisor; the margin keeps the planner above the supervisor's kill threshold.
--oom-guard auto 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. off disables it. The
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 device caps and the host cap are checked separately; a load that reaches the host floor is stopped by the supervisor.
Allocator mode
If a load needs expandable segments off: Use the existing EXL3_EXPANDABLE_SEGMENTS=0
(or PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False) in that lane profile before the library import.
It recovers about 0.5 GiB of fragmentation, not capacity. There is no automatic allocator heuristic.
If the host cap refuses on a particular boot:
Set KYOJIN_OOM_GUARD_PREFLIGHT_MARGIN_GIB=0 or KYOJIN_OOM_GUARD=off for that lane;
the external supervisor floor is unchanged and still protects the box. Do not disable the supervisor.
External supervisor
Use exllamav3/guard.py (the compatibility path util/memguard.py execs it). It watches host
MemAvailable and page cache; it has no device floors and no torch import:
python exllamav3/guard.py --fadvise-dir /path/to/model -- python tools/glm/serve.py ...
The host floor defaults to 8 GiB (or MEMGUARD_FLOOR) and is the same value
the preflight plans around. The supervisor logs a sample to --log; the serve lanes pass
$TMPDIR/memguard.log so a future event leaves evidence. The serve scripts use a
MEMGUARD=auto|1|0 wrapper: auto arms exllamav3/guard.py on Linux when
/proc/meminfo is readable; use MEMGUARD=0 to disable it.
Keep the supervisor external; an in-process watchdog cannot be relied on while the allocator
or kernel is stalled.
Model support
| Model | Status | Notes |
|---|---|---|
| GLM-5.3-Flash | measured | text, MTP and vision; on a 16 GiB gfx12 part0, N=6 fits short context (MTP off), N=4 is the 128K MTP setting, and N=5 fits 500K |
| Qwen3.8-Flash-Next | staged, not load-tested | QSA/GDN/PLE components; separate dflash drafter config; QSA gfx12 caveat below |
| DeepSeek-V4.1-Flash | staged | uses the DSV4 engine, not Model.load |
| Flint, Mimo | best effort | generic Model path; no dedicated adapter |
Kernel support is per architecture. The split owns placement and transport, not kernel ports; a missing kernel fallback on a new architecture is a model/kernel issue, not a split defect.
Verification
- Split off must remain byte-identical to the parent branch, including outputs and the serve environment block. It must not enumerate devices or mutate split settings.
- Split on is judged by run-to-run determinism with plain greedy decoding, KLD/task metrics and the needle probe. A mixed-architecture pair is not expected to be bitwise.
tools/strix_halo/split_eval.pyruns the battery:--baseline,--part0-layers,--part1-device/--part0-device,--needle-depth,--bench-depth,--bench-prompt passkey|summary,--bench-acceptance,--num-draft,--perf-tokens/--perf-reps,--vision-image PATHand--compare a.json b.json. Its context-dependent part0 default is harness tuning, not a split property; override it with--part0-layersor the--long-ctx-part0-layers/--short-ctx-part0-layersflags.--bench-acceptanceuses long-form summary prompts and reports the drafted-token sample plus a 95% interval; the passkey prompt is too short for an acceptance comparison.--vision-imageencodes one image through the split vision tower; the harness setsEXL3_CONV_GEMM=1as the safe gfx12 spatial-merge fallback.--kld-corpus PATH --kld-slices N --kld-len L --kld-out FILEteacher-forces corpus slices and--kld-compare BASE SPLITreports KLD both ways, top-1 agreement and PPL. The short battery also reports programmatic task checks. Use these for split-on quality: a mixed-architecture pair is not bitwise.tools/strix_halo/split_sessions_smoke.pysends N concurrent requests at a running server and checks that every response succeeds and that the requests overlap.tools/strix_halo/split_startup_health.pypolls/healthduring load and checks the stage trace; run it with and without--no-visionand with--num-draft 0.
Known limitations
- Split-on is deterministic run-to-run, but it is not bitwise equal to a single device on a mixed-architecture pair. Measured on GLM, N=4: 4/6 short greedy prompts identical, task checks 5/6 vs 4/6, PPL 9.374 vs 9.401 and KLD 2.08e-2 with 94.52% top-1 agreement over 1022 positions. The distributions and task accuracy are unchanged; a few near-tie argmax positions flip. Use KLD/task metrics for split-on.
- At 500K context the split fits the measured pair (
part010.75 GiB,part1100.2 GiB load-time peak). A single 118 GiB device did not have headroom for the same context there; size for capacity, not only speed. - Concurrent serving is smoke-tested at 4 sessions with MTP on (4/4 responses overlap, no queue or slot error). A heavier mixed chat/image/tool workload is future work.
- MTP on the split is deterministic at 8K/32K/128K with N=4 in the measured
configuration (two independent runs: 6/6 greedy prompts and identical long-prompt ids).
The earlier N=6 128K battery used short prompts; N=6 long prefill OOMs a 16 GB part0,
so N=4 is the 128K MTP configuration and the 500K capacity run used N=5. Use
--num-draft 0for configs outside this measured set. - Per-segment graphs are not implemented. Split runs eager; measured GLM decode is -3.4% at 8K and +1.3% to +8.1% at 32K/128K versus single device with MTP on.
- Auto-N subtracts the MTP drafter and vision tower when the adapter predeclares them
before load (the GLM server does). The default 2 GiB safety covers the measured 32K
MTP+vision warm-up (1 GiB still chose N=6 and OOMed; 1.5/2/3 GiB chose N=5), but it is
a fixed stopgap. Stage 5 sizes the forward workspace from the context and cache so
short context can use more part0 layers and long context reserves more;
KYOJIN_AUTON_SAFETY_GBremains the override. - Qwen QSA sparse attention has an illegal-access report in the
gfx12top-k path ongfx1201; keep QSA cache pages offpart0until that kernel is fixed. - Reverse orientation with MTP on is validated at 32K (N=42, endcaps off, MTP on
part1) on the measured configuration. - Same-architecture and RDNA3/3.5 pairs are selection-tested only until such hardware is available.