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: progress lines during first-launch tuning, finish_reason length; README: first launch, reasoning effort, memory notes
YanissAmzb882074af191
diff --git a/README.md b/README.mdindex 3c1bf18..28abd63 100644--- a/README.md+++ b/README.md@@ -36,7 +36,13 @@ python tools/glm/serve.py --model ./glm-pack --port 8000 -c 131072 --num-draft 2curl http://localhost:8000/v1/models```Run `source tools/strix_halo/env.sh` again in every new shell before serving.-Status: build and MiMo serving were verified from a fresh clone on a second Strix Halo machine (build in about 8 minutes). Both published packs were checked there against `SHA256SUMS` and served (one chat request each); `env.sh --check` has not been run there yet. The first request after a build is slow while the kernels warm up.+Status: build and MiMo serving were verified from a fresh clone on a second Strix Halo machine (build in 8 to 10 minutes). Both published packs were checked there against `SHA256SUMS` and served (one chat request each); `env.sh --check` has not been run there yet. The first request after a build is slow while the kernels warm up.++First GLM launch: the server tunes its dense GEMM kernels before it opens the port. This takes about 10 minutes, and the port stays closed during that time (the log prints a progress line every 30 seconds). The next one or two launches can repeat it for the shapes still missing; later launches start fast.++GLM 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`.++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.py b/tools/glm/serve.pyindex 45cc598..799343c 100644--- a/tools/glm/serve.py+++ b/tools/glm/serve.py@@ -355,10 +355,13 @@ def prime_dense_tune(budget_s: float = 600.0) -> tuple[int, float]:b_buf = torch.empty(max(k * n for n, k, _, _, _ in todo), device="cuda", dtype=torch.half)c_buf = torch.empty(max(cbytes(n, ldn, f32, mc) for n, _, ldn, f32, mc in todo), device="cuda", dtype=torch.uint8)print(mem_line("prime-bufs"), flush=True)- last = None+ last, shown = None, t0for n, k, ldn, f32, mc in todo:if time.perf_counter() - t0 > budget_s:break+ if time.perf_counter() - shown > 30.0: # the port opens only after this pass: show it is alive+ shown = time.perf_counter()+ print(f"serve: dense GEMM prime: {done} of {len(todo)} keys, {shown - t0:.0f} s", flush=True)dt = torch.float32 if f32 else torch.halfw = n if ldn else n + 64if last != (n, k): # finite data: the tuner keeps only winners whose output equals the default's@@ -457,6 +460,13 @@ def create_app(engine: Any, model_id: str, template: str) -> web.Application:return {"prompt_tokens": prompt_tokens, "completion_tokens": completion_tokens,"total_tokens": prompt_tokens + completion_tokens}+ def finish_for(message: dict[str, Any], raw: str) -> str:+ # A reply cut by max_tokens is "length", not "stop" (clients use it to tell a truncated answer).+ finish = message.pop("finish_reason", "stop")+ if finish == "stop" and engine.count_tokens(raw) >= body.get("max_tokens", 4096):+ finish = "length"+ return finish+def timings(raw: str) -> dict[str, Any]:# llama.cpp names: the swap orchestrator reads cache_n as the verdict of a KV restorest = getattr(engine, "last_stats", None) or {}@@ -503,7 +513,7 @@ def create_app(engine: Any, model_id: str, template: str) -> web.Application:if "tool_calls" in message:await response.write(sse(event({"tool_calls": [dict(call, index=n) for n, call in enumerate(message["tool_calls"])]})))- await response.write(sse(event({}, message.get("finish_reason", "stop")) |+ await response.write(sse(event({}, finish_for(message, text[len(prefix):])) |{"usage": usage(text[len(prefix):]), "timings": timings(text)}))await response.write(b"data: [DONE]\n\n")await response.write_eof()@@ -512,7 +522,7 @@ def create_app(engine: Any, model_id: str, template: str) -> web.Application:raw = "".join([d async for d in deltas()])text, _ = stop_text(prefix + raw, body["_stop"])message = parse_completion(text)- finish = message.pop("finish_reason", "stop")+ finish = finish_for(message, text[len(prefix):])return web.json_response({"id": request_id, "object": "chat.completion", "created": created, "model": model_id,"choices": [{"index": 0, "message": message, "finish_reason": finish}],diff --git a/tools/glm/test_serve.py b/tools/glm/test_serve.pyindex df7acbd..04d9c36 100644--- a/tools/glm/test_serve.py+++ b/tools/glm/test_serve.py@@ -89,6 +89,10 @@ class ServeTests(unittest.TestCase):self.assertEqual(body["choices"][0]["message"]["content"], "hello")self.assertEqual(body["choices"][0]["message"]["reasoning_content"], "why")self.assertIn("usage", body)+ self.assertEqual(body["choices"][0]["finish_reason"], "stop")+ cut = await (await client.post("/v1/chat/completions", json={+ "model": "test-model", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]})).json()+ self.assertEqual(cut["choices"][0]["finish_reason"], "length")await client.close()run(check())