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 prefill MoE: grid order with the N tiles of one row block (and the row blocks of one expert) back to back, on by default (HY4_MOE_NFIRST=0 restores the old order): the down kernel re-read its 600 MB input 24x from DRAM; bit-identical output, down kernel 3.6 s -> 1.3 s at 8K; rope tables cached per step
YanissAmza4304b3ba828
diff --git a/exllamav3/loader/mla_hy4.py b/exllamav3/loader/mla_hy4.pyindex d4fa24c..8fc9147 100644--- a/exllamav3/loader/mla_hy4.py+++ b/exllamav3/loader/mla_hy4.py@@ -156,8 +156,11 @@ class Hy4MLA:q = _pk.qdense_raw16(qr, self.wq_b.packed, tm)with tm.t("f q: rope"):P = self.rope_dim- th = pos.double()[:, None] * (self.theta ** (-2.0 * torch.arange(P // 2, dtype=torch.float64, device=pos.device) / P))[None, :]- xh, qc = _pk.qprep(q, th.cos().float().contiguous(), th.sin().float().contiguous(), H, self.hd, self.nope, P, self.R)+ rc = pos.__dict__.setdefault("_rope_tabs", {}) # the tables depend only on (positions, theta): one fp64 evaluation per step, not per layer+ if self.theta not in rc:+ th = pos.double()[:, None] * (self.theta ** (-2.0 * torch.arange(P // 2, dtype=torch.float64, device=pos.device) / P))[None, :]+ rc[self.theta] = (th.cos().float().contiguous(), th.sin().float().contiguous())+ xh, qc = _pk.qprep(q, rc[self.theta][0], rc[self.theta][1], H, self.hd, self.nope, P, self.R)with tm.t("f q: wk_b bmm"):torch.bmm(xh, self._w16("wk_b").transpose(1, 2), out=qc[..., :self.R])return qcdiff --git a/exllamav3/loader/prefill_kernels.py b/exllamav3/loader/prefill_kernels.pyindex e793dd7..c2f397f 100644--- a/exllamav3/loader/prefill_kernels.py+++ b/exllamav3/loader/prefill_kernels.py@@ -479,7 +479,7 @@ def moe_prefill(z, sel, w, bufs, fmts, lim, nff, nout, rowb, ebytes, E, cfg=NoneP = T * SK = z.shape[1]t = tm.t if tm is not None and tm.on else (lambda n: contextlib.nullcontext())- nf = c.get("NF", MOE_NF if MOE_NF is not None else os.environ.get("HY4_MOE_NFIRST", "0") == "1")+ nf = c.get("NF", MOE_NF if MOE_NF is not None else os.environ.get("HY4_MOE_NFIRST", "1") == "1")with t("f moe: route + sort"):sp, be, maxb = route_blocks(sel.to(torch.int64), E, BM)x = to_f16(z).contiguous()