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
Hy4: a missing built kernel library (repository extension, MoE extension, attention libraries) stops the server with the install step; HY4_ALLOW_SLOW=1 keeps the slow path
YanissAmzadf6cdbbacf7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d66117c..f2e9269 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,3 +12,4 @@ Hy4-flash (GGUF Q3_K) on one Strix Halo machine. Numbers: see the benchmark tabl- The server applies the frozen TunableOp results (`tools/hy4/tunableop_gfx1151.csv`) and a start-up warm-up request by default (`HY4_TUNABLEOP_FILE`, `HY4_WARMUP_TOKENS=0` to skip it), and picks up `head_q5_k.bin` next to the GGUF.- 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.+- A missing built kernel library (repository extension, MoE extension, attention libraries) stops the server with the install step; `HY4_ALLOW_SLOW=1` keeps the old slow-path start.diff --git a/doc/hy4.md b/doc/hy4.mdindex 1eedf74..9ae5643 100644--- a/doc/hy4.md+++ b/doc/hy4.md@@ -28,7 +28,7 @@ The script uses the repository venv (`EXL3_VENV`, default `.venv`), builds three- `~/.cache/exl3_gm_ext/exl3_gm_ext.so`: the MoE expert kernels (`EXL3_GM_BUILD_DIR` moves the build, `HY4_GM_EXT` points the server to it).- `~/.cache/kyojin/ck-fmha/libckmla.so`: CK latent attention (`EXL3_CKMLA_OUT` moves the build, `EXL3_CKMLA_SO` points the server to it). The script fetches composable_kernel at the pinned commit once into `~/.cache/kyojin/ck-src`; `CK_SRC` names your own checkout.-The server stops at start when the MoE extension is missing and names this script (`HY4_ALLOW_SLOW=1` starts on the slow path anyway). A missing attention library prints a warning.+The server stops at start when a built library is missing (the repository extension, the MoE extension or an attention library) and names the install step (`HY4_ALLOW_SLOW=1` starts on the slow path anyway). The kernel loaders stop the same way at run time.Optional: a Q5_K copy of the output head for the MTP drafts (0.255 GB instead of 0.394 GB for Q8_0, which the server uses when no file is given). It needs the `libggml-base.so` of a llama.cpp build:diff --git a/exllamav3/loader/hy4_forward.py b/exllamav3/loader/hy4_forward.pyindex 73b4914..3f88257 100644--- a/exllamav3/loader/hy4_forward.py+++ b/exllamav3/loader/hy4_forward.py@@ -172,6 +172,14 @@ def moe_ref(z, sel, w, rsp, lim, group=16):return lat+def _slow_path(what):+ """A fast kernel library is missing. The shipped speed needs it, so stop with the install step; HY4_ALLOW_SLOW=1 continues on the slow path (tests, CPU debugging)."""+ msg = "hy4_forward: " + what+ if os.environ.get("HY4_ALLOW_SLOW") != "1":+ raise RuntimeError(msg + ". HY4_ALLOW_SLOW=1 continues on the slow path anyway.")+ print(msg + " -> slow path (HY4_ALLOW_SLOW=1)", flush=True)++def _ext():"""the compiled extension: $HY4_EXT_DIR/exllamav3_ext*.so if set (a tree built for THIS torch, e.g. the HIP tree on the Strix), else the tree root"""if not _EXT:@@ -186,7 +194,8 @@ def _ext():_EXT.append(e)except Exception as ex: # noqa: BLE001sys.modules.pop("exllamav3_ext", None)- print("hy4_forward: extension unavailable:", repr(ex)[:160], flush=True)+ _slow_path("the repository extension exllamav3_ext is not built or does not load (" + repr(ex)[:160] + "). Build it once: ./build.sh (doc/install.md), "+ "then bash tools/hy4/install_strix.sh (HY4_EXT_DIR points at a tree built elsewhere)")_EXT.append(None)return _EXT[0]@@ -221,12 +230,15 @@ _GMX = []def _gm():if not _GMX:+ ex = Nonetry:from .. import gm_ext- _GMX.append(gm_ext.get())- except Exception as ex: # noqa: BLE001- print("hy4_forward: gm_ext unavailable:", repr(ex)[:160], flush=True)- _GMX.append(None)+ g = gm_ext.get()+ except Exception as e: # noqa: BLE001+ g, ex = None, e+ if g is None and (ex is not None or os.environ.get("EXL3_GM", "1") != "0"): # EXL3_GM=0 is the explicit opt-out+ _slow_path("the MoE kernel extension (gm_ext) is not built or does not load" + (f" ({ex!r:.160})" if ex else "") + ". Build it once: bash tools/hy4/install_strix.sh")+ _GMX.append(g)return _GMX[0]@@ -436,7 +448,8 @@ class Hy4Forward:returne = _ext()if e is None or not hasattr(e, "fq_moe_kq_grouped_mixed_q8") or not hasattr(e, "fq_moe_kq_set_swiglu_limit"):- print("hy4_forward: grouped kernel unavailable -> experts stay on the pread path", flush=True)+ _slow_path("the grouped MoE kernel is missing from exllamav3_ext (stale build?). Rebuild it: ./build.sh (doc/install.md)")+ print("hy4_forward: experts stay on the pread path", flush=True)returng, dev, budget, skipped = self.g, self.dev, int(RESIDENT_GB * 2**30), []for i in range(self.n_dense, self.n_layers):diff --git a/tests/conftest.py b/tests/conftest.pyindex 1d6468f..94e90fd 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -7,6 +7,8 @@ import torchsys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # tests/hardware.py, whatever the --import-modeimport hardware # noqa: E402+os.environ.setdefault("HY4_ALLOW_SLOW", "1") # hy4_forward stops without the built kernels; tests cover the slow path too+def pytest_configure(config):for need, reason in hardware.REASONS.items():diff --git a/tools/hy4/serve.py b/tools/hy4/serve.pyindex b8452e6..5daabb3 100644--- a/tools/hy4/serve.py+++ b/tools/hy4/serve.py@@ -12,6 +12,7 @@ and needs the kernels of tools/hy4/install_strix.sh (once). It takes no GPU lockfrom __future__ import annotationsimport argparse+import globimport asyncioimport jsonimport os@@ -58,17 +59,25 @@ SHIPPED_ENV = {def check_kernels() -> None:- """The built kernels (tools/hy4/install_strix.sh) are part of the shipped speed. A missing MoE extension stops the start with the install step- (HY4_ALLOW_SLOW=1 starts anyway on the slow path); a missing attention library prints a warning."""+ """The built kernels (doc/install.md ./build.sh, then tools/hy4/install_strix.sh) are part of the shipped speed. A missing library stops the start with the install step+ (HY4_ALLOW_SLOW=1 starts anyway on the slow path)."""home_cache = os.path.expanduser("~/.cache")+ ext_dir = os.environ.get("HY4_EXT_DIR") or TREEgm = os.environ.get("HY4_GM_EXT", os.path.join(home_cache, "exl3_gm_ext", "exl3_gm_ext.so"))sp = os.environ.get("SP_SO", os.path.join(TREE, "hipsp", "libspmla.so"))ck = os.environ.get("EXL3_CKMLA_SO") or os.path.join(os.environ.get("XDG_CACHE_HOME", home_cache), "kyojin", "ck-fmha", "libckmla.so")- if os.environ.get("HY4_MOE_HIP", "0") in ("1", "2") and not os.path.isfile(gm) and os.environ.get("HY4_ALLOW_SLOW") != "1":- sys.exit(f"hy4 serve: the MoE kernel extension is missing ({gm}).\nBuild the kernels once: bash tools/hy4/install_strix.sh (HY4_ALLOW_SLOW=1 starts on the slow path anyway).")- for flag, path, what in (("HY4_PF_SPARSE", sp, "sparse prefill attention (Triton fallback)"), ("HY4_PF_CK", ck, "CK latent attention (slower fallback)")):+ miss = []+ if not glob.glob(os.path.join(ext_dir, "exllamav3_ext*.so")):+ miss.append(f"the repository extension exllamav3_ext*.so is missing in {ext_dir} (build it: ./build.sh, doc/install.md)")+ if os.environ.get("HY4_MOE_HIP", "0") in ("1", "2") and not os.path.isfile(gm):+ miss.append(f"the MoE kernel extension is missing ({gm}; build it: bash tools/hy4/install_strix.sh)")+ for flag, path, what in (("HY4_PF_SPARSE", sp, "the sparse prefill attention library"), ("HY4_PF_CK", ck, "the CK latent attention library")):if os.environ.get(flag, "0") == "1" and not os.path.isfile(path):- print(f"hy4 serve: WARNING {path} is missing: {what}. Build it with: bash tools/hy4/install_strix.sh", file=sys.stderr, flush=True)+ miss.append(f"{what} is missing ({path}; build it: bash tools/hy4/install_strix.sh)")+ if miss and os.environ.get("HY4_ALLOW_SLOW") != "1":+ sys.exit("hy4 serve: " + "\n".join(miss) + "\nHY4_ALLOW_SLOW=1 starts on the slow path anyway.")+ for m in miss:+ print(f"hy4 serve: WARNING {m}: slow path (HY4_ALLOW_SLOW=1)", file=sys.stderr, flush=True)def apply_env(ctx: int, model: str = "") -> None: