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: lazy layer residual (HY4_PF_HC2), head-major CK attention operands (HY4_PF_KV_HM, HY4_PF_QO_HM) and fp16 router logits of prefill rows (HY4_PF_ROUTER16), shipped on; =0 restores 1.9.0
YanissAmzde740838ba42
diff --git a/exllamav3/loader/hc_fused.py b/exllamav3/loader/hc_fused.pyindex 08680e5..0b89080 100644--- a/exllamav3/loader/hc_fused.py+++ b/exllamav3/loader/hc_fused.py@@ -89,14 +89,29 @@ def _k2_collapse(x_ptr, part_ptr, sq_ptr, base_ptr, scale_ptr, w_ptr, post_ptr,@triton.jitdef _k12_row(x_ptr, y_ptr, post_ptr, s_ptr, fn_ptr, base_ptr, scale_ptr, w_ptr, postout_ptr, cur_ptr, cur16_ptr,D, K, eps, hc_eps, mag,- H: tl.constexpr, HP: tl.constexpr, NO: tl.constexpr, HAS_RES: tl.constexpr, EMIT16: tl.constexpr, BD: tl.constexpr):- """K1 + K2 in one program per row: the whole [H, D] row is held in registers (read once, residual written once)"""+ pf_ptr, ppost_ptr, pw_ptr, er_ptr, ew_ptr, emu_ptr, peps,+ H: tl.constexpr, HP: tl.constexpr, NO: tl.constexpr, HAS_RES: tl.constexpr, EMIT16: tl.constexpr, BD: tl.constexpr,+ PEND: tl.constexpr = False, HAS_EDIT: tl.constexpr = False):+ """K1 + K2 in one program per row: the whole [H, D] row is held in registers (read once, residual written once)+ PEND: x_ptr holds the PREVIOUS layer's s1 and the previous residual (K3) is applied here, in registers: x = s1 + ppost * (rms(f) * pw)+ (the previous layer's output x is never written to memory; K3's arithmetic, expression for expression)"""r = tl.program_id(0)hv = tl.arange(0, HP)d = tl.arange(0, BD)off = hv[:, None] * D + d[None, :]xm = (hv[:, None] < H) & (d[None, :] < D)x = tl.load(x_ptr + r * K + off, mask=xm, other=0.0)+ if PEND:+ f = tl.load(pf_ptr + r * D + d, mask=d < D, other=0.0)+ frc = tl.math.rsqrt(tl.sum(f * f, axis=0) / D + peps)+ fnv = f * frc * tl.load(pw_ptr + d, mask=d < D, other=0.0)+ if HAS_EDIT:+ er = tl.load(er_ptr + d, mask=d < D, other=0.0)+ ew = tl.load(ew_ptr)+ fe = fnv - ew * (tl.sum(fnv * er, axis=0) - tl.load(emu_ptr)) * er+ fnv = tl.where(ew == 0.0, fnv, fe)+ pp = tl.load(ppost_ptr + r * H + hv, mask=hv < H, other=0.0)+ x = x + pp[:, None] * fnv[None, :]if HAS_RES:yv = tl.load(y_ptr + r * D + d, mask=d < D, other=0.0)pv = tl.load(post_ptr + r * H + hv, mask=hv < H, other=0.0)@@ -159,7 +174,7 @@ def ok(x, hw, H):return fn.dtype == torch.float32 and fn.shape[1] == H * x.shape[2] and fn.shape[0] in (H, 2 * H) and x.shape[2] <= MAX_D-def _mix(x, y, post_prev, hw, w, eps, hc_eps, mag):+def _mix(x, y, post_prev, hw, w, eps, hc_eps, mag, pend=None):T, H, D = x.shapefn, base, scale = hwNO = fn.shape[0]@@ -173,12 +188,19 @@ def _mix(x, y, post_prev, hw, w, eps, hc_eps, mag):post = torch.empty(T, H, dtype=torch.float32, device=dev) if NO == 2 * H else Nonecur = torch.empty(T, D, dtype=torch.float32, device=dev)cur16 = torch.empty(T, D, dtype=torch.float16, device=dev) if EMIT16[0] else cur+ if pend is None:+ pa = (x, x, x, x, x, x, 0.0)+ else:+ er, ew, emu = pend.edit if pend.edit is not None else (x, x, x)+ pa = (pend.f, pend.post, pend.w_post, er, ew, emu, pend.eps)_k12_row[(T,)](x, y if has_res else x, post_prev if has_res else x, s, fn, base, scale, w, post if post is not None else cur, cur, cur16,- D, K, eps, hc_eps, mag, H=H, HP=_p2(H), NO=NO, HAS_RES=has_res, EMIT16=EMIT16[0], BD=_p2(D), num_warps=8)+ D, K, eps, hc_eps, mag, *pa, H=H, HP=_p2(H), NO=NO, HAS_RES=has_res, EMIT16=EMIT16[0], BD=_p2(D),+ PEND=pend is not None, HAS_EDIT=pend is not None and pend.edit is not None, num_warps=8)if EMIT16[0]:from . import prefill_kernels as _pk_pk.register_f16(cur, cur16)return s, post, cur+ assert pend is Nonepart = torch.empty(T, NCH, NOP, dtype=torch.float32, device=dev)sq = torch.empty(T, NCH, dtype=torch.float32, device=dev)has_res = y is not None@@ -194,15 +216,30 @@ def _mix(x, y, post_prev, hw, w, eps, hc_eps, mag):return s, post, cur-def site(x, hw, w_norm, eps, hc_eps, mag):+def site(x, hw, w_norm, eps, hc_eps, mag, pend=None):"""site A / head: x [T,H,D] -> (post [T,H] or None for a pre-only head fn, cur [T,D] = rms(sum_h pre_h x_h) * w_norm)"""- _, post, cur = _mix(x, None, None, hw, w_norm.contiguous(), eps, hc_eps, mag)+ _, post, cur = _mix(x, None, None, hw, w_norm.contiguous(), eps, hc_eps, mag, pend)return post, cur-def res_site(x, y, post_prev, hw, w_norm, eps, hc_eps, mag):+def res_site(x, y, post_prev, hw, w_norm, eps, hc_eps, mag, pend=None):"""s = x + post_prev[:, :, None] * y[:, None, :]; then the site on s -> (s, post, cur)"""- return _mix(x, y.float().contiguous(), post_prev.float().contiguous(), hw, w_norm.contiguous(), eps, hc_eps, mag)+ return _mix(x, y.float().contiguous(), post_prev.float().contiguous(), hw, w_norm.contiguous(), eps, hc_eps, mag, pend)+++def lazy(): # read live (arm switching in one process)+ return ONEPASS and os.environ.get("HY4_PF_HC2", "0") == "1" # layer output left as (s1, f, post): K3 runs inside the next layer's two site kernels (3 stream passes per layer instead of 5)+++class Pend:+ """the previous layer's residual K3 not yet applied: its output x = s + post[:, :, None] * (rms(f) * w_post)[:, None, :] (edit: optional edit of the layer output)"""+ __slots__ = ("s", "f", "post", "w_post", "eps", "edit")++ def __init__(self, s, f, post, w_post, eps, edit=None):+ self.s, self.f, self.post, self.w_post, self.eps, self.edit = s, f.float().contiguous(), post.float().contiguous(), w_post.contiguous(), eps, edit++ def materialize(self):+ return resid(self.s, self.f, self.post, self.w_post, self.eps)def resid(s, f, post, w_post, eps):diff --git a/exllamav3/loader/hy4_forward.py b/exllamav3/loader/hy4_forward.pyindex c008bfa..0a86562 100644--- a/exllamav3/loader/hy4_forward.py+++ b/exllamav3/loader/hy4_forward.py@@ -608,6 +608,10 @@ class Hy4Forward:if getattr(L, "router16", None) is None:L.router16 = L.router.half().contiguous()p = torch.sigmoid(_pk().mm_f32(_pk().to_f16(x), L.router16.T))+ elif T > MMVQ_MAXR and dev.type == "cuda" and x.dtype == torch.float32 and os.environ.get("HY4_PF_ROUTER16", "0") == "1": # fp16 operands, fp32 accumulate AND fp32 logits (the fp32 GEMM runs at ~5 TFLOPS)+ if getattr(L, "router16", None) is None:+ L.router16 = L.router.half().contiguous()+ p = torch.sigmoid(_pk().mm16_f32(_pk().to_f16(x), L.router16))else:p = torch.sigmoid(_RG.mm(x, L.router))sel = torch.sort(p + L.rbias, dim=-1, descending=True, stable=True).indices[:, :self.topk] # stable: tied experts resolve to the lowest id every call (torch.topk tie order varies between calls on gfx1151)@@ -790,6 +794,12 @@ class Hy4Forward:def layer(self, i, x, pos, ids, start):L = self._layer(i)+ pend = None+ if _HCF is not None and isinstance(x, _HCF.Pend): # HY4_PF_HC2: the previous layer's residual is applied inside this layer's two site kernels+ pend = x+ x = pend.s+ if i in self.ple or not _HCF.ok(x, L.hca, self.hc):+ x, pend = pend.materialize(), NoneT = x.shape[0]if _AE.ENABLED: # HY4_ATTN_EAGER: host bound for the rope tables (no sync)_AE.ensure(start + T)@@ -800,8 +810,9 @@ class Hy4Forward:tm = self.tmwith tm.t("hc / norms"):if _HCF is not None and _HCF.ok(x, L.hca, self.hc):- post, cur = _HCF.site(x, L.hca, L.attn_norm, self.eps, self.hc_eps, self.magnitude)+ post, cur = _HCF.site(x, L.hca, L.attn_norm, self.eps, self.hc_eps, self.magnitude, pend)else:+ assert pend is Nonepre, post = self._site(x, L.hca)cur = rms((x * pre[:, :, None]).sum(1), self.eps) * L.attn_normmla = L.mla@@ -846,8 +857,10 @@ class Hy4Forward:self._hk("attn_out", i, out)with tm.t("hc / norms"):if _HCF is not None and _HCF.ok(x, L.hcf, self.hc) and out.shape == (T, self.D):- s1, post2, cur2 = _HCF.res_site(x, out, post, L.hcf, L.ffn_norm, self.eps, self.hc_eps, self.magnitude)+ s1, post2, cur2 = _HCF.res_site(x, out, post, L.hcf, L.ffn_norm, self.eps, self.hc_eps, self.magnitude, pend)else:+ if pend is not None:+ x, pend = pend.materialize(), Nones1 = x + post[:, :, None] * out[:, None, :]pre2, post2 = self._site(s1, L.hcf)cur2 = rms((s1 * pre2[:, :, None]).sum(1), self.eps) * L.ffn_norm@@ -856,6 +869,9 @@ class Hy4Forward:self._hk("ffn_moe_out", i, lat)with tm.t("hc / norms"):if _HCF is not None and _HCF.ok(s1, L.hcf, self.hc) and f.shape == (T, self.D):+ if (_HCF.lazy() and T > _HCF.PF_MIN_ROWS and self.hook is None and self._gs is None and i + 1 < self.n_layers+ and i + 1 not in self.ple and self.hc <= 8): # HY4_PF_HC2: hand (s1, f, post) to the next layer instead of writing x+ return _HCF.Pend(s1, f, post2, L.post_ffw, self.eps)s2 = _HCF.resid(s1, f, post2, L.post_ffw, self.eps)else:f = rms(f, self.eps) * L.post_ffwdiff --git a/exllamav3/loader/mla_hy4.py b/exllamav3/loader/mla_hy4.pyindex 42070e7..690fec8 100644--- a/exllamav3/loader/mla_hy4.py+++ b/exllamav3/loader/mla_hy4.py@@ -242,9 +242,10 @@ class Hy4MLA:return self.hd == 256 and self.vd == 256 and self.R == 512 and self.rope_dim == 64 and ck_mla.available()def _kvw(self):+ from . import prefill_unabs as _puw = self.__dict__.get("_kvw_c")- if w is None:- from . import prefill_unabs as _pu+ if w is None or (w.dim() == 3) != _pu.kv_head_major(): # the layout follows HY4_PF_KV_HM (one resident copy: the other layout is dropped)+ self._kvw_c = Nonew = self._kvw_c = _pu.kv_weight(self._w16("wk_b"), self._w16("wv_b"))return w@@ -271,7 +272,10 @@ class Hy4MLA: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())- _pu.qrope_inplace(q, rc[self.theta][0], rc[self.theta][1], H, self.hd, self.hd - P, P)+ if _pu.qo_head_major():+ q = _pu.qrope_hm(q, rc[self.theta][0], rc[self.theta][1], H, self.hd, self.hd - P, P)+ else:+ _pu.qrope_inplace(q, rc[self.theta][0], rc[self.theta][1], H, self.hd, self.hd - P, P)with tm.t("f ck: kv decompress"):klo = max(0, N - T - self.window + 1) if self.window else 0kc = kcache[klo:]@@ -285,13 +289,15 @@ class Hy4MLA:bias = torch.empty(T, (Nk + 7) // 8 * 8, dtype=torch.float16, device=cur.device)bias[:, :Nk] = torch.where(allow[:, klo:], 0.0, -30000.0).half()with tm.t("MLA core + sinks"):- o = ck_mla.fmha(q.view(T, H, self.hd), kk, vv, self.scale, self.sinks, bias, self.window)+ hm = _pu.qo_head_major()+ o = ck_mla.fmha(q if hm else q.view(T, H, self.hd), kk, vv, self.scale, self.sinks, bias, self.window,+ out=torch.empty(H, T, self.vd, dtype=torch.float16, device=cur.device).permute(1, 0, 2) if hm else None)if o is None:return Nonewith tm.t("attn proj"):with tm.t("f gate: wgate mm + sigmoid"):g = _pk.qdense_raw16(cur, self.wgate.packed, tm)- gated = _pk.gate16t(o.view(T, H * self.vd), g)+ gated = _pu.gate16_hm(o, g, H, self.vd) if hm else _pk.gate16t(o.view(T, H * self.vd), g)with tm.t("f gate: wo mm"):out = _pk.qdense_tm(gated, self.wo.packed, tm)with tm.t("f gate: post norm"):diff --git a/exllamav3/loader/prefill_kernels.py b/exllamav3/loader/prefill_kernels.pyindex 0690473..279a38c 100644--- a/exllamav3/loader/prefill_kernels.py+++ b/exllamav3/loader/prefill_kernels.py@@ -1021,6 +1021,32 @@ def mm_f32(a, b):return f32_sat(torch.mm(a, b))+def _mm16_f32_kernel(A, B, C, M, N, K, BM: tl.constexpr, BN: tl.constexpr, BK: tl.constexpr):+ rm = tl.program_id(0) * BM + tl.arange(0, BM)+ rn = tl.program_id(1) * BN + tl.arange(0, BN)+ rk = tl.arange(0, BK)+ acc = tl.zeros([BM, BN], dtype=tl.float32)+ for k in range(0, K, BK):+ a = tl.load(A + rm[:, None] * K + (k + rk)[None, :], mask=(rm[:, None] < M) & ((k + rk)[None, :] < K), other=0.0)+ b = tl.load(B + rn[None, :] * K + (k + rk)[:, None], mask=(rn[None, :] < N) & ((k + rk)[:, None] < K), other=0.0)+ acc += tl.dot(a, b)+ tl.store(C + rm[:, None] * N + rn[None, :], acc, mask=(rm[:, None] < M) & (rn[None, :] < N))+++MM16_CFG = (64, 128, 64, 4)+++def mm16_f32(a, b):+ """a [M, K] fp16 @ b [N, K] fp16 (row-major weight) -> fp32 [M, N], fp32 accumulation AND fp32 output (torch.mm rounds the product to fp16; the out_dtype=float32 variant is slow here)"""+ M, K = a.shape+ N = b.shape[0]+ BM, BN, BK, w = MM16_CFG+ c = torch.empty(M, N, dtype=torch.float32, device=a.device)+ _mm16_f32_kernel[(triton.cdiv(M, BM), triton.cdiv(N, BN))](a, b, c, M, N, K, BM=BM, BN=BN, BK=BK, num_warps=w)+ return c++def dequant_q8(packed):"""stored Q8_0 [N, K/32, 34] uint8 -> fp16 W^T [K, N] (contiguous)"""N, nb, bb = packed.shapediff --git a/exllamav3/loader/prefill_unabs.py b/exllamav3/loader/prefill_unabs.pyindex 71eeb0a..f08059a 100644--- a/exllamav3/loader/prefill_unabs.py+++ b/exllamav3/loader/prefill_unabs.py@@ -1,6 +1,7 @@"""Un-absorbed MLA prefill helpers (generic by (H, nope, rope, R, vd)): q rotary in place on the raw wq_b output, and the per-head K / V decompressionweight W [R, H * S] with slot S = 512 per head = [k_nope (nope) | pad to 256 (filled with the shared rope key) | v (vd)], so ONE GEMMlatent [N, R] @ W gives K / V as strided views (row stride H * S, head stride S) that the CK fmha reads without a copy."""+import osimport torchimport tritonimport triton.language as tl@@ -29,6 +30,69 @@ def _qrope_kernel(Q, COS, SIN, H, HD: tl.constexpr, NOPE: tl.constexpr, P: tl.cotl.store(Q + base + c[None, :], o.to(tl.float16), mask=hm)+def _qrope_hm_kernel(Q, OUT, COS, SIN, T, H, HD: tl.constexpr, NOPE: tl.constexpr, P: tl.constexpr, HB: tl.constexpr):+ """_qrope_kernel writing HEAD-MAJOR into OUT [H, T, HD] (same values, same rounding points; no extra pass)"""+ t = tl.program_id(0)+ h = tl.program_id(1) * HB + tl.arange(0, HB)+ c = tl.arange(0, HD)+ hm = (h < H)[:, None]+ base = (t.to(tl.int64) * H + h)[:, None] * HD+ x = tl.load(Q + base + c[None, :], mask=hm, other=0.0).to(tl.float32)+ x = tl.where(x != x, 0.0, tl.minimum(tl.maximum(x, -65504.0), 65504.0))+ xp = tl.load(Q + base + (c ^ 1)[None, :], mask=hm, other=0.0).to(tl.float32)+ xp = tl.where(xp != xp, 0.0, tl.minimum(tl.maximum(xp, -65504.0), 65504.0))+ pe = c >= NOPE+ j = tl.where(pe, (c - NOPE) // 2, 0)+ cs = tl.load(COS + t * (P // 2) + j)+ sn = tl.load(SIN + t * (P // 2) + j)+ sg = tl.where((c % 2) == 0, -sn, sn)+ r = tl.minimum(tl.maximum(x * cs[None, :] + xp * sg[None, :], -65504.0), 65504.0)+ o = tl.where(pe[None, :], r, x)+ ob = (h.to(tl.int64)[:, None] * T + t) * HD+ tl.store(OUT + ob + c[None, :], o.to(tl.float16), mask=hm)+++def qo_head_major():+ """HY4_PF_QO_HM=1 (read live, default off): the CK fmha reads Q and writes O head-major ([H, T, hd], seen as a [T, H, hd] view): a tile of rows is one contiguous+ run instead of a 32 KB-stride gather (sliding-window layer, 8K rows: 22 -> 13.7 ms); the rope kernel writes Q head-major and the gate kernel reads O head-major,+ so no extra pass"""+ return os.environ.get("HY4_PF_QO_HM", "0") == "1"+++def qrope_hm(q, cos, sin, H, hd, nope, P):+ """q [T, H * hd] raw fp16 -> [T, H, hd] VIEW of a head-major [H, T, hd] buffer, rotary applied (qrope_inplace maths)"""+ T = q.shape[0]+ HB = 8+ out = torch.empty(H, T, hd, dtype=torch.float16, device=q.device)+ _qrope_hm_kernel[(T, triton.cdiv(H, HB))](q, out, cos, sin, T, H, HD=hd, NOPE=nope, P=P, HB=HB, num_warps=4)+ return out.permute(1, 0, 2)+++def _gate_hm_kernel(O, G, OUT, T, n, H: tl.constexpr, VD: tl.constexpr, BLK: tl.constexpr):+ """OUT [T, H * VD] = O (head-major [H, T, VD]) * sigmoid(G [T, H * VD]); the maths of prefill_kernels._gate_ew_kernel"""+ i = tl.program_id(0).to(tl.int64) * BLK + tl.arange(0, BLK)+ m = i < n+ g = tl.load(G + i, mask=m, other=0.0).to(tl.float32)+ g = tl.where(g != g, 0.0, tl.minimum(tl.maximum(g, -65504.0), 65504.0))+ t = i // (H * VD)+ cc = i % (H * VD)+ oi = (cc // VD) * T * VD + t * VD + cc % VD+ kv = tl.load(O + oi, mask=m, other=0.0).to(tl.float32)+ o = kv * (1.0 / (1.0 + tl.exp(-g)))+ tl.store(OUT + i, tl.minimum(tl.maximum(o, -65504.0), 65504.0).to(tl.float16), mask=m)+++def gate16_hm(o, g, H, VD):+ """o [T, H, VD] view of a head-major buffer, g [T, H * VD] raw gate GEMM output -> gated [T, H * VD] fp16"""+ T = o.shape[0]+ out = torch.empty(T, H * VD, dtype=torch.float16, device=o.device)+ n = out.numel()+ _gate_hm_kernel[(triton.cdiv(n, 4096),)](o, g, out, T, n, H=H, VD=VD, BLK=4096, num_warps=4)+ return out++def qrope_inplace(q, cos, sin, H, hd, nope, P):T = q.shape[0]HB = 8@@ -36,13 +100,23 @@ def qrope_inplace(q, cos, sin, H, hd, nope, P):return q+def kv_head_major():+ """HY4_PF_KV_HM=1 (read live, default off): K / V decompressed head-major ([H, N, slot], one batched GEMM) instead of [N, H, slot]: the CK fmha then reads a+ tile of keys as one contiguous run (the [N, H, 512] slab has a 64 KB row stride: channel camping, 33 -> 22 ms per sliding-window layer at 8K, dense 180 -> 104 ms);+ same values (bit-equal outputs), same footprint (the weight is kept in ONE layout, chosen when it is built)"""+ return os.environ.get("HY4_PF_KV_HM", "0") == "1"++def kv_weight(wk16, wv16, slot=512, kpad=256):- """wk16 [H, R, nope] fp16, wv16 [H, vd, R] fp16 -> W [R, H * slot] fp16: head h columns [0:nope] = wk16[h], [kpad:kpad + vd] = wv16[h].T, rest 0"""+ """wk16 [H, R, nope] fp16, wv16 [H, vd, R] fp16 -> W [R, H * slot] fp16: head h columns [0:nope] = wk16[h], [kpad:kpad + vd] = wv16[h].T, rest 0+ (HY4_PF_KV_HM=1: W [H, R, slot], the batched-GEMM layout of kv_decompress)"""H, R, nope = wk16.shapevd = wv16.shape[1]W = torch.zeros(R, H, slot, dtype=torch.float16, device=wk16.device)W[:, :, :nope] = wk16.permute(1, 0, 2)W[:, :, kpad:kpad + vd] = wv16.permute(2, 0, 1)+ if kv_head_major():+ return W.permute(1, 0, 2).contiguous()return W.reshape(R, H * slot)@@ -51,6 +125,10 @@ def kv_decompress(lat16, pe16, W, H, hd=256, slot=512):the rope key is broadcast over heads into the pad columns of K"""N = lat16.shape[0]P = pe16.shape[1]+ if W.dim() == 3: # head-major (HY4_PF_KV_HM): slab [H, N, slot]; K / V are [N, H, hd] views with row stride slot, head stride N * slot+ slab = torch.bmm(lat16.unsqueeze(0).expand(H, N, lat16.shape[1]), W)+ slab[:, :, hd - P:hd] = pe16[None]+ return slab[:, :, :hd].permute(1, 0, 2), slab[:, :, hd:hd + hd].permute(1, 0, 2)slab = torch.mm(lat16, W).view(N, H, slot)slab[:, :, hd - P:hd] = pe16[:, None, :]return slab[:, :, :hd], slab[:, :, hd:hd + hd]diff --git a/tools/hy4/serve.py b/tools/hy4/serve.pyindex b5f86b1..6cd3a56 100644--- a/tools/hy4/serve.py+++ b/tools/hy4/serve.py@@ -56,6 +56,7 @@ SHIPPED_ENV = {"HY4_PF_SPARSE": "1", "HY4_PF_SPARSE_MINN": "2048", # sparse prefill attention (HIP kernel via SP_SO, Triton fallback) from 2048 keys (first measured from 16K keys): 33K prefill 60.6 -> 42 s, 128K flat ~790 tok/s; NLL 32K 4.5226 vs dense 4.5231 (nulls 4.511-4.515); below 16K dense CK (KL at 4096 with sparse 0.1089 vs nulls 0.0988-0.1054)"HY4_ENGRAM_NPHASH": "1", "HY4_ENGRAM_NATIVE_IO": "1", "HY4_ENGRAM_PF_WORKERS": "1", "HY4_PF_G_SWIGLU": "1", "HY4_PF_G_ADD": "1", "HY4_PF_MM_FINE": "1", # prefill levers (box A/B 20/11 pf2_A / pf2_B: prefill +11 / +7.6 / +6.5 % at 8K / 32K / 64K, passkey 3/3, KL 0.108 vs noise nulls 0.103-0.108)"HY4_MLA_HB": "1", "HY4_BG_DOT": "1", "HY4_HEAD_DOT": "1", "HY4_RG_F16": "1", # decode levers (box A/B 20/11, 256 tok x2: verify round -7 % at 4K, -4 % at 32K, plain flat; qual6 KL 0.94 x noise null)+ "HY4_PF_KV_HM": "1", "HY4_PF_QO_HM": "1", "HY4_PF_HC2": "1", "HY4_PF_ROUTER16": "1", # prefill set 3 (1.9.1): head-major CK attention operands, lazy layer residual (3 stream passes per layer), fp16 router logits of prefill rows (only on the HY4_REF_FUSED=0 router path)"HY4_PF_WOT": "0", "HY4_MOE_HIP": "2", "HY4_PF_CK": "1", "HY4_PF_FUSE": "1", # prefill set 2: shared gm_ext WMMA experts (HY4_GM_EXT), CK MLA core (EXL3_CKMLA_SO), one-pass hc / norm / indexer kernels}