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
Version 1.9.2: changelog, README tool calling section, doc fixes
YanissAmz1e8faa93095e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8855eec..10e354c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,8 +1,19 @@# Changelog+## 1.9.2++Hy4-flash server hotfix: tool calling, a quiet exit when the client leaves, request-parser fixes, Strix install fixes, docs.++- Tool calling (it was a 400 "not supported"): `tools` and legacy `functions`, `tool_choice` `none` / `auto` / `required` / a named function (and legacy `function_call`), assistant messages with `tool_calls`, `tool` messages with `tool_call_id`, all rendered through the GGUF chat template. Replies carry `message.tool_calls` (JSON `arguments` string, `content` null when only calls, `finish_reason` `"tool_calls"`); streamed replies carry `delta.tool_calls` (index, id and name, then the arguments). Reasoning stays in `reasoning_content`. The parser reads the model's GLM-shaped tool block (`<tool_calls>`, `<tool_call>`, `<arg_key>`, `<arg_value>`, every tag with the template suffix), types the arguments by the declared schema, and leaves a cut-off or unknown block as plain content. The template has no switch for `tool_choice`: `none` drops the tools from the prompt, a named function keeps only that tool, `required` and a named function add one instruction line to the system message (best effort).+- A client that closes the stream no longer raises in `sse()` (`ClientConnectionResetError: Cannot write to closing transport`, issue #222): the generation is cancelled, one log line is printed, no traceback. Requests that are not streamed are cancelled the same way when the client leaves. An engine error after the stream began is sent as an SSE error event followed by `[DONE]` (it used to attempt a second response and leave the client hanging).+- Chat request parser: all system / developer messages are merged into one leading system message instead of a 400; a last assistant message is continued (prefill), an empty one is dropped; `response_format` `json_object` / `json_schema` is a clean 400 "not supported yet" (it was silently ignored); `n` > 1 is a clean 400; an explicit `max_completion_tokens: null` no longer hides `max_tokens`; a `stream_options` that is not an object is a 400 (was a 500); null parts, null / empty text and `input_text` / `output_text` content parts are accepted; a message shape the template cannot read is a 400, never a 500.+- `tools/strix_halo/env.sh` finds the HSA runtime through `rocm-sdk path --root` when `EXL3_ROCM_SDK` is unset, and stops with a clear error instead of letting torch segfault when there is none (`EXL3_ALLOW_NO_HSA=1` for CPU-only use). `hipsp/build.sh` and `ck_fmha/build_mla.sh` remove the old library first and fail when the build fails (the first ended with `ls` and could exit 0 with a stale `.so`).+- Docs: the README test command uses the right port per server (Hy4-flash is on 8300) and the Hy4 example answers directly (`reasoning_effort` `no_think`); README states that reasoning goes to `reasoning_content`; README version line, CHANGELOG 1.9.1 wording and the venv command (`python3.12`) are consistent across the install docs.+- New: `tools/hy4/tool_smoke.py`, a served smoke test of tool calling and client disconnect. New CPU tests: `tests/test_hy4_tools_cpu.py`, `tests/test_hy4_compat_cpu.py`, `tests/test_strix_scripts_cpu.py`.+## 1.9.1-Hy4-flash: faster prefill and decode on the same GGUF, decensor preset, warm-up fix. Every lever below ships on and has its own switch: `HY4_<FLAG>=0` in the environment restores the 1.9.0 behaviour of that lever. The flag table is in `doc/env_vars.md`; numbers are in the release notes.+Hy4-flash: faster prefill at every depth and faster decode on the same prompt (the 32K served decode cell reads lower than 1.9.0 because that prompt's tau and generated text differ; see the README table note), decensor preset, warm-up fix. Every lever below ships on and has its own switch: `HY4_<FLAG>=0` in the environment restores the 1.9.0 behaviour of that lever. The flag table is in `doc/env_vars.md`; numbers are in the release notes.- Decensor preset for Hy4-flash, opt-in and off by default (`HY4_ABLIT_SPEC=on` loads the bundled preset; an explicit path loads another spec). Validated in no_think mode; in the default thinking mode some answers run long (2 of 17 hit the 4096-token cap in our check), a fix is in progress. A per-layer run-time edit of the attention and MLP / MoE outputs, no weight change. Files in `presets/hy4-uncensor/`, code in `exllamav3/loader/ablit_hy4.py`.- Prefill: lazy layer residual, 3 stream passes per layer (`HY4_PF_HC2`); head-major K / V and Q / O operands for the CK latent-attention core (`HY4_PF_KV_HM`, `HY4_PF_QO_HM`); Q3_K gate-up kernel V2 with packed fp16 decode and aligned dword loads, bit-identical to the old kernel (`HY4_PF_Q3K_V2`; needs the rebuilt MoE extension, which `install_strix.sh` rebuilds; the old kernel runs when the library is older or K / 256 is odd).diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 98f4e0f..e3e5957 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -14,7 +14,7 @@ Thank you for helping. Kyojin is the Yamz inference engine for AMD Strix Halo, bFollow the Quickstart in `README.md`. In short:```bash-python3 -m venv .venv && source .venv/bin/activate+python3.12 -m venv .venv && source .venv/bin/activatepip install --pre torch rocm-sdk-devel --index-url https://rocm.nightlies.amd.com/v2/gfx1151/pip install -r requirements.txtrocm-sdk initdiff --git a/README.md b/README.mdindex b5b0851..a11a611 100644--- a/README.md+++ b/README.md@@ -19,7 +19,7 @@<tr><td align="center" width="25%"><a href="https://huggingface.co/yamz-labs/GLM-5.3-Flash-EXL3-Yamz"><picture><source media="(prefers-color-scheme: dark)" srcset="doc/img/home/card-glm-dark.svg"><img src="doc/img/home/card-glm-light.svg" alt="GLM-5.3-Flash on Strix Halo: 32 tok/s decode, 633 tok/s prefill" width="100%"></picture></a></td><td align="center" width="25%"><a href="https://huggingface.co/yamz-labs/Qwen3.8-Flash-Next-EXL3-Yamz"><picture><source media="(prefers-color-scheme: dark)" srcset="doc/img/home/card-flash-next-dark.svg"><img src="doc/img/home/card-flash-next-light.svg" alt="Qwen3.8-Flash-Next on Strix Halo: 53 tok/s decode, 1,576 tok/s prefill" width="100%"></picture></a></td><td align="center" width="25%"><a href="https://huggingface.co/turboderp/Qwen3.8-27B-exl3/tree/SC_4.00bpw_H5_V6"><picture><source media="(prefers-color-scheme: dark)" srcset="doc/img/home/card-qwen27-dark.svg"><img src="doc/img/home/card-qwen27-light.svg" alt="Qwen3.8-27B on RTX 3090: 75 tok/s decode, 1,621 tok/s prefill" width="100%"></picture></a></td><td align="center" width="25%"><a href="https://huggingface.co/yamz-labs/DeepSeek-V4.1-Flash-EXL3-Yamz"><picture><source media="(prefers-color-scheme: dark)" srcset="doc/img/home/card-ds41-dark.svg"><img src="doc/img/home/card-ds41-light.svg" alt="DeepSeek V4.1 Flash on Mac Studio M5 Ultra: 62 tok/s decode, 3,001 tok/s prefill" width="100%"></picture></a></td></tr></table>-<p align="center"><sub>Decode and prefill tok/s at 8K (RTX: 5K), served. Kyojin 1.8.10 on Strix Halo, 1.8.9 on RTX and Mac.</sub></p>+<p align="center"><sub>Decode and prefill tok/s at 8K (RTX: 5K), served. Measured on Kyojin 1.8.10 (Strix Halo) and 1.8.9 (RTX, Mac); the Hy4-flash numbers in the table below are 1.9.1.</sub></p>## Quick start@@ -78,13 +78,34 @@ Every server speaks the OpenAI API. More commands: [doc/models.md](doc/models.md### Test it-With a server running on port 8000 (the Mac command above uses 8080):+With a server running, use its port: GLM on 8000 (the command above), Hy4-flash on 8300, the Mac command above on 8080.```bashcurl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" \-d '{"messages": [{"role": "user", "content": "Say hello in five words."}]}'```+Hy4-flash thinks before it answers: the reasoning comes back in `reasoning_content` and the answer in `content`, so a small `max_tokens` can end inside the reasoning and leave `content` empty. For a direct answer add `"reasoning_effort": "no_think"` (or `"chat_template_kwargs": {"reasoning_effort": "no_think"}`), or leave room for the reasoning with a larger `max_tokens`:++```bash+curl http://localhost:8300/v1/chat/completions -H "Content-Type: application/json" \+ -d '{"messages": [{"role": "user", "content": "Say hello in five words."}], "reasoning_effort": "no_think", "max_tokens": 64}'+```++### Tool calling++The Hy4-flash server speaks the OpenAI tool-calling API: `tools` (and the legacy `functions`), `tool_choice` (`none`, `auto`, `required` or a named function; the model template has no switch for it, so `required` and a named function add one instruction line to the system message and the model decides), assistant messages with `tool_calls`, and `tool` messages with the result. A reply that calls a function has `finish_reason` `"tool_calls"` and `message.tool_calls`; streamed, the calls arrive as `delta.tool_calls`. The reasoning stays in `reasoning_content`.++```bash+curl http://localhost:8300/v1/chat/completions -H "Content-Type: application/json" -d '{+ "messages": [{"role": "user", "content": "What is the weather in Paris?"}],+ "tools": [{"type": "function", "function": {"name": "get_weather", "description": "Current weather of a city.",+ "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}],+ "reasoning_effort": "low", "max_tokens": 1024}'+```++Send the result back with the call: add the assistant message with its `tool_calls` and a `{"role": "tool", "tool_call_id": "<id of the call>", "content": "<result>"}` message, and the model answers in text. `python tools/hy4/tool_smoke.py --base http://localhost:8300` checks a running server end to end (tool call, stream, round trip, a client that closes the stream). `response_format` `json_object` / `json_schema` is not supported yet (a 400); several system messages are merged into one, and a last assistant message is continued (prefill).+## Speed by contextTokens per second against context length (log scale), served through the real server with real text. Each chart says its machine, Kyojin version and date. Higher is better.diff --git a/build.sh b/build.shindex 9a18843..22ad803 100755--- a/build.sh+++ b/build.sh@@ -10,7 +10,7 @@ export EXL3_ROCM_DEV_INCLUDE="${EXL3_ROCM_DEV_INCLUDE:-}"export MAX_JOBS="${MAX_JOBS:-6}" PYTORCH_ROCM_ARCH="${PYTORCH_ROCM_ARCH:-gfx1151}"# Preflight: fail early with a readable message instead of "CUDA_HOME environment variable is not set".if [ ! -x "$EXL3_VENV/bin/python" ]; then- echo "[build] no venv at $EXL3_VENV. Run: python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt" >&2; exit 1+ echo "[build] no venv at $EXL3_VENV. Run: python3.12 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt" >&2; exit 1fiif [ -z "$("$EXL3_VENV/bin/python" -c 'import torch; print(torch.version.hip or "")' 2>/dev/null)" ]; thenecho "[build] the venv's PyTorch is not a ROCm build (torch.version.hip is empty). Install the ROCm wheel for gfx1151 first, see README.md." >&2; exit 1diff --git a/doc/hy4.md b/doc/hy4.mdindex c6c0aac..b759667 100644--- a/doc/hy4.md+++ b/doc/hy4.md@@ -43,9 +43,13 @@ The server finds `head_q5_k.bin` by itself when it sits next to the GGUF (`HY4_M```bashpython tools/hy4/serve.py --model ./hy4/Hy4-flash-Q3_K-00001-of-00002.gguf --port 8300 -c 65536 --num-draft 3curl http://127.0.0.1:8300/v1/chat/completions -H 'content-type: application/json' \- -d '{"messages":[{"role":"user","content":"Hello"}],"max_tokens":64}'+ -d '{"messages":[{"role":"user","content":"Hello"}],"reasoning_effort":"no_think","max_tokens":64}'```+Hy4-flash thinks first by default (`reasoning_effort` high): the reasoning is returned in `reasoning_content`, the answer in `content`, and a small `max_tokens` can end inside the reasoning with `content` empty. `"reasoning_effort": "no_think"` (or `"chat_template_kwargs": {"reasoning_effort": "no_think"}`) answers directly; otherwise leave room, for example `max_tokens` 1024.++Tool calling (1.9.2): `tools` / `tool_choice` / `tool_calls` / `tool` messages work as in the OpenAI API, streamed or not (README "Tool calling"). `python tools/hy4/tool_smoke.py --base http://127.0.0.1:8300` runs the served check. A client that closes a stream stops the generation. Not supported: `n` > 1, `response_format` `json_object` / `json_schema` (400, no constrained decoding), images and audio.+The 1.9.1 levers are listed with their rollback switches in the [env_vars.md](env_vars.md) table "Hy4-flash 1.9.1 levers". After updating from 1.9.0 run `bash tools/hy4/install_strix.sh` again (the Q3_K V2 kernel needs the rebuilt MoE extension; without it the old kernel runs).The server speaks the OpenAI API (`/v1/chat/completions`, `/v1/completions`, both with streaming; `/v1/models`, `/health`, `/tokenize`, `/apply-template`).diff --git a/doc/install.md b/doc/install.mdindex 778ee2e..53bd3a7 100644--- a/doc/install.md+++ b/doc/install.md@@ -4,7 +4,7 @@ Requirements: Linux (Ubuntu/Debian tested), a gfx1151 machine with 128 GB, Pytho```bashgit clone https://github.com/Yamz-Labs/kyojin && cd kyojin-python3 -m venv .venv && source .venv/bin/activate+python3.12 -m venv .venv && source .venv/bin/activate# 1. ROCm torch + SDK first (AMD gfx1151 wheels; plain `pip install torch` gives a CUDA/CPU build that cannot run here):pip install --pre torch rocm-sdk-devel --index-url https://rocm.nightlies.amd.com/v2/gfx1151/pip install -r requirements.txtdiff --git a/exllamav3/version.py b/exllamav3/version.pyindex 38cf6db..2cbc28c 100644--- a/exllamav3/version.py+++ b/exllamav3/version.py@@ -1 +1 @@-__version__ = "1.9.1"+__version__ = "1.9.2"diff --git a/tools/strix_halo/env.sh b/tools/strix_halo/env.shindex c7db24d..d42fcae 100755--- a/tools/strix_halo/env.sh+++ b/tools/strix_halo/env.sh@@ -100,7 +100,7 @@ fiif [ "${1:-}" = "--check" ]; thenif [ ! -x "$EXL3_VENV/bin/python" ]; then- echo "[env.sh] no venv at $EXL3_VENV. Create it (python3 -m venv .venv) or set EXL3_VENV." >&2+ echo "[env.sh] no venv at $EXL3_VENV. Create it (python3.12 -m venv .venv) or set EXL3_VENV." >&2exit 1fi"$EXL3_VENV/bin/python" - <<'PY'