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.

K-quant grouped prefill: fit gfx11 LDS, default off on ROCm (no gain on the iGPU)

YanissAmz36af80ad2f67
diff --git a/exllamav3/modules/block_sparse_mlp.py b/exllamav3/modules/block_sparse_mlp.py
index 83f3bd8..7e72441 100644
--- a/exllamav3/modules/block_sparse_mlp.py
+++ b/exllamav3/modules/block_sparse_mlp.py
@@ -1917,7 +1917,8 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):
if fmts is None or not (use_kq or fmts == ("iq4_xs", "iq4_xs")) or self.act_limit or \
self.activation_fn not in ("silu", None):
return None
- if use_kq and os.environ.get("MCPM_FQ_PF_GROUPED_KQ", "1") == "0":
+ # CUDA: 2.4-4.2x on the MoE layer. ROCm (iGPU): 0.9-1.1x (scratch traffic is bound by LPDDR bandwidth), so off by default there
+ if use_kq and os.environ.get("MCPM_FQ_PF_GROUPED_KQ", "0" if torch.version.hip else "1") == "0":
return None
if (self.num_local_experts or self.num_experts) != self.num_experts:
return None
diff --git a/exllamav3/modules/fq_moe_prefill_kq.py b/exllamav3/modules/fq_moe_prefill_kq.py
index 73291fb..36ec5c7 100644
--- a/exllamav3/modules/fq_moe_prefill_kq.py
+++ b/exllamav3/modules/fq_moe_prefill_kq.py
@@ -237,7 +237,7 @@ def moe_kq_prefill(y_sorted, gu_ptrs, dn_ptrs, a, dn, tile_e, tile_r0, offs, wro
_dq_kq[(triton.cdiv(I, BNd), K // 256, ec)](gu_ptrs, wu, E + e0, I, K, FMT=fmt_gu, BN=BNd, num_warps=4)
_dq_kq[(triton.cdiv(K, BNd), I // 256, ec)](dn_ptrs, wd, e0, K, I, FMT=fmt_dn, BN=BNd, num_warps=4)
T = tile_e.shape[0]
- BN, BK, nw, ns = 128, 64, 8, 3
+ BN, BK, nw, ns = 128, 64, 8, (2 if torch.version.hip else 3) # 64 KiB LDS on gfx11
_gmm_f16[(triton.cdiv(I, BN), T)](y_sorted, wg, wu, a, tile_e, tile_r0, offs, offs, I, K, y_sorted.stride(0),
a.stride(0), e0, e0 + ec, SWIGLU=True, SCALE_ROWS=False,
BM=bm, BN=BN, BK=BK, num_warps=nw, num_stages=ns)