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.

split: stage 0 re-baseline docs and GLM pack path defaults

Resynth09f8f134e2b4
diff --git a/doc/split-support-matrix.md b/doc/split-support-matrix.md
new file mode 100644
index 0000000..377af4c
--- /dev/null
+++ b/doc/split-support-matrix.md
@@ -0,0 +1,68 @@
+# Layer-split support matrix
+
+What the contiguous layer split (`exllamav3/device_map.py`, `exllamav3/bridge.py`,
+`Model.load(device_map=...)`) can place today, per model family and per serve flavor.
+Status as of the Stage 0 rebase (2026-11-10): GLM is measured on the Strix Halo / 9070 box;
+Qwen and DSV4 entries are code inventories, not load-tested.
+
+Legend — placement: **front** (mapped to the front eGPU), **main** (mapped to the main GPU),
+**cpu**, **host** (never enters the map: CPU/streamed by design). Stage links point at the
+roadmap stage that must finish before that row is claimable.
+
+## Measured — GLM-5.3-Flash (`tools/glm/serve.py`, `tools/strix_halo/split_*`)
+
+| Component | Config | Placement | Notes |
+| --- | --- | --- | --- |
+| text (`Model.from_config`) | shared | layers 0..N-1 front, N..44 main; endcaps per flag | measured N=4, N=6 at `-c 65536`; N=5 is the long-context setting until the gfx12 KDA kernel lands |
+| mtp (`component="mtp"`) | shared | all front when `--endcaps on`, else main | separate `LayerDeviceMap` (no own trunk), reserve owned by the text map |
+| vision (`component="vision"`) | shared | front when `--endcaps on`, else main | loaded with a plain `device=` argument; no bridge interaction |
+| `embed_tokens` | shared | cpu (`prefer_cpu` cap) | stays host-side by design |
+| KV cache (TQ 6-bit) | built per model/cache | each cache layer follows its block | measured 0.62 GiB main / 0.12 GiB front at 65K |
+| bridge | shared config | installed by `_load_mapped` for all three components | one `Bridge` per config; split_active defuses graphs |
+
+Gate status (Stage 0 replay): N=6 65K load with MTP+vision front 13.68/13.94 GiB, plain split
+run-to-run deterministic; results appended in `docs-notes/split-log.md`.
+
+Known blockers: gfx12 fused KDA kernel (separate PR), MTP cross-device acceptance/determinism,
+endcaps currently moves every non-layer module to the front (GLM has no ngram/PLE/engram, so it
+never showed; the universal core replaces this with an allowlist — Stage 1).
+
+## Code inventory — Qwen3.8-Flash-Next (`tools/qwen/serve.py`)
+
+| Component | Config | Placement intent | Stage |
+| --- | --- | --- | --- |
+| text | own (`Model.from_config`) | layers via SplitPlan; `.load()` with no device today → autosplit | 3 |
+| dflash drafter | **separate `Config` (`dconf`)**, `attach_to` | needs its own bridge + split_active (install per config) | 3 |
+| mtp | shared config, `component="mtp"` | all front (endcaps on), else main | 3 |
+| vision | shared config, `component="vision"` | front when it fits | 3 |
+| ngram table (`NGramEmbedding`) | inside the text model | host/swap-resident (`ensure_resident`, 24.4 GiB) — never front | 3 |
+| PLE / DQ / GR / GDN HIP kernels | JIT loaders | gfx11.5-only gates; per-device arch needed; no implicit front placement | 3 |
+| QSA sparse attention (quant cache pages) | cache layers | gfx1201 `dsa_topk_gfx12` illegal access — keep off the front until fixed | 3 |
+| KV/GDN recurrent state | `Cache(…, max_history=ndt, max_batch_size=sessions)` | per-layer KV automatic; recurrent slot devices need an audit | 3 |
+
+Serve env notes: CUDA-side graph preset (`EXL3_CUDA_GRAPH*`), ROCm chunked prefill
+(`EXL3_SCHED_CHUNK_IL`), `EXL3_PF_GR_FUSE`/`EXL3_GR_PF_FUSE` deferred-residual keys must be
+disabled for split (roadmap Stage 3).
+
+## Code inventory — DeepSeek-V4.1-Flash (`tools/ds41` ↔ `exllamav3/dsv41`)
+
+The DSV4 engine does **not** go through `Model.load()`: `dsv41/pack.py:load_pack` streams
+`model.modules` to one device with `mod.load(dev)` and builds `DSV41Serving(..., device=dev)`.
+
+| Component | Today | Placement intent | Stage |
+| --- | --- | --- | --- |
+| text blocks | per-module `mod.load(dev)` on one device | contiguous N via a SplitPlan over the same module list | 4 |
+| mtp | `Model.from_config(cfg, component="mtp")` then `mod.load(dev)` | front with endcaps / main | 4 |
+| engram tables | `MemoryEngramStore` / `PrefetchRowStore` (O_DIRECT, host) | stay host; `engram_inject` gathers rows at the layer that needs them | 4 |
+| MoE | `GroupedMoE(b.ex_w1, ex_w3, ex_w2, dcfg, dev, …)` one device + `MixedKStore` | per-device grouped backends; no cross-device expert state | 4 |
+| decode graphs | `serve_graph.DecodeGraph` per run-of-layers around engram layers | the existing per-segment split is the natural seam for Stage 6 | 4/6 |
+| KV/state | `DSV41Cache` (custom pool, kv source layers + shared read) | audit device placement of pools and slots | 4 |
+| vision | `VisionTower.load(vision_dir, …, vision_device)` | separate device arg; map to front/main policy | 4 |
+| tiered experts (`EXL3_EXPERT_BUDGET_GIB`) | forces `DSV41_DECODE_GRAPH=0` | graphs-off for split anyway (Stage 6) | 4 |
+
+## Candidate (best effort) — Flint, Mimo, generic `Model` trees
+
+`tools/flint/serve.py` and `tools/mimo/serve.py` are single-`Config` engines calling
+`Model.from_config(...)` + `.load()`; both already accept `device_map` after the Stage 1 core
+lands (mimo loads its vision tower separately, mirroring GLM). They inherit whatever the
+universal core does for text layers + endcaps; no dedicated adapter is planned (Stage 7).
diff --git a/doc/split.md b/doc/split.md
new file mode 100644
index 0000000..b8ac266
--- /dev/null
+++ b/doc/split.md
@@ -0,0 +1,67 @@
+# Contiguous layer split (iGPU + eGPU)
+
+*Status: Stage 0 of the universal roadmap (see `.kilo/plans/1794309410242-universal-layer-split-roadmap.md`).
+This file is the durable user/ops reference; the roadmap owns the staging, and
+`docs-notes/split-log.md` (untracked) owns raw measurements.*
+
+## What it is
+
+One process places the first N transformer layers plus the small endcaps of a model on the
+fast "front" GPU (the 15.92 GiB RX 9070 over USB4) and the rest on the "main" GPU (the 118 GiB
+Strix Halo iGPU), with an asynchronous host-staged bridge on every crossing:
+
+ src tensor --D2H--> pinned slot ring --H2D--> dst tensor
+
+Both legs are enqueued on the two devices' own compute streams; the host never blocks. The
+destination tensor is a fresh allocation, so callers may keep using it after the slot cycles.
+`KYOJIN_BRIDGE=0` falls back to `to_device` (split still runs, crossings block).
+
+## Interface
+
+| Flag (CLI) | Env fallback | Meaning |
+| --- | --- | --- |
+| `--front-layers auto\|N` | `KYOJIN_FRONT_LAYERS` | first N transformer layers on the front device; 0 = off |
+| `--front-device auto\|gfx1201\|cuda:N\|uuid` | `KYOJIN_FRONT_DEVICE` | front device selection (auto = first gfx12 device) |
+| `--endcaps on\|off` | `KYOJIN_ENDCAPS` | non-layer modules (norm/head/MTP/vision) follow the front; `auto` later |
+| `--front-reserve-gb` | `KYOJIN_FRONT_RESERVE_GB` | VRAM left free on the front for workspace (default 1.2) |
+| `--split-preset` | `KYOJIN_SPLIT_PRESET` | per-model unsafe-env preset (Stage 3+) |
+| `--split-graphs` | — | per-segment capture (Stage 6); until then split forces graphs off |
+
+`KYOJIN_FRONT_LAYERS=…` without CLI flags also works in `model_init.init` paths
+(examples/eval tools). The legacy `EXL3_LOAD_SPLIT` budget knob is **not** part of this
+interface; combining it with the new map must error.
+
+## Load-time effects worth knowing
+
+- The front reserve caps the front card while its segment loads and is **released at the
+ first main module**: on ROCm a process-wide allocator cap perturbs main-device numerics
+ (map-zero control diverged from baseline 3/6 until the release was added). Never cap main.
+- `prepare_for_device` routes CUDA↔CUDA moves through the bridge once
+ `config.split_active` is set; CPU moves keep the pinned/async path.
+- Graphs: split mode declines whole-forward, lag-1, `prepare_inputs` and per-block captures
+ (`split_active`). Per-segment capture is Stage 6.
+- JIT HIP loaders compile per (device, defines); `kda_fused_h` is a gfx11.5 WMMA kernel and
+ refuses other archs (`vendor/fla/hip/kda_fused_h_hip.py:supported`). gfx12 runs the
+ deterministic fla chain (`EXL3_KDA_FUSE=0` forced there) — see PR C for the fused port.
+
+## Determinism / verification policy
+
+- Split **off** must stay byte-identical to `main` (outputs and the serve env block).
+- Split **on** is judged by run-to-run determinism (plain greedy), KLD/task metrics and the
+ needle probe — cross-arch (gfx1201 vs gfx1151) is not expected to be bitwise.
+- `tools/strix_halo/split_eval.py` (GLM) runs the battery: `--baseline`, `--front-layers`,
+ `--needle-depth`, `--num-draft`, `--perf-tokens/--perf-reps`, `--compare a.json b.json`.
+
+## Model support
+
+See `doc/split-support-matrix.md` (GLM measured; Qwen and DSV4 adapters staged; Flint/Mimo
+best-effort inheritors of the generic `Model` path). Core placement is model-agnostic:
+adapters declare components and policies, unknown non-layer modules default to main.
+
+## Known limitations (Stage 0)
+
+- Endcaps is still "all non-layer modules to the front" — replaced by an allowlist in Stage 1.
+- Auto-N uses the old tier assumptions; actual-byte sizing is Stage 5. For GLM: N=6 at ≤65K,
+ N=5 for long context until the gfx12 KDA kernel lands.
+- MTP on the split is not yet deterministic (`--num-draft 0` remains the deterministic mode).
+- No per-segment graphs (Stage 6); split runs eager and pays ~0.95× decode (GLM, MTP).
diff --git a/tools/strix_halo/split_eval.py b/tools/strix_halo/split_eval.py
index 0bd89a1..da8e962 100644
--- a/tools/strix_halo/split_eval.py
+++ b/tools/strix_halo/split_eval.py
@@ -50,8 +50,7 @@ FILLER = (
def parse_args() -> argparse.Namespace:
p = argparse.ArgumentParser()
- p.add_argument("-m", "--model", default="/data/hf/hub/models--NicSir--GLM-5.3-Flash-EXL3-2.72bpw/"
- "snapshots/db672fc5e61f1d61bdf6d641fb63538b80bb7613")
+ p.add_argument("-m", "--model", default="/data/models/NicSir--GLM-5.3-Flash-EXL3-2.72bpw")
p.add_argument("--baseline", action="store_true", help="single device (cuda:0), no layer split")
p.add_argument("--front-layers", type=int, default=6)
p.add_argument("--front-device", default="auto")
diff --git a/tools/strix_halo/split_load.py b/tools/strix_halo/split_load.py
index 4a29d52..566bb33 100644
--- a/tools/strix_halo/split_load.py
+++ b/tools/strix_halo/split_load.py
@@ -4,7 +4,7 @@
No forward pass is run. Usage (from the repo root, after `source tools/strix_halo/env.sh`):
python tools/strix_halo/split_load.py \
- -m /data/hf/hub/models--NicSir--GLM-5.3-Flash-EXL3-2.72bpw/snapshots/db672fc5e61f1d61bdf6d641fb63538b80bb7613 \
+ -m /data/models/NicSir--GLM-5.3-Flash-EXL3-2.72bpw \
--front-layers 4 --endcaps on -c 65536
"""
from __future__ import annotations