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.

GLM, MiMo serve: default reply budget 32768 tokens, as on the Qwen server

YanissAmz3e325fa198b1
diff --git a/tools/glm/SERVE.md b/tools/glm/SERVE.md
index 16fd813..212412a 100644
--- a/tools/glm/SERVE.md
+++ b/tools/glm/SERVE.md
@@ -81,8 +81,8 @@ Honored:
because the GLM template iterates them as a dict.
- `tools` — passed to the template verbatim (no server-side validation).
- `stream` (bool) — SSE or a single JSON body.
-- `max_completion_tokens` or `max_tokens` (the first wins; default **4096**), `temperature` (default **0.0** → greedy),
- `top_p` (default 1.0), `stop` (string or array; also fed to EXL3 as stop conditions).
+- `max_completion_tokens` or `max_tokens` (the first wins; default **32768**, thinking included; `--default-max-tokens`), `temperature` and
+ `top_p` (default: the pack's `generation_config.json`, 1.0 and 0.95), `stop` (string or array; also fed to EXL3 as stop conditions).
- `model` — must equal `--model-id` if present, else 400.
- `clear_thinking` — forwarded to the template as a Jinja variable.
diff --git a/tools/glm/serve.py b/tools/glm/serve.py
index 6f3ad6a..ca564fb 100644
--- a/tools/glm/serve.py
+++ b/tools/glm/serve.py
@@ -116,7 +116,7 @@ TOOL_CLOSE = "</tool_call>"
# The engine's own default stays greedy; the lane passes the model card's sampling.
# Used when a request omits the field. main() replaces the sampling values with the pack's
# generation_config.json (the model card's recommendation); command-line flags win over both.
-SERVE_DEFAULTS: dict[str, Any] = {"temperature": 1.0, "top_p": 0.95, "reasoning_effort": "medium"}
+SERVE_DEFAULTS: dict[str, Any] = {"temperature": 1.0, "top_p": 0.95, "reasoning_effort": "medium", "max_tokens": 32768}
# The model's template (levels low, high, max) with a medium level added: the model's "high" plus one instruction line.
DEFAULT_TEMPLATE = Path(__file__).resolve().parent.parent / "lanes" / "assets" / "glm53-template-medium.jinja"
@@ -224,12 +224,13 @@ def stop_text(text: str, stop: list[str]) -> tuple[str, str | None]:
return text[:pos], match
-def token_limit(body: dict[str, Any], default: int = 4096) -> int:
+def token_limit(body: dict[str, Any], default: int | None = None) -> int:
"""Reply token budget: max_completion_tokens (newer OpenAI field) wins over max_tokens."""
for key in ("max_completion_tokens", "max_tokens"):
value = body.get(key)
if isinstance(value, int) and not isinstance(value, bool) and value >= 1:
return min(value, body.get("_room") or value)
+ default = default or SERVE_DEFAULTS["max_tokens"]
return min(default, body.get("_room") or default)
@@ -856,6 +857,8 @@ def main() -> None:
help="used when a request omits temperature (default: generation_config.json)")
parser.add_argument("--default-top-p", type=float, default=None,
help="used when a request omits top_p (default: generation_config.json)")
+ parser.add_argument("--default-max-tokens", type=int, default=None,
+ help="reply budget when a request omits max_tokens, thinking included (default 32768)")
parser.add_argument("--default-reasoning-effort", choices=("low", "medium", "high", "max"), default=None,
help="thinking effort when a request omits it (default: medium)")
args = parser.parse_args()
@@ -863,7 +866,8 @@ def main() -> None:
os.environ["EXL3_ABLIT_RUNTIME"] = "off"
SERVE_DEFAULTS.update(pack_sampling(args.model))
SERVE_DEFAULTS.update({k: v for k, v in (("temperature", args.default_temperature), ("top_p", args.default_top_p),
- ("reasoning_effort", args.default_reasoning_effort)) if v is not None})
+ ("reasoning_effort", args.default_reasoning_effort),
+ ("max_tokens", args.default_max_tokens)) if v is not None})
for key, value in SPEED_ENV.items():
os.environ.setdefault(key, value)
os.environ.setdefault("EXL3_MOE_UNION_V2", "1")
diff --git a/tools/glm/test_serve.py b/tools/glm/test_serve.py
index 309119f..fa53c64 100644
--- a/tools/glm/test_serve.py
+++ b/tools/glm/test_serve.py
@@ -146,7 +146,7 @@ class ServeTests(unittest.TestCase):
def test_max_completion_tokens_is_honored(self):
self.assertEqual(serve.token_limit({"max_completion_tokens": 7, "max_tokens": 9}), 7)
self.assertEqual(serve.token_limit({"max_tokens": 9}), 9)
- self.assertEqual(serve.token_limit({"max_tokens": None}), 4096)
+ self.assertEqual(serve.token_limit({"max_tokens": None}), 32768)
from aiohttp.test_utils import TestClient, TestServer
class Spy(FakeEngine):
diff --git a/tools/mimo/SERVE.md b/tools/mimo/SERVE.md
index d96a76e..c54de80 100644
--- a/tools/mimo/SERVE.md
+++ b/tools/mimo/SERVE.md
@@ -39,7 +39,7 @@ top-level config does not carry `max_position_embeddings` — the GLM fix.
- `POST /v1/chat/completions` — `stream: true` (SSE `chat.completion.chunk`) and `false`.
`tools` / `tool_calls` / `tool` role messages, `reasoning_content` for `<think>` blocks,
- `stop` (string or list), `temperature`, `top_p`, `max_completion_tokens` or `max_tokens` (the first wins; default 4096). A reply cut by the limit reports `finish_reason: "length"`. An engine failure mid-stream ends with an `error` frame, `finish_reason: "error"` and `[DONE]`. Tool calls are emitted only
+ `stop` (string or list), `temperature`, `top_p`, `max_completion_tokens` or `max_tokens` (the first wins; default 32768, thinking included; `--default-max-tokens`). A reply cut by the limit reports `finish_reason: "length"`. An engine failure mid-stream ends with an `error` frame, `finish_reason: "error"` and `[DONE]`. Tool calls are emitted only
once the XML block closes, so a client never sees half a JSON payload.
- `GET /v1/models` — one entry, `MiMo-2.6-EXL3`.
- `GET /health` — `{"status","model","generator","spec_gate"}` once ready (load progress while starting: see below); with the gate on, `spec_gate`
diff --git a/tools/mimo/serve.py b/tools/mimo/serve.py
index 6417f16..6c1ba24 100644
--- a/tools/mimo/serve.py
+++ b/tools/mimo/serve.py
@@ -41,7 +41,7 @@ DEFAULT_NDT = 7
# Used when a request omits the field. Agent clients often send no sampling at all, and plain greedy
# makes the model loop: main() takes the values of the pack's generation_config.json (the model
# card's recommendation); command-line flags win over both.
-SERVE_DEFAULTS: dict[str, Any] = {"temperature": 1.0, "top_p": 0.95, "reasoning_effort": "medium"}
+SERVE_DEFAULTS: dict[str, Any] = {"temperature": 1.0, "top_p": 0.95, "reasoning_effort": "medium", "max_tokens": 32768}
# The model's own template plus a medium effort level (the model defines none).
DEFAULT_TEMPLATE = Path(__file__).with_name("chat_template.jinja")
@@ -211,12 +211,13 @@ def stop_text(text: str, stop: list[str]) -> tuple[str, str | None]:
return text[:pos], match
-def token_limit(body: dict[str, Any], default: int = 4096) -> int:
+def token_limit(body: dict[str, Any], default: int | None = None) -> int:
"""Reply token budget: max_completion_tokens (newer OpenAI field) wins over max_tokens."""
for key in ("max_completion_tokens", "max_tokens"):
value = body.get(key)
if isinstance(value, int) and not isinstance(value, bool) and value >= 1:
return min(value, body.get("_room") or value)
+ default = default or SERVE_DEFAULTS["max_tokens"]
return min(default, body.get("_room") or default)
@@ -808,6 +809,8 @@ def main() -> None:
help="used when a request omits temperature (default: generation_config.json)")
parser.add_argument("--default-top-p", type=float, default=None,
help="used when a request omits top_p (default: generation_config.json)")
+ parser.add_argument("--default-max-tokens", type=int, default=None,
+ help="reply budget when a request omits max_tokens, thinking included (default 32768)")
parser.add_argument("--default-reasoning-effort", choices=("medium", "none"), default=None,
help="medium (default) adds one effort instruction to the prompt; none leaves the model's own prompt")
args = parser.parse_args()
@@ -815,7 +818,8 @@ def main() -> None:
os.environ["EXL3_ABLIT_RUNTIME"] = "off"
SERVE_DEFAULTS.update(pack_sampling(args.model))
SERVE_DEFAULTS.update({k: v for k, v in (("temperature", args.default_temperature), ("top_p", args.default_top_p),
- ("reasoning_effort", args.default_reasoning_effort)) if v is not None})
+ ("reasoning_effort", args.default_reasoning_effort),
+ ("max_tokens", args.default_max_tokens)) if v is not None})
torch.set_grad_enabled(False)
drafter = None
diff --git a/tools/mimo/test_serve.py b/tools/mimo/test_serve.py
index 1c5ae43..02d429a 100644
--- a/tools/mimo/test_serve.py
+++ b/tools/mimo/test_serve.py
@@ -344,7 +344,7 @@ class ServeTests(unittest.TestCase):
"""The newer OpenAI field sets the budget (and the "length" verdict) like max_tokens."""
self.assertEqual(serve.token_limit({"max_completion_tokens": 7, "max_tokens": 9}), 7)
self.assertEqual(serve.token_limit({"max_tokens": 9}), 9)
- self.assertEqual(serve.token_limit({"max_tokens": None}), 4096)
+ self.assertEqual(serve.token_limit({"max_tokens": None}), 32768)
self.assertEqual(serve.token_limit({}), 4096)
from aiohttp.test_utils import TestClient, TestServer