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: long-form MTP acceptance and vision checks

Resynth870c04aa9727
diff --git a/doc/split.md b/doc/split.md
index 1529dca..aa9d87a 100644
--- a/doc/split.md
+++ b/doc/split.md
@@ -109,23 +109,35 @@ defect.
- 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.py` runs the battery: `--baseline`, `--part0-layers`,
- `--part1-device`/`--part0-device`, `--needle-depth`, `--bench-depth`, `--num-draft`,
- `--perf-tokens`/`--perf-reps` and `--compare a.json b.json`. Its context-dependent part0
+ `--part1-device`/`--part0-device`, `--needle-depth`, `--bench-depth`,
+ `--bench-prompt passkey|summary`, `--bench-acceptance`, `--num-draft`,
+ `--perf-tokens`/`--perf-reps`, `--vision-image PATH` and `--compare a.json b.json`.
+ Its context-dependent part0
default is harness tuning, not a split property; override it with `--part0-layers` or the
- `--long-ctx-part0-layers`/`--short-ctx-part0-layers` flags.
+ `--long-ctx-part0-layers`/`--short-ctx-part0-layers` flags. `--bench-acceptance` uses
+ 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-image` encodes
+ one image through the split vision tower; the harness sets `EXL3_CONV_GEMM=1` as the
+ safe gfx12 spatial-merge fallback.
## Known limitations
-- MTP on the split is not deterministic. `--num-draft 0` remains the deterministic mode.
+- 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 long-context MTP configuration. Use `--num-draft 0` for configs outside
+ this measured set.
- Per-segment graphs are not implemented. Split runs eager and pays about 0.95x decode on
GLM with MTP.
- Auto-N uses text bytes, cache and text endcaps, but does not yet subtract components
declared after the target load (MTP/vision). Leave headroom or set N explicitly.
- Qwen QSA sparse attention has an illegal-access report in the `gfx12` top-k path on
`gfx1201`; keep QSA cache pages off `part0` until that kernel is fixed.
-- Reverse orientation with MTP on currently fails on the eGPU + iGPU device order with a
- Triton `no kernel image is available` error when the MTP block lands on the eGPU.
- Forward split is unaffected. Treat either-device MTP-on placement as requiring this JIT
- fix; MTP-off reverse placement is validated.
+- Reverse orientation with MTP on passes at 32K in both device orders on the current box
+ (N=42, endcaps off, MTP on `part1`). The 2026-11-11 Triton `no kernel image` report did
+ not reproduce, including with a fresh Triton cache; it was most likely a Triton
+ seed/runtime mismatch (the shipped seed is for Triton 3.7, the runtime is 3.9). If it
+ returns, capture the failing kernel with a launch-device probe before changing
+ placement.
- Same-architecture and RDNA3/3.5 pairs are selection-tested only until such hardware is
available.
diff --git a/tests/test_split_plan_cpu.py b/tests/test_split_plan_cpu.py
index fe1610e..934922e 100644
--- a/tests/test_split_plan_cpu.py
+++ b/tests/test_split_plan_cpu.py
@@ -567,6 +567,83 @@ def test_harness_part0_layers_are_explicit_flags(monkeypatch):
assert args.part0_layers == 3 and args.part0_layers_defaulted is True
+def test_harness_acceptance_flags_and_interval(monkeypatch):
+ mod = _load_split_eval()
+ monkeypatch.setattr(sys, "argv", ["split_eval.py", "--bench-depth", "8192",
+ "--bench-acceptance", "--bench-prompt", "summary"])
+ args = mod.parse_args()
+ assert args.bench_depth == 8192 and args.bench_acceptance
+ assert args.bench_prompt == "summary"
+ monkeypatch.setattr(sys, "argv", ["split_eval.py", "--vision-image", "doc/cat.png"])
+ assert mod.parse_args().vision_image == "doc/cat.png"
+ # Wilson interval: 0/0 has no interval, a larger sample is tighter than a small one.
+ assert mod.acceptance_ci95(0, 0) is None
+ small = mod.acceptance_ci95(1, 1)
+ large = mod.acceptance_ci95(500, 500)
+ assert small[0] < large[0] <= large[1] < small[1]
+ lo, hi = mod.acceptance_ci95(75, 25)
+ assert 65.0 < lo < 75.0 < hi < 85.0
+
+
+def test_harness_acceptance_needs_depth(monkeypatch):
+ mod = _load_split_eval()
+ monkeypatch.setattr(sys, "argv", ["split_eval.py", "--bench-acceptance"])
+ with pytest.raises(SystemExit):
+ mod.parse_args()
+
+
+def test_harness_vision_image_rejects_no_vision(monkeypatch):
+ mod = _load_split_eval()
+ monkeypatch.setattr(sys, "argv", ["split_eval.py", "--vision-image", "doc/cat.png",
+ "--no-vision"])
+ with pytest.raises(SystemExit):
+ mod.parse_args()
+
+
+def test_harness_compare_checks_every_summary_run(tmp_path, capsys):
+ import json
+ mod = _load_split_eval()
+ long = lambda ids_b: {
+ "prompt": "summary-set", "ids": [1, 2], "accepted": 90, "rejected": 10,
+ "acceptance": 90.0,
+ "runs": [
+ {"instruction": "first", "ids": [1, 2]},
+ {"instruction": "second", "ids": ids_b},
+ ],
+ }
+ a = {"prompts": [], "long": long([3, 4])}
+ b = {"prompts": [], "long": long([3, 5])}
+ for name, rec in (("a.json", a), ("b.json", b)):
+ (tmp_path / name).write_text(json.dumps(rec))
+ mod.compare(str(tmp_path / "a.json"), str(tmp_path / "b.json"))
+ out = capsys.readouterr().out
+ assert "long run 1 DIVERGED" in out
+ assert "long runs: IDENTICAL" not in out
+
+
+def test_harness_compare_skips_small_acceptance_samples(tmp_path, capsys):
+ import json
+ mod = _load_split_eval()
+ rec = {"prompts": [], "long": {
+ "prompt": "summary-set", "ids": [1], "accepted": 40, "rejected": 10,
+ "acceptance": 80.0, "runs": [{"instruction": "only", "ids": [1]}]}}
+ (tmp_path / "a.json").write_text(json.dumps(rec))
+ (tmp_path / "b.json").write_text(json.dumps(rec))
+ mod.compare(str(tmp_path / "a.json"), str(tmp_path / "b.json"))
+ out = capsys.readouterr().out
+ assert "acceptance: sample too small" in out
+ assert "acceptance: first" not in out
+
+ passkey = {"prompts": [], "long": {
+ "prompt": "passkey", "ids": [1], "accepted": 15, "rejected": 1,
+ "acceptance": 93.75, "runs": None}}
+ (tmp_path / "a.json").write_text(json.dumps(passkey))
+ (tmp_path / "b.json").write_text(json.dumps(passkey))
+ mod.compare(str(tmp_path / "a.json"), str(tmp_path / "b.json"))
+ out = capsys.readouterr().out
+ assert "acceptance: skipped (passkey" in out
+
+
def test_adapter_unsafe_env_is_applied_and_logged(split_modules, monkeypatch):
dm, _bridge, _split = split_modules
monkeypatch.setenv("EXL3_TEST_UNSAFE", "0")
diff --git a/tools/strix_halo/split_eval.py b/tools/strix_halo/split_eval.py
index 27a6bf3..25e7e1f 100644
--- a/tools/strix_halo/split_eval.py
+++ b/tools/strix_halo/split_eval.py
@@ -53,6 +53,17 @@ PERF_PROMPTS = [
"Write a detailed summary of the causes and consequences of the Industrial Revolution.",
]
NEEDLE = "KX-4817-QM"
+# Long-form instructions for --bench-acceptance. A passkey answer is only ~20 tokens,
+# which is too few drafted tokens to compare acceptance between configurations; these
+# ask for a long answer so the rate is measured over a useful sample.
+# The passkey answer is too short for an acceptance comparison; a summary-set arm
+# reaches several hundred drafted tokens. Keep the compare output honest below this.
+MIN_ACCEPTANCE_SAMPLES = 100
+SUMMARY_INSTRUCTIONS = (
+ "Summarize the document in detail, at least 200 words.",
+ "Explain the main trade-offs and risks described above in detail.",
+ "Write a technical analysis of the document above, at least 200 words.",
+)
FILLER = (
"The archive room was quiet except for the soft hum of the ventilation and the slow "
"turning of a clock on the far wall. Shelves of ledgers ran from floor to ceiling, each "
@@ -81,6 +92,10 @@ def parse_args() -> argparse.Namespace:
p.add_argument("-c", "--max-ctx", type=int, default=131072)
p.add_argument("--num-draft", type=int, default=2)
p.add_argument("--no-vision", action="store_true")
+ p.add_argument("--vision-image", default=None,
+ help="run this image through the split vision tower once (twice timed) and "
+ "record the first-image latency; the vision tower must be loaded "
+ "(cannot be combined with --no-vision)")
p.add_argument("--no-graphs", action="store_true", help="force block/whole-forward graphs off (both modes)")
p.add_argument("--no-budget", action="store_true", help="do not cap the per-device allocator (diagnostic: isolates reserve effects)")
p.add_argument("--tokens", type=int, default=128)
@@ -89,11 +104,20 @@ def parse_args() -> argparse.Namespace:
p.add_argument("--needle-depth", type=int, default=0, help="run one needle probe at this many prompt tokens")
p.add_argument("--bench-depth", type=int, default=0,
help="also decode --perf-tokens at this prompt depth and report prefill/decode/acceptance")
+ p.add_argument("--bench-prompt", choices=("passkey", "summary"), default="passkey",
+ help="long-depth prompt: passkey (needle) or a long-form summary instruction")
+ p.add_argument("--bench-acceptance", action="store_true",
+ help="run all long-form summary instructions at --bench-depth and report the "
+ "aggregate draft acceptance with a 95%% interval")
p.add_argument("--out", default=None, help="write the full JSON here")
p.add_argument("--compare", nargs=2, metavar=("BASE", "SPLIT"),
help="compare two saved runs: prompt ids and decode numbers")
p.add_argument("--no-perf", action="store_true", help="skip the 3 decode timing prompts")
args = p.parse_args()
+ if args.bench_acceptance and args.bench_depth <= 0:
+ p.error("--bench-acceptance needs --bench-depth N (the prompt depth to measure)")
+ if args.vision_image and args.no_vision:
+ p.error("--vision-image needs the vision tower; remove --no-vision")
args.part0_layers_defaulted = args.part0_layers is None
if args.part0_layers is None:
# Harness tuning for memory, not a split property: a small part0 card cannot
@@ -114,6 +138,9 @@ def configure_env(args: argparse.Namespace) -> None:
# (untuned, default) path instead of a per-process autotune winner.
os.environ.setdefault("EXL3_DENSE_GEMM_TUNE", "0")
os.environ.setdefault("EXL3_MOE_UNION_V2", "1")
+ # GLM serve's safe vision default: on gfx12 the MIOpen F.conv2d path can fail with
+ # "invalid device function", while the GEMM spatial-merge path is the measured fallback.
+ os.environ.setdefault("EXL3_CONV_GEMM", "1")
# Same optional unquantized MTP eh_proj as serve.py: raises draft acceptance, never output.
if "EXL3_MTP_EH_FP16" not in os.environ:
for path in (os.path.join(args.model, "mtp_eh_proj.st"),
@@ -182,6 +209,34 @@ def build_needle(depth: int, tokenizer):
return torch.cat((p, ids, q), dim = -1).unsqueeze(0), NEEDLE
+def build_context_prompt(depth: int, tokenizer, instruction: str):
+ """~``depth`` tokens of filler followed by ``instruction``, for long-form acceptance."""
+ import torch
+ head = "Read the document below and follow the instruction that follows.\n\n"
+ tail = f"\n\nInstruction: {instruction}\n"
+ p = tokenizer.encode(f"[gMASK]<sop><|user|>\n{head}", encode_special_tokens = True).flatten()
+ q = tokenizer.encode(tail + "<|assistant|>\n", encode_special_tokens = True).flatten()
+ filler_ids = tokenizer.encode(FILLER, encode_special_tokens = False).flatten()
+ target = max(64, depth - int(p.numel() + q.numel()))
+ reps = target // max(1, filler_ids.numel()) + 1
+ ids = filler_ids.repeat(reps)[:target].clone()
+ return torch.cat((p, ids, q), dim = -1).unsqueeze(0)
+
+
+def acceptance_ci95(accepted: int, rejected: int) -> list[float] | None:
+ """Wilson score interval for the acceptance rate, in percent (None without samples)."""
+ import math
+ total = int(accepted) + int(rejected)
+ if total <= 0:
+ return None
+ z = 1.96
+ p = int(accepted) / total
+ denom = 1.0 + z * z / total
+ center = (p + z * z / (2.0 * total)) / denom
+ half = z * math.sqrt(p * (1.0 - p) / total + z * z / (4.0 * total * total)) / denom
+ return [round(max(0.0, center - half) * 100.0, 2), round(min(1.0, center + half) * 100.0, 2)]
+
+
def main() -> None:
args = parse_args()
if args.part0_layers_defaulted and not args.baseline:
@@ -307,8 +362,31 @@ def main() -> None:
"after_load_gib": after_load,
"prompts": [],
"perf": [],
+ "vision": None,
}
+ if args.vision_image and vision is None:
+ raise SystemExit("--vision-image was requested but the vision tower did not load")
+ if vision is not None and args.vision_image:
+ from PIL import Image
+ image = Image.open(args.vision_image).convert("RGB")
+ times = []
+ emb = None
+ for _ in range(2):
+ t0 = time.perf_counter()
+ emb = vision.get_image_embeddings(tokenizer = tokenizer, image = image)
+ torch.cuda.synchronize()
+ times.append(time.perf_counter() - t0)
+ result["vision"] = {
+ "image": args.vision_image, "mm_length": int(emb.mm_length),
+ "embedding_shape": list(emb.embeddings.shape),
+ "embedding_device": str(emb.embeddings.device),
+ "first_s": times[0], "second_s": times[1],
+ }
+ print(f"[eval] vision {args.vision_image}: {emb.mm_length} tokens, "
+ f"first {times[0]:.2f} s, second {times[1]:.2f} s, "
+ f"embeddings {tuple(emb.embeddings.shape)} on {emb.embeddings.device}", flush = True)
+
for prompt in PROMPTS:
ids = ids_of(prompt, tokenizer)
r = run_job(gen, Job, ids, args.tokens)
@@ -349,25 +427,72 @@ def main() -> None:
f" (ttft {r['ttft_s']:.1f} s) text={r['text'][:120]!r}", flush = True)
if args.bench_depth > 0:
- ids, _ = build_needle(min(args.bench_depth, args.max_ctx - 1024), tokenizer)
- r = run_job(gen, Job, ids, args.perf_tokens)
- tps = (r["tokens"] - 1) / r["decode_s"] if r["decode_s"] and r["tokens"] > 1 else None
- acc, rej = r["accepted"], r["rejected"]
- result["long"] = {
- "depth": int(ids.numel()), "ttft_s": r["ttft_s"], "tokens": r["tokens"],
- "decode_s": r["decode_s"], "decode_tps": tps,
- "accepted": acc, "rejected": rej,
- "acceptance": round(100 * acc / (acc + rej), 2) if acc + rej else None,
- "text": r["text"],
- }
- if r["ttft_s"] is None or tps is None:
- print(f"[eval] long depth {ids.numel()}: incomplete run "
- f"({r['tokens']} tokens, ttft={r['ttft_s']}, decode_tps={tps}, "
- f"accept {acc}/{rej})", flush = True)
+ depth = min(args.bench_depth, args.max_ctx - 1024)
+ if args.bench_prompt == "summary" or args.bench_acceptance:
+ instructions = SUMMARY_INSTRUCTIONS if args.bench_acceptance else SUMMARY_INSTRUCTIONS[:1]
+ runs = []
+ for instruction in instructions:
+ ids = build_context_prompt(depth, tokenizer, instruction)
+ r = run_job(gen, Job, ids, args.perf_tokens)
+ tps = (r["tokens"] - 1) / r["decode_s"] if r["decode_s"] and r["tokens"] > 1 else None
+ runs.append({
+ "instruction": instruction,
+ "depth": int(ids.numel()), "ids": r["ids"],
+ "ttft_s": r["ttft_s"], "tokens": r["tokens"],
+ "decode_s": r["decode_s"], "decode_tps": tps,
+ "accepted": r["accepted"], "rejected": r["rejected"],
+ "acceptance": round(100 * r["accepted"] / (r["accepted"] + r["rejected"]), 2)
+ if r["accepted"] + r["rejected"] else None,
+ "text": r["text"],
+ })
+ if r["ttft_s"] is None or tps is None:
+ print(f"[eval] long summary depth {ids.numel()}: incomplete run "
+ f"({r['tokens']} tokens, ttft={r['ttft_s']}, decode_tps={tps}, "
+ f"accept {r['accepted']}/{r['rejected']})", flush = True)
+ else:
+ print(f"[eval] long summary depth {ids.numel()}: "
+ f"ttft {r['ttft_s']:.1f} s, decode {tps:.2f} t/s, "
+ f"accept {r['accepted']}/{r['rejected']}", flush = True)
+ acc = sum(x["accepted"] for x in runs)
+ rej = sum(x["rejected"] for x in runs)
+ base = runs[0]
+ result["long"] = {
+ "prompt": "summary-set" if args.bench_acceptance else "summary",
+ "depth": base["depth"], "ids": base["ids"],
+ "ttft_s": base["ttft_s"], "tokens": base["tokens"],
+ "decode_s": base["decode_s"], "decode_tps": base["decode_tps"],
+ "accepted": acc, "rejected": rej,
+ "acceptance": round(100 * acc / (acc + rej), 2) if acc + rej else None,
+ "acceptance_ci95": acceptance_ci95(acc, rej),
+ "runs": runs, "text": base["text"],
+ }
+ if acc + rej:
+ lo, hi = result["long"]["acceptance_ci95"]
+ print(f"[eval] acceptance {acc}/{acc + rej} = {result['long']['acceptance']:.2f}% "
+ f"(95% CI {lo:.2f}-{hi:.2f}%, {acc + rej} drafted tokens)", flush = True)
else:
- print(f"[eval] long depth {ids.numel()}: ttft {r['ttft_s']:.1f} s, "
- f"prefill {ids.numel() / r['ttft_s']:.2f} t/s, decode {tps:.2f} t/s, "
- f"accept {acc}/{rej}", flush = True)
+ ids, _ = build_needle(depth, tokenizer)
+ r = run_job(gen, Job, ids, args.perf_tokens)
+ tps = (r["tokens"] - 1) / r["decode_s"] if r["decode_s"] and r["tokens"] > 1 else None
+ acc, rej = r["accepted"], r["rejected"]
+ result["long"] = {
+ "prompt": "passkey",
+ "depth": int(ids.numel()), "ids": r["ids"],
+ "ttft_s": r["ttft_s"], "tokens": r["tokens"],
+ "decode_s": r["decode_s"], "decode_tps": tps,
+ "accepted": acc, "rejected": rej,
+ "acceptance": round(100 * acc / (acc + rej), 2) if acc + rej else None,
+ "acceptance_ci95": acceptance_ci95(acc, rej),
+ "text": r["text"],
+ }
+ if r["ttft_s"] is None or tps is None:
+ print(f"[eval] long depth {ids.numel()}: incomplete run "
+ f"({r['tokens']} tokens, ttft={r['ttft_s']}, decode_tps={tps}, "
+ f"accept {acc}/{rej})", flush = True)
+ else:
+ print(f"[eval] long depth {ids.numel()}: ttft {r['ttft_s']:.1f} s, "
+ f"prefill {ids.numel() / r['ttft_s']:.2f} t/s, decode {tps:.2f} t/s, "
+ f"accept {acc}/{rej}", flush = True)
for d in devs:
result["devices"][str(d)].update({
@@ -414,6 +539,40 @@ def compare(base_path: str, split_path: str) -> None:
f"({b['decode_tps'] / a['decode_tps']:.3f}x)")
if "needle" in split:
print(f"[compare] needle: {'found' if split['needle']['found'] else 'MISSING'}")
+ if base.get("long") and split.get("long"):
+ a, b = base["long"], split["long"]
+ runs_a, runs_b = a.get("runs"), b.get("runs")
+ if runs_a is not None or runs_b is not None:
+ if not runs_a or not runs_b:
+ print("[compare] long runs: cannot compare (one side has no per-run ids)")
+ else:
+ if len(runs_a) != len(runs_b):
+ print(f"[compare] long runs: {len(runs_a)} vs {len(runs_b)} runs")
+ differing = [
+ i for i, (ra, rb) in enumerate(zip(runs_a, runs_b))
+ if ra.get("ids") != rb.get("ids")
+ ]
+ if differing:
+ i = differing[0]
+ print(f"[compare] long run {i} DIVERGED: {runs_a[i].get('instruction')!r}")
+ else:
+ print("[compare] long runs: IDENTICAL")
+ elif a.get("ids") is not None and b.get("ids") is not None:
+ same_long = a["ids"] == b["ids"]
+ print(f"[compare] long prompt ids: {'IDENTICAL' if same_long else 'DIVERGED'}")
+ if a.get("acceptance") is not None and b.get("acceptance") is not None:
+ a_n = a["accepted"] + a["rejected"]
+ b_n = b["accepted"] + b["rejected"]
+ if a.get("prompt") == "passkey" or b.get("prompt") == "passkey":
+ print(f"[compare] acceptance: skipped (passkey sample {a_n}/{b_n} drafted tokens; "
+ "use --bench-prompt summary)")
+ elif min(a_n, b_n) < MIN_ACCEPTANCE_SAMPLES:
+ print(f"[compare] acceptance: sample too small ({a_n}/{b_n} drafted tokens; "
+ f"need >= {MIN_ACCEPTANCE_SAMPLES})")
+ else:
+ print(f"[compare] acceptance: first {a['acceptance']:.2f}% "
+ f"({a['accepted']}/{a_n}), second {b['acceptance']:.2f}% "
+ f"({b['accepted']}/{b_n})")
if __name__ == "__main__":