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.

Hy4-flash v1: user guide (doc/hy4.md), changelog, README section

YanissAmz76d0e6980fa6
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..39e5f5a
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,13 @@
+# Changelog
+
+## Hy4-flash v1 (draft)
+
+Hy4-flash (GGUF Q3_K) on one Strix Halo machine. Numbers: see the benchmark table.
+
+- New `tools/hy4/serve.py`: OpenAI-compatible server for Hy4-flash with prefill fast path, HIP-graph decode, MTP drafts and prompt-lookup rows. Guide: `doc/hy4.md`.
+- Sparse-attention prefill: per-query gather MLA kernel in HIP/WMMA (`hipsp/`, H = 32 and H = 64), Triton fallback; blocked indexer score with linear-time exact top-k; sparse path from 16K keys.
+- Long-context decode: exact top-k sparse attend (`HY4_LC_SPARSE`), draft-cache fill with the same selection.
+- Prefill: fused dequant GEMMs, WMMA expert kernels shared with the GGUF MoE path, CK latent-attention core, dense GEMMs split in pieces of 8192 rows above 8192 rows.
+- Decode: static-buffer graph step, MTP head from a Q5_K copy of the output head, n-gram rows on top of the drafts, Engram rows prefetched by row.
+- Generic GGUF loader (`EXL3_GGUF_GENERIC=1`, off by default) and its CPU tests.
+- Context: 128K tokens. Single user (`--slots` is experimental). Greedy decoding only.
diff --git a/README.md b/README.md
index 3859afa..444a5f8 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,13 @@ hf download yamz-labs/GLM-5.3-Flash-EXL3-Yamz --local-dir ./glm-pack
python tools/glm/serve.py --model ./glm-pack --port 8000 -c 131072 --num-draft 2
```
+Hy4-flash (GGUF Q3_K, 128K context, one Strix Halo machine): download the publisher's GGUF and run `tools/hy4/serve.py` ([doc/hy4.md](doc/hy4.md)):
+
+```bash
+hf download AngelSlim/Hy4-flash-GGUF --include "Hy4-flash-Q3_K-*.gguf" --local-dir ./hy4
+python tools/hy4/serve.py --model ./hy4/Hy4-flash-Q3_K-00001-of-00002.gguf --port 8300 -c 131072
+```
+
RTX 3090 (NVIDIA): build for CUDA once ([tools/cuda/README.md](tools/cuda/README.md)), then Qwen3.8-27B with 245K of context (the served settings, one session), with turboderp's 4.0 bpw pack:
```bash
@@ -91,6 +98,7 @@ It prints a Markdown block. Paste it in a [benchmark report](https://github.com/
## What is inside
- Speculative decoding, on by default; it returns the same tokens as plain decoding.
+- Hy4-flash (public GGUF, Q3_K) on one Strix Halo machine: sparse-attention prefill, graph decode with MTP drafts, 128K context ([doc/hy4.md](doc/hy4.md), [changelog](CHANGELOG.md)).
- Long context: up to 983K tokens (DeepSeek V4.1 Flash on a Mac Studio), 500K on GLM-5.3-Flash.
- Image input on Qwen3.8-27B.
- Optional uncensored mode: a small run-time preset on the normal packs, off by default; it edits no weights. How it works: [doc/refusal_hook.md](doc/refusal_hook.md).
@@ -121,6 +129,7 @@ All packs are EXL3 on Hugging Face: ours on [yamz-labs](https://huggingface.co/y
- Strix Halo needs Linux (Ubuntu/Debian tested), a gfx1151 machine with 128 GB and ROCm 7.0 or newer; ROCm 6.4 has no gfx1151 code ([install](doc/install.md)).
- NVIDIA needs sm_80 or newer; tested on one RTX 3090 with 24 GB ([RTX](doc/rtx.md)).
+- Hy4-flash: one request at a time, greedy decoding, 128K context ([doc/hy4.md](doc/hy4.md)).
- The first GLM launch tunes its kernels for about 10 minutes, and the port stays closed until it finishes ([install](doc/install.md)).
- GLM at `-c 131072` leaves about 10 GiB free on a 128 GB machine ([install](doc/install.md)).
- The 763B model on one 128 GB machine is experimental: real decode is about 5 to 11 tokens per second ([Strix Halo](doc/strix.md)).
diff --git a/doc/HY4_MULTI_USER.md b/doc/HY4_MULTI_USER.md
index 22e4a71..66d0c58 100644
--- a/doc/HY4_MULTI_USER.md
+++ b/doc/HY4_MULTI_USER.md
@@ -1,6 +1,6 @@
-# Hy4 multi-session decode (perf/hy4-strix-mu, on perf/hy4-strix-int e834628)
+# Hy4 multi-session decode (experimental, `--slots`)
-## Where a session enters the step (read 19/11)
+## Where a session enters the step
- `tools/hy4/serve.py` takes an asyncio lock around `Hy4Engine.generate`: ONE request at a time. `generate` calls `reset()` (zeroes every static buffer) then prefill then the decode loop.
- `step_graph.GraphDecoder.step_rows(toks)` appends T consecutive tokens of ONE sequence to static buffers and replays a HIP graph keyed (bucket, T); T <= TM = 8.
- Per-session state in the solo engine: K rows `_ns.State.kv[layer]` [cap, 576] fp32 (every trunk layer), indexer `pool` [cap/k, d] + `vgb` [cap, 2d] (+ eager `n`, `P`, `vg`),
diff --git a/doc/hy4.md b/doc/hy4.md
new file mode 100644
index 0000000..9b17228
--- /dev/null
+++ b/doc/hy4.md
@@ -0,0 +1,65 @@
+# Hy4-flash on Strix Halo (GGUF, one machine)
+
+Kyojin loads the public Hy4-flash GGUF (Q3_K split, 2 files, 144 GiB) and serves it on one Strix Halo machine with ROCm. Prefill runs the sparse-attention
+fast path; decode runs a HIP graph with multi-token-prediction (MTP) drafts and prompt-lookup rows. Speed numbers: see the benchmark table in the release notes.
+
+## Requirements
+
+- A gfx1151 machine with 128 GB, Linux, ROCm 7.0 or newer, the repository built as in [install.md](install.md).
+- About 150 GB of free disk for the model.
+
+## Get the model
+
+The GGUF is published by AngelSlim: [AngelSlim/Hy4-flash-GGUF](https://huggingface.co/AngelSlim/Hy4-flash-GGUF). Take the Q3_K files only. The model keeps the publisher's licence.
+
+```bash
+hf download AngelSlim/Hy4-flash-GGUF --include "Hy4-flash-Q3_K-*.gguf" --local-dir ./hy4
+```
+
+## Build the optional kernels (once)
+
+The server runs without them and falls back to slower paths. Build them for the full speed:
+
+```bash
+source tools/strix_halo/env.sh build
+bash hipsp/build.sh hipsp/sp_mla.cu hipsp/libspmla.so # sparse prefill attention (HIP); without it the Triton kernel runs
+bash tools/strix_halo/ck_fmha/build_mla.sh # CK latent-attention core, written to ~/.cache/kyojin/ck-fmha/libckmla.so (EXL3_CKMLA_SO overrides)
+python tools/hy4/make_head_bin.py ./hy4/Hy4-flash-Q3_K-00001-of-00002.gguf ./hy4/head_q5_k.bin
+export HY4_MTP_HEAD_BIN=$PWD/hy4/head_q5_k.bin # Q5_K copy of the output head for the MTP drafts (smaller than the Q8_0 default)
+```
+
+`hipsp/libspmla.so` is found next to `hipsp/sp_hip.py`; `SP_SO` points to another build. The expert kernels (`exl3_gm_ext`) build on first use and are cached in `~/.cache/exl3_gm_ext`.
+
+## Run
+
+```bash
+source tools/strix_halo/env.sh
+python tools/hy4/serve.py --model ./hy4/Hy4-flash-Q3_K-00001-of-00002.gguf --port 8300 -c 131072 --num-draft 3
+curl http://127.0.0.1:8300/v1/chat/completions -H 'content-type: application/json' \
+ -d '{"messages":[{"role":"user","content":"Hello"}],"max_tokens":64}'
+```
+
+The server speaks the OpenAI API (`/v1/chat/completions`, `/v1/completions`, both with streaming; `/v1/models`, `/health`, `/tokenize`, `/apply-template`).
+`tools/hy4/serve.py` sets the shipped kernel flags (`SHIPPED_ENV` in the file); every one can be overridden from the environment. The main ones:
+
+| variable | shipped | effect |
+|---|---|---|
+| `HY4_LC_SPARSE` | 1 | exact top-k sparse attention in decode for long context |
+| `HY4_PF_SPARSE`, `HY4_PF_SPARSE_MINN` | 1, 16384 | sparse prefill attention from 16K keys |
+| `HY4_PF_MM_SPLIT` | 8192 | dense prefill GEMMs of more than 8192 rows run in pieces of 8192 (`0` = off) |
+| `HY4_NGRAM_EXT`, `HY4_NGRAM_MIN` | 4, 8 | prompt-lookup rows added to the MTP drafts when the last 8 tokens occurred before |
+| `HY4_MTP_HEAD` | q5k | head of the MTP drafts |
+
+`--num-draft` is the number of MTP drafts per round (3 by default). Memory: the K buffers are sized by `-c` (about 0.1 MB per position).
+
+## Supported context
+
+128K tokens (`-c 131072`). Longer prompts are not supported in this release.
+
+## Known limits
+
+- One request at a time; other requests queue. `--slots N` (several sessions in one batched step) is experimental, see [HY4_MULTI_USER.md](HY4_MULTI_USER.md).
+- Decoding is greedy: sampling parameters are accepted and ignored. Speculation returns the same tokens as plain greedy decoding.
+- Context above 128K is not part of this release.
+- The Engram tables (59 GiB) are read from disk by row, so the first requests after a start depend on storage speed.
+- One model and one quantization (Q3_K). Other Hy4 quantizations are not tested.