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
GLM server: make the MTP eh_proj sidecar optional on a fresh install
YanissAmz579c762f983e
diff --git a/README.md b/README.mdindex 761d07a..92383c8 100644--- a/README.md+++ b/README.md@@ -42,6 +42,8 @@ First GLM launch: the server tunes its dense GEMM kernels before it opens the poGLM reasons at maximum effort by default. With a small `max_tokens`, the reasoning can use the whole budget: `content` is then empty and `finish_reason` is `length`. Send `"reasoning_effort": "low"` in the request (or start the server with `--default-reasoning-effort low`), or allow at least 1000 tokens. The server defaults to greedy sampling when a request gives no temperature; set the sampling values of the model card in your client, or with `--default-temperature` and `--default-top-p`.+Optional for GLM: an unquantized MTP `eh_proj` sidecar raises draft acceptance (about +5 % decode). The pack does not ship it and the server starts without it (one log line). To add it, see "Optional MTP sidecar" in `tools/glm/SERVE.md`.+Memory: GLM at `-c 131072` leaves about 10 GiB free on a 128 GB machine. Close browsers and other large processes first, or use a smaller `-c`.MiMo: `hf download yamz-labs/MiMo-V2.6-Flash-MOPD-EXL3-Yamz --local-dir ./mimo-pack`, then `python tools/mimo/serve.py --model ./mimo-pack --port 8000 -c 131072`. Speculative decoding (DFlash, 4 bpw drafter, confidence-truncated drafts) is on by default: the server uses the pack's `drafter/` directory (or `$MIMO_DRAFTER`, or `--drafter <dir>`). Without a drafter it logs one line and decodes plain. Set `MIMO_SPEC=0` in the lane script (`tools/lanes/serve_mimo.sh`) or pass `--no-dflash` to `serve.py` for plain decode. Greedy output under speculation is not token-identical to plain decode: near-tied logits can flip under the batched verify. A loaded drafter costs 2 to 4 % prefill. Details: `tools/mimo/SERVE.md`.diff --git a/tools/glm/SERVE.md b/tools/glm/SERVE.mdindex 89ce6be..734fb3e 100644--- a/tools/glm/SERVE.md+++ b/tools/glm/SERVE.md@@ -36,6 +36,23 @@ wins): `EXL3_MOE_UNION_V2=1`, `EXL3_MOE_CFG=2`, `EXL3_HIP_PREFILL_MIN_ROWS=2`,`Generator.MTP_FUSE_CATCHUP = 2`. There is no `--temperature`/seed handling beyond therequest body.+### Optional MTP sidecar (higher draft acceptance)++The published pack stores the MTP `eh_proj` at 2 bits. An unquantized copy raises draft+acceptance (about +0.08) and decode speed (about +5 %), but the pack does not ship it and+the server runs fine without it. If `EXL3_MTP_EH_FP16` is not set, the server uses+`~/models/glm53-mtp-eh-proj-bf16.safetensors` when that file exists and otherwise starts+without it, with one log line. To add it, extract it once from the official GLM-5.3+checkpoint (BF16 `eh_proj`, about 64 MiB), then point the server at it:++```bash+python tools/glm/mtp_eh_sidecar.py <official GLM-5.3 checkpoint dir> ~/models/glm53-mtp-eh-proj-bf16.safetensors+# or any path, with: EXL3_MTP_EH_FP16=<path> python tools/glm/serve.py ...+```++An explicit `EXL3_MTP_EH_FP16=<path>` that does not exist stops the load with an error;+`EXL3_MTP_EH_FP16=0` turns the sidecar off.+## Endpoints### `GET /v1/models`diff --git a/tools/glm/serve.py b/tools/glm/serve.pyindex 799343c..9379b1a 100644--- a/tools/glm/serve.py+++ b/tools/glm/serve.py@@ -20,6 +20,7 @@ from aiohttp import webfrom jinja2.sandbox import ImmutableSandboxedEnvironmentDEFAULT_MODEL = "~/models/glm53-exl3-td205"+EH_SIDECAR_DEFAULT = "~/models/glm53-mtp-eh-proj-bf16.safetensors"SPEED_ENV = {"EXL3_MOE_CFG": "2","EXL3_HIP_PREFILL_MIN_ROWS": "2",@@ -35,8 +36,7 @@ SPEED_ENV = {"EXL3_PREFILL_BIG_CHUNK_MAXPOS": "32768", # mem512k1: plain chunks beyond 32K depth, lower peak memory at 512K ctx# 27/09 acceptaudit2 WIN: unquantized MTP eh_proj (td205 stores it at 2 bpw, cos 0.79):# served accept +0.077 +- 0.008 (n=24), target ids 24/24 equal, serve_accept decode +4.8 %.- # Sidecar: python tools/glm/mtp_eh_sidecar.py ~/models/glm53-fp8 <path>.- "EXL3_MTP_EH_FP16": "~/models/glm53-mtp-eh-proj-bf16.safetensors",+ # The published pack does not ship the sidecar: it is optional (see apply_eh_sidecar_default()).# 27/09 verifyfuse1 WIN: R-row verify linears in one launch (Hadamards in-kernel):# served R=2 round -3.04 +- 0.20 ms, +6.7 % t/s; R=1 bitwise, R=2 greedy 64/64."EXL3_VERIFY_FUSE": "1",@@ -69,6 +69,28 @@ SPEED_ENV = {"EXL3_PF_MSPLIT": "2048","EXL3_PF_SKIP": "1",}++def apply_eh_sidecar_default() -> str:+ """Use the optional unquantized MTP eh_proj sidecar only when it exists.++ An explicit EXL3_MTP_EH_FP16 is never touched (a wrong path still fails loudly at load).+ Otherwise the default path is used if the file is there, and the server starts without it+ (one log line) if not: the sidecar only raises draft acceptance, it is not needed to run.+ Returns the outcome: "explicit", "default" or "absent".+ """+ if "EXL3_MTP_EH_FP16" in os.environ:+ return "explicit"+ path = os.path.expanduser(EH_SIDECAR_DEFAULT)+ if os.path.isfile(path):+ os.environ["EXL3_MTP_EH_FP16"] = path+ return "default"+ print(f"serve: no MTP eh_proj sidecar at {EH_SIDECAR_DEFAULT}: running without it "+ "(draft acceptance is a little lower). To add it: python tools/glm/mtp_eh_sidecar.py "+ "<official GLM-5.3 checkpoint dir> <out.safetensors>, then set EXL3_MTP_EH_FP16=<out.safetensors>.",+ flush=True)+ return "absent"++# The template deliberately uses a zero-width space so normal prose does not trigger tools.TOOL_OPEN = "<tool_call>"TOOL_CLOSE = "</tool_call>"@@ -650,6 +672,7 @@ def main() -> None:for key, value in SPEED_ENV.items():os.environ.setdefault(key, value)os.environ.setdefault("EXL3_MOE_UNION_V2", "1")+ apply_eh_sidecar_default()engine = ResidentEngine(args.model, max_history=args.max_history or args.num_draft, max_ctx=args.max_ctx, num_draft=args.num_draft)template = Path(args.chat_template or Path(args.model) / "chat_template.jinja").expanduser().read_text(encoding="utf-8")print(mem_line("loaded"), flush=True)diff --git a/tools/glm/test_serve.py b/tools/glm/test_serve.pyindex 04d9c36..f5c8deb 100644--- a/tools/glm/test_serve.py+++ b/tools/glm/test_serve.py@@ -33,6 +33,27 @@ def run(coro):class ServeTests(unittest.TestCase):template = "{% for m in messages %}<|im_start|>{{ m.role }}: {{ m.content }}<|im_end|>{% endfor %}{% if tools %}TOOLS={{ tools|length }}{% endif %}"+ def test_eh_sidecar_default_is_optional(self):+ import os, tempfile+ from unittest import mock+ with tempfile.TemporaryDirectory() as home:+ with mock.patch.dict(os.environ, {"HOME": home}):+ os.environ.pop("EXL3_MTP_EH_FP16", None)+ # fresh install: no file -> variable stays unset, no FileNotFoundError at load+ self.assertEqual(serve.apply_eh_sidecar_default(), "absent")+ self.assertNotIn("EXL3_MTP_EH_FP16", os.environ)+ # file present at the default path -> used+ path = Path(home) / "models" / "glm53-mtp-eh-proj-bf16.safetensors"+ path.parent.mkdir()+ path.write_bytes(b"x")+ self.assertEqual(serve.apply_eh_sidecar_default(), "default")+ self.assertEqual(os.environ["EXL3_MTP_EH_FP16"], str(path))+ # explicit value (even a missing file) is never touched+ os.environ["EXL3_MTP_EH_FP16"] = "/nope/x.safetensors"+ self.assertEqual(serve.apply_eh_sidecar_default(), "explicit")+ self.assertEqual(os.environ["EXL3_MTP_EH_FP16"], "/nope/x.safetensors")+ self.assertNotIn("EXL3_MTP_EH_FP16", serve.SPEED_ENV)+def test_template_rendering(self):out = serve.render_prompt(self.template, [{"role": "user", "content": "hi"}], [{"type": "function"}])self.assertEqual(out, "<|im_start|>user: hi<|im_end|>TOOLS=1")