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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
Figures: read the 1.5.10 curves, plot the 500K point
YanissAmz2f9944a96452
diff --git a/doc/benchmarks.tmpl.md b/doc/benchmarks.tmpl.mdindex eb8079d..008ab26 100644--- a/doc/benchmarks.tmpl.md+++ b/doc/benchmarks.tmpl.md@@ -9,7 +9,7 @@ The figures of the three models come from a run set up like yours:- the public code at the commit named in `doc/figures.json`, built from the README install;- an empty home directory, the published packs downloaded from the hub, the default environment (no private flags);- greedy decoding, thinking off, the four card prompts for each of chat, prose and code, 256 tokens, median of 3 repetitions (`tools/bench.sh` runs the same prompts);-- prefill and decode by context: cold prompts of 8K to 256K tokens (MiMo: to 128K), an essay request of 256 tokens, after one discarded 8K request; prefill is the speed the server reports for the request. Decode: Qwen, like the other engines in the comparison below, is timed by the client from the first to the last streamed token; GLM and MiMo use the server's own decode counters (`/metrics`), because their streams arrive in bursts that a client clock misreads. Qwen and GLM: {{LADDER}}; MiMo: two requests per depth, the second one reported. GLM and MiMo are started with a context large enough for the longest prompt (`-c 272384` and `-c 163840`);+- prefill and decode by context: cold prompts of 8K to 256K tokens and, for Qwen and GLM, one of 500K (499,712 tokens) (MiMo: to 128K), an essay request of 256 tokens, after one discarded 8K request; prefill is the speed the server reports for the request. Decode: Qwen, like the other engines in the comparison below, is timed by the client from the first to the last streamed token; GLM and MiMo use the server's own decode counters (`/metrics`), because their streams arrive in bursts that a client clock misreads. Qwen and GLM: {{LADDER}}; MiMo: two requests per depth, the second one reported. GLM and MiMo are started with a context large enough for the longest prompt (`-c 272384` and `-c 163840`); the 500K point of Qwen and GLM is a separate start with `-c 524288` (Qwen also with `--cache-bits 8`);- speculative decode is the default server mode and returns the same tokens as plain decode.- the server log of each run has no `fallback`, `disabled`, `unavailable`, `not tuned` or `No module` line.diff --git a/tests/fixtures/pub/scratch/curve_glm_c272384.json b/tests/fixtures/pub/scratch/curve_glm_c272384.jsonindex 365fe0f..2d146a8 100644--- a/tests/fixtures/pub/scratch/curve_glm_c272384.json+++ b/tests/fixtures/pub/scratch/curve_glm_c272384.json@@ -102,5 +102,6 @@"target": 262144,"calibrated_tokens": 262144}- }+ },+ "started": "2026-10-17 12:00:00"}\ No newline at end of filediff --git a/tests/fixtures/pub/scratch/curve_glm_c524288.json b/tests/fixtures/pub/scratch/curve_glm_c524288.jsonindex 6903528..ceada7d 100644--- a/tests/fixtures/pub/scratch/curve_glm_c524288.json+++ b/tests/fixtures/pub/scratch/curve_glm_c524288.json@@ -22,5 +22,6 @@"target": 499712,"calibrated_tokens": 499712}- }+ },+ "started": "2026-10-17 12:00:00"}\ No newline at end of filediff --git a/tests/fixtures/pub/scratch/curve_qwen_c272384.json b/tests/fixtures/pub/scratch/curve_qwen_c272384.jsonindex 0b7bb60..858c716 100644--- a/tests/fixtures/pub/scratch/curve_qwen_c272384.json+++ b/tests/fixtures/pub/scratch/curve_qwen_c272384.json@@ -102,5 +102,6 @@"target": 262144,"calibrated_tokens": 262144}- }+ },+ "started": "2026-10-17 12:00:00"}\ No newline at end of filediff --git a/tests/fixtures/pub/scratch/curve_qwen_c524288.json b/tests/fixtures/pub/scratch/curve_qwen_c524288.jsonindex 6ae12f3..e18445e 100644--- a/tests/fixtures/pub/scratch/curve_qwen_c524288.json+++ b/tests/fixtures/pub/scratch/curve_qwen_c524288.json@@ -22,5 +22,6 @@"target": 499712,"calibrated_tokens": 499712}- }+ },+ "started": "2026-10-17 12:00:00"}\ No newline at end of filediff --git a/tools/make_charts.py b/tools/make_charts.pyindex 6c13471..7d2be75 100644--- a/tools/make_charts.py+++ b/tools/make_charts.py@@ -16,7 +16,12 @@ DASH = {"mimo": "9 6"}SHORT = {"qwen": "Qwen3.8-Flash-Next", "glm": "GLM-5.3-Flash", "mimo": "MiMo-V2.6-Flash"}FONT = "font-family=\"'Ubuntu Sans','DejaVu Sans',Helvetica,Arial,sans-serif\""def fmt(v): return f"{v:,.0f}" if v >= 100 else f"{v:.1f}"-def ck(c): return f"{int(c) // 1024}K"+def ck(c): return "500K" if int(c) == 499712 else f"{int(c) // 1024}K" # 499712 = the 500K point (a 524288-token window)+BASE_TICKS = [8192, 16384, 32768, 65536, 131072, 262144]+def ctx_ticks():+ """Context ticks 8K..256K, plus the 500K tick when any model publishes that point."""+ pub = {int(c) for m in M for k in ("prefill", "decode") for c, v in m[k].items() if v}+ return BASE_TICKS + ([499712] if 499712 in pub else [])def t(x, y, s, size, fill=TXT, anchor="start", weight="400"):return f'<text x="{x}" y="{y}" fill="{fill}" font-size="{size}" text-anchor="{anchor}" font-weight="{weight}">{s}</text>'@@ -69,7 +74,7 @@ def draw(key, headline, footer, xs, label, pos, getter, note=None):return draw_lines(headline, footer, xs, label, pos, series, note)def prefill_chart():- ticks = [4096, 8192, 16384, 32768, 65536, 131072, 262144]+ ticks = [4096] + ctx_ticks()allx = sorted({int(c) for m in M for c, v in m["prefill"].items() if v})xs = sorted(set(ticks) | set(allx)); lo, hi = math.log2(ticks[0]), math.log2(ticks[-1])pos = lambda a, b: {c: a + (b - a) * (math.log2(c) - lo) / (hi - lo) for c in xs}@@ -89,7 +94,7 @@ def decode_chart():def prefill_context_chart():"""Prefill against context length: Kyojin and the rivals where a figure exists (Strata by the independent lab, Gufo measured by us)."""q = M[0]; R = F.get("rivals", {})- ticks = [8192, 16384, 32768, 65536, 131072, 262144]+ ticks = ctx_ticks()ints = lambda d: {int(c): v for c, v in d.items() if v}series = [{"name": "Kyojin", "color": BLUE, "pts": ints(q["prefill"]), "below": True, "first_label": False}]if R.get("strata"):@@ -105,7 +110,7 @@ def prefill_context_chart():def decode_context_chart():"""Speculative decode against context length: Kyojin now and before, and the rivals where a figure exists at that context."""q = M[0]; R = F.get("rivals", {})- ticks = [8192, 16384, 32768, 65536, 131072, 262144]+ ticks = ctx_ticks()lo, hi = math.log2(ticks[0]), math.log2(ticks[-1])pos = lambda a, b: {c: a + (b - a) * (math.log2(c) - lo) / (hi - lo) for c in ticks}ints = lambda d: {int(c): v for c, v in d.items() if v}@@ -119,7 +124,7 @@ def decode_context_chart():def decode_models_chart():"""Speculative decode against context length, one line per model."""- ticks = [8192, 16384, 32768, 65536, 131072, 262144]+ ticks = ctx_ticks()lo, hi = math.log2(ticks[0]), math.log2(ticks[-1])pos = lambda a, b: {c: a + (b - a) * (math.log2(c) - lo) / (hi - lo) for c in ticks}qd = {int(c): v for c, v in M[0]["decode"].items() if v}; cmax = max(qd)diff --git a/tools/make_readme_table.py b/tools/make_readme_table.pyindex adb79f8..ecbd28c 100644--- a/tools/make_readme_table.py+++ b/tools/make_readme_table.py@@ -5,7 +5,7 @@ import json, osroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))F = json.load(open(os.path.join(root, "doc", "figures.json"))); HP, HC = F["headline_prompt"], F["headline_prefill_ctx"]def f(v): return "n/a" if v is None else (f"{v:.1f}" if v < 100 else f"{v:.0f}")-def ck(c): return f"{int(c) // 1024}K"+def ck(c): return "500K" if int(c) == 499712 else f"{int(c) // 1024}K" # 499712 = the 500K pointdef b(m, v): return v if m.get("earlier") else f"<b>{v}</b>"def label(m): return f'{m["name"]} <sub>({m["earlier"]})</sub>' if m.get("earlier") else f'<b>{m["name"]}</b>'rows = "".join(f'<tr><td>{label(m)}</td><td align="right">{m["pack_gb"]:g} GB</td><td align="right">{m["table"]["prefill"]}</td><td align="right">{b(m, m["table"]["decode"])}</td></tr>\n' for m in F["models"])diff --git a/tools/pub_to_figures.py b/tools/pub_to_figures.pyindex 6602807..c16e796 100644--- a/tools/pub_to_figures.py+++ b/tools/pub_to_figures.py@@ -1,17 +1,18 @@#!/usr/bin/env python3"""Turn the publication measurements into doc/figures.json, then regenerate the charts and the README tables.-Inputs, in the scratch directory (default ~/hermes-work/pub159/scratch):+Inputs, in the --scratch directory:curve_{glm,qwen}_c272384.json served depth curve: points["8192"].."262144" (timings, usage)curve_{glm,qwen}_c524288.json served depth curve: points["499712"] (the 500K point)- bench_{glm,qwen}_c272384.md tools/bench.py --json output: card prompts (fenced JSON block)+ bench_{glm,qwen}_c272384.md tools/bench.py --json output: card prompts (fenced JSON block); not read with --keep-cardWrites doc/figures.json, keeping its schema: the previous current values become "before", the newvalues replace prefill / decode / spec, "table" is recomputed, "date" is the bench run date and"commit" is the measured commit. Then runs tools/make_charts.py and tools/make_readme_table.py.Refuses to write anything when an expected point or card value is missing or inconsistent.-usage: python3 tools/pub_to_figures.py [--scratch DIR] [--commit HASH] [--dry-run] [--no-render] [--add-500k]+usage: python3 tools/pub_to_figures.py --scratch DIR [--commit HASH] [--dry-run] [--no-render] [--add-500k]+ [--keep-card] [--skip-500k] [--models glm,qwen]"""import argparseimport copy@@ -23,7 +24,6 @@ import subprocessimport sysROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))-DEFAULT_SCRATCH = os.path.expanduser("~/hermes-work/pub159/scratch")MODELS = ("qwen", "glm")SHORT_FILE, LONG_FILE = "c272384", "c524288"POINTS = (8192, 32768, 65536, 131072, 262144)@@ -37,8 +37,9 @@ class InputError(Exception):pass-def load_curve(path, targets):- """Return {target: (prefill_tok_s, decode_tok_s)} from the server-reported timings."""+def load_curve(path, targets, client_timed=False):+ """Return {target: (prefill_tok_s, decode_tok_s)}: server-reported timings; client_timed replaces the decode+ figure by the client first-to-last-token one when the curve has it (the published method for Qwen)."""if not os.path.exists(path):raise InputError(f"missing input {path}")with open(path, encoding="utf-8") as f:@@ -55,6 +56,10 @@ def load_curve(path, targets):ptok = (p.get("usage") or {}).get("prompt_tokens")if not isinstance(ptok, int) or abs(ptok - t) > max(TOL_TOKENS, t * 0.001):raise InputError(f"{os.path.basename(path)}: point {t} has prompt_tokens={ptok}")+ if client_timed: # doc/benchmarks.md: Qwen decode is timed by the client, first to last streamed token+ cli = p.get("client_decode_tok_s")+ if isinstance(cli, (int, float)) and cli > 0:+ dec = cliout[t] = (float(pre), float(dec))return out@@ -82,15 +87,30 @@ def load_bench(path):return spec, d["date"]-def collect(scratch):- """Return ({model: {prefill: {int: v}, decode: {int: v}, spec: {...}}}, date, warnings)."""+def curve_date(path):+ """Day of the curve run (the "started" field), or None."""+ with open(path, encoding="utf-8") as f:+ started = json.load(f).get("started") or ""+ return started[:10] or None+++def collect(scratch, models=MODELS, card=True, long=True):+ """Return ({model: {prefill: {int: v}, decode: {int: v}, spec: {...} or None}}, date).++ card=False: the card prompts were not re-measured; spec is None and the date is the curve date.+ long=False: the 500K curve is not read."""data, dates = {}, []- for mid in MODELS:- short = load_curve(os.path.join(scratch, f"curve_{mid}_{SHORT_FILE}.json"), POINTS)- long = load_curve(os.path.join(scratch, f"curve_{mid}_{LONG_FILE}.json"), [POINT_500K])- spec, date = load_bench(os.path.join(scratch, f"bench_{mid}_{SHORT_FILE}.md"))- pts = dict(short)- pts.update(long)+ for mid in models:+ short_path = os.path.join(scratch, f"curve_{mid}_{SHORT_FILE}.json")+ pts = dict(load_curve(short_path, POINTS, mid == "qwen"))+ if long:+ pts.update(load_curve(os.path.join(scratch, f"curve_{mid}_{LONG_FILE}.json"), [POINT_500K], mid == "qwen"))+ if card:+ spec, date = load_bench(os.path.join(scratch, f"bench_{mid}_{SHORT_FILE}.md"))+ else:+ spec, date = None, curve_date(short_path)+ if not date:+ raise InputError(f"{os.path.basename(short_path)}: no started date")data[mid] = {"prefill": {t: pts[t][0] for t in pts},"decode": {t: pts[t][1] for t in pts},@@ -105,7 +125,7 @@ def build(F, data, date, commit, add_500k):G = copy.deepcopy(F)warnings = []ids = {m["id"] for m in G["models"]}- for mid in MODELS:+ for mid in data:if mid not in ids:raise InputError(f"figures.json has no model {mid!r}")for m in G["models"]:@@ -115,13 +135,14 @@ def build(F, data, date, commit, add_500k):m["before"] = {"prefill": m["prefill"], "decode": m["decode"], "spec": m["spec"]}published = set(m["prefill"]) | set(m["decode"])keys = list(POINTS) + ([POINT_500K] if (add_500k or str(POINT_500K) in published) else [])- if POINT_500K not in keys:+ if POINT_500K not in keys and POINT_500K in d["prefill"]:warnings.append(f"{m['id']}: 500K point measured ({d['prefill'][POINT_500K]:.1f} prefill, "f"{d['decode'][POINT_500K]:.1f} decode) but figures.json has no {POINT_500K} key; "f"not published (use --add-500k)")m["prefill"] = {str(t): round(d["prefill"][t]) for t in keys}m["decode"] = {str(t): round(d["decode"][t], 1) for t in keys}- m["spec"] = dict(d["spec"])+ if d["spec"] is not None: # card prompts re-measured; otherwise the published card values stay+ m["spec"] = dict(d["spec"])vals = list(m["spec"].values())m["table"] = {"prefill": f"{m['prefill']['8192']} at 8K","decode": f"{min(vals):.1f} to {max(vals):.1f}"}@@ -149,7 +170,11 @@ def render(root):def main(argv=None):ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])- ap.add_argument("--scratch", default=DEFAULT_SCRATCH, help="directory with the curve_*.json and bench_*.md inputs")+ ap.add_argument("--scratch", required=True, help="directory with the curve_*.json (and bench_*.md) inputs")+ ap.add_argument("--models", default=",".join(MODELS), help="comma list of models to update (default: all)")+ ap.add_argument("--keep-card", action="store_true",+ help="do not read bench_*.md: keep the published card values (spec, decode range); date = curve date")+ ap.add_argument("--skip-500k", action="store_true", help="do not read the 500K curves (partial dry run)")ap.add_argument("--root", default=ROOT, help="repository root (doc/figures.json, tools/, README templates)")ap.add_argument("--commit", help="short hash of the measured commit (default: git HEAD of --root)")ap.add_argument("--dry-run", action="store_true", help="print the diff of doc/figures.json; write nothing")@@ -157,6 +182,7 @@ def main(argv=None):ap.add_argument("--add-500k", action="store_true",help="publish the 500K point under key 499712 even if figures.json has no such key yet")a = ap.parse_args(argv)+ a.root = os.path.abspath(a.root)fig_path = os.path.join(a.root, "doc", "figures.json")try:@@ -165,7 +191,13 @@ def main(argv=None):commit = a.commit or git_head(a.root)if not commit:raise InputError("no --commit given and git HEAD is unavailable")- data, date = collect(a.scratch)+ models = tuple(m for m in a.models.split(",") if m)+ unknown = [m for m in models if m not in MODELS]+ if not models or unknown:+ raise InputError(f"--models: expected a subset of {','.join(MODELS)}, got {a.models!r}")+ if a.skip_500k and a.add_500k:+ raise InputError("--skip-500k and --add-500k contradict each other")+ data, date = collect(a.scratch, models, card=not a.keep_card, long=not a.skip_500k)G, warnings = build(json.loads(old_text), data, date, commit, a.add_500k)except (InputError, OSError, json.JSONDecodeError) as e:print(f"pub_to_figures: {e}", file=sys.stderr)diff --git a/tools/test_pub_to_figures.py b/tools/test_pub_to_figures.pyindex 34b7954..40aa68a 100644--- a/tools/test_pub_to_figures.py+++ b/tools/test_pub_to_figures.py@@ -102,14 +102,59 @@ def test_500k_point_not_published_without_flag(tmp_path, capsys):assert "499712 key" in capsys.readouterr().err-def test_500k_point_with_flag_writes_key(tmp_path):- # make_charts.py has no 499712 tick yet: rendering a published 500K point fails (see NOTEBOOK.md)+def test_500k_point_with_flag_writes_key_and_renders(tmp_path):root, scratch = make_root(tmp_path), make_scratch(tmp_path)- assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234",- "--add-500k", "--no-render"]) == 0+ assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234", "--add-500k"]) == 0q = model(load(root), "qwen")assert q["prefill"]["499712"] == 1291 and q["decode"]["499712"] == 36.2assert list(q["prefill"])[-1] == "499712"+ # the charts reach the 500K tick, labelled "500K" (499712 // 1024 would print 488K)+ svg = (root / "doc" / "img" / "decode_models.svg").read_text(encoding="utf-8")+ assert ">500K</text>" in svg and "488K" not in svg+ for name in ("prefill", "prefill_context", "decode_context"):+ assert ">500K</text>" in (root / "doc" / "img" / f"{name}.svg").read_text(encoding="utf-8")+ md = (root / "doc" / "benchmarks.md").read_text(encoding="utf-8")+ assert "Prefill 500K" in md and "488K" not in md+++def test_charts_without_500k_keep_the_256k_axis(tmp_path):+ root, scratch = make_root(tmp_path), make_scratch(tmp_path)+ assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234"]) == 0+ assert "500K" not in (root / "doc" / "img" / "decode_models.svg").read_text(encoding="utf-8")+++def test_keep_card_leaves_spec_and_needs_no_bench(tmp_path):+ root, scratch = make_root(tmp_path), make_scratch(tmp_path)+ old = load(root)+ for f in scratch.glob("bench_*.md"):+ f.unlink()+ assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234", "--keep-card",+ "--add-500k"]) == 0+ F = load(root)+ for mid in ("qwen", "glm"):+ m = model(F, mid)+ assert m["spec"] == model(old, mid)["spec"] and m["table"]["decode"] == model(old, mid)["table"]["decode"]+ assert m["before"]["spec"] == model(old, mid)["spec"]+ assert m["prefill"]["499712"] > 0+ assert model(F, "qwen")["prefill"]["8192"] == 1502 and F["date"] == "2026-10-17"+++def test_partial_dry_run_one_model_without_500k(tmp_path, capsys):+ """What can be run while the other curves are still being measured."""+ root, scratch = make_root(tmp_path), make_scratch(tmp_path)+ for f in scratch.glob("*qwen*"):+ f.unlink()+ (scratch / "curve_glm_c524288.json").unlink()+ rc = p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234", "--keep-card",+ "--models", "glm", "--skip-500k", "--dry-run"])+ assert rc == 0+ out = capsys.readouterr().out+ assert "+ \"8192\": 656," in out and "1502" not in out+++def test_scratch_is_required():+ with pytest.raises(SystemExit):+ p2f.main(["--dry-run"])def test_missing_point_refuses_and_writes_nothing(tmp_path, capsys):@@ -140,3 +185,16 @@ def test_bad_prompt_token_count_refuses(tmp_path, capsys):path.write_text(json.dumps(d), encoding="utf-8")assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234"]) == 1assert "prompt_tokens=40000" in capsys.readouterr().err+++def test_qwen_decode_is_client_timed_glm_is_server_counter(tmp_path):+ root, scratch = make_root(tmp_path), make_scratch(tmp_path)+ for mid in ("qwen", "glm"):+ path = scratch / f"curve_{mid}_c272384.json"+ d = json.loads(path.read_text(encoding="utf-8"))+ d["points"]["8192"]["client_decode_tok_s"] = 20.0+ path.write_text(json.dumps(d), encoding="utf-8")+ assert p2f.main(["--root", str(root), "--scratch", str(scratch), "--commit", "abc1234", "--no-render"]) == 0+ F = load(root)+ assert model(F, "qwen")["decode"]["8192"] == 20.0+ assert model(F, "glm")["decode"]["8192"] == 30.1