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: fp16 router select option (HY4_PF_RK=1, slower than the torch select, off), fused saturating fp16 cast with reuse of the last fp32 input, post-attention norm through the fused rms kernel; KL gate at 4096 for the CK path: 0.088 +- 0.008 vs noise null 0.110 +- 0.011
YanissAmzba7c5548b46e
diff --git a/exllamav3/loader/prefill_kernels.py b/exllamav3/loader/prefill_kernels.pyindex 315a42c..4e547d4 100644--- a/exllamav3/loader/prefill_kernels.py+++ b/exllamav3/loader/prefill_kernels.py@@ -428,9 +428,32 @@ def pf_indexer(obj, tm=None):F16MAX = 65504.0+def _sat_half_kernel(X, O, n, BLK: tl.constexpr):+ i = tl.program_id(0).to(tl.int64) * BLK + tl.arange(0, BLK)+ m = i < n+ x = tl.load(X + i, mask=m, other=0.0)+ tl.store(O + i, tl.minimum(tl.maximum(x, -65504.0), 65504.0).to(tl.float16), mask=m)+++_F16_MEMO = [None, None] # (source tensor, converted) and its key: the fp32 stream of one layer feeds several GEMMs (wq_a, wkv_a, wgate / router, rdown, shared gate + up)++def to_f16(x):- """saturating fp32 / fp16 -> fp16 (hidden streams keep the clamp)"""- return x.float().clamp(-F16MAX, F16MAX).half() if x.dtype != torch.float16 else x+ """saturating fp32 / fp16 -> fp16 (hidden streams keep the clamp): one fused pass, and the conversion of the last fp32 input is reused while that tensor is+ unchanged (same storage, same in-place version)"""+ if x.dtype == torch.float16:+ return x+ if x.dtype != torch.float32 or not x.is_cuda or not x.is_contiguous() or x.numel() < (1 << 20):+ return x.float().clamp(-F16MAX, F16MAX).half()+ key = (x.data_ptr(), x.shape, x._version)+ if _F16_MEMO[0] is not None and _F16_MEMO[1] == key and _F16_MEMO[0][0] is x:+ return _F16_MEMO[0][1]+ o = torch.empty(x.shape, dtype=torch.float16, device=x.device)+ n = x.numel()+ _sat_half_kernel[(triton.cdiv(n, 4096),)](x, o, n, BLK=4096, num_warps=4)+ _F16_MEMO[0], _F16_MEMO[1] = (x, o), key+ return oMOE_NF = None # tests: force the grid order (None = env HY4_MOE_NFIRST)