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
MoE: grouped decode and WMMA prefill routes for K5 and K6 routed experts
YanissAmza02c93ce04aa
diff --git a/exllamav3/exllamav3_ext/quant/exl3_gemv.cu b/exllamav3/exllamav3_ext/quant/exl3_gemv.cuindex 03ac583..7dc6b57 100644--- a/exllamav3/exllamav3_ext/quant/exl3_gemv.cu+++ b/exllamav3/exllamav3_ext/quant/exl3_gemv.cu@@ -748,13 +748,16 @@ static void launch_moe_grouped_kint size_k, int size_n, int experts, int assignments, hipStream_t stream){- // k2 = 2 * K: 4 -> K2, 5 -> K2.5, 6 -> K3, 8 -> K4+ // k2 = 2 * K: 4 -> K2, 5 -> K2.5, 6 -> K3, 8 -> K4, 10 -> K5, 12 -> K6switch (k2){case 4: launch_moe_grouped<2, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;case 5: launch_moe_grouped<2, true, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;case 6: launch_moe_grouped<3, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;- default: launch_moe_grouped<4, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;+ case 8: launch_moe_grouped<4, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;+ case 10: launch_moe_grouped<5, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;+ case 12: launch_moe_grouped<6, false, FP32, TWO>(A, selected, dd, t0, t1, C, size_k, size_n, experts, assignments, stream); break;+ default: TORCH_CHECK(false, "exl3_moe_gfx12_k3: unsupported expert bitrate (K*2 = ", k2, ")");}}@@ -808,8 +811,8 @@ void exl3_moe_gfx12_k3TORCH_CHECK(exl3_gemv_wmma_family(device) != 0,"exl3_moe_gfx12_k3 requires a WMMA GEMV arch (gfx1200/1201 or gfx1150/1151/1152)");const int k2 = (int) (2.0 * K + 0.25);- TORCH_CHECK(k2 == 4 || k2 == 5 || k2 == 6 || k2 == 8,- "exl3_moe_gfx12_k3 expert bitrate K must be 2, 2.5, 3 or 4");+ TORCH_CHECK(k2 == 4 || k2 == 5 || k2 == 6 || k2 == 8 || k2 == 10 || k2 == 12,+ "exl3_moe_gfx12_k3 expert bitrate K must be 2, 2.5, 3, 4, 5 or 6");TORCH_CHECK(A.is_cuda() && A.is_contiguous() && A.dtype() == at::kHalf &&A.dim() == 2 && A.size(1) % 128 == 0 &&diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cu b/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cuindex d25f4d3..d8dd3b0 100644--- a/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cu+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cu@@ -1521,6 +1521,8 @@ void launch_gemm_cbcase 6: MPW2_K(3, false)case 7: MPW2_K(3, true)case 8: MPW2_K(4, false)+ case 10: MPW2_K(5, false)+ case 12: MPW2_K(6, false)default: TORCH_CHECK(false, "exl3_moe_prefill_wmma: unsupported K ", K);}#undef MPW2_D@@ -1545,6 +1547,8 @@ void launch_gemm_cbcase 6: MPW_K(3, false)case 7: MPW_K(3, true)case 8: MPW_K(4, false)+ case 10: MPW_K(5, false)+ case 12: MPW_K(6, false)default: TORCH_CHECK(false, "exl3_moe_prefill_wmma: unsupported K ", K);}#undef MPW_Kdiff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cuh b/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cuhindex fe03c00..e1ba779 100644--- a/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cuh+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_prefill.cuh@@ -5,7 +5,7 @@// Grouped EXL3 MoE prefill for gfx11.5 (RDNA3.5 WMMA): tokens are sorted by expert and every// projection runs as ONE launch over all experts. Trellis tiles are decoded in the GEMM (to LDS),// no fp16 weight materialization. Gate+up share a launch. Any hidden / intermediate width that-// is a multiple of 128, any top-k, K = 2, 2.5, 3, 4, both codebooks (mcg / mul1).+// is a multiple of 128, any top-k, K = 2, 2.5, 3, 4, 5, 6, both codebooks (mcg / mul1).void exl3_moe_prefill_wmma(const at::Tensor& A, // fp16 [rows, H]diff --git a/exllamav3/modules/block_sparse_mlp.py b/exllamav3/modules/block_sparse_mlp.pyindex 0ca8800..80dd081 100644--- a/exllamav3/modules/block_sparse_mlp.py+++ b/exllamav3/modules/block_sparse_mlp.py@@ -781,7 +781,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):)# Grouped WMMA prefill (gfx11.5, exl3_moe_prefill.cu): any expert shape with 128-aligned- # widths, any top-k, K 2 / 2.5 / 3 / 4, either codebook, and a clamped SwiGLU limit+ # widths, any top-k, K 2 / 2.5 / 3 / 4 / 5 / 6, either codebook, and a clamped SwiGLU limit# (checked once the pointer tables exist below). Full expert layers only;# EXL3_MOE_WMMA=0 disables it per forward.hip_wmma_device = False@@ -832,7 +832,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):# bitrate and gate/up/down share it (the allocator assigns per layer).ks = {multi.K for multi in (self.multi_gate, self.multi_up, self.multi_down)}self.support_hip_grouped = self.support_hip_grouped and len(ks) == 1 and all(- multi.K in (2, 2.5, 3, 4) and multi.mul1 and not multi.mcg+ multi.K in (2, 2.5, 3, 4, 5, 6) and multi.mul1 and not multi.mcgfor multi in (self.multi_gate, self.multi_up, self.multi_down))# The prefill kernel (exl3_moe_gfx12_k3_prefill) is still Qwen3.8-only: K=3, top-10 and@@ -880,7 +880,7 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):# Ipad, 8*H) for this model's shapes; a TORCH_CHECK in the kernel catches it if a# future shape needs more.self.support_hip_wmma = self.support_hip_wmma and all(- multi.K in (2, 2.5, 3, 4) and (multi.mul1 != multi.mcg)+ multi.K in (2, 2.5, 3, 4, 5, 6) and (multi.mul1 != multi.mcg)for multi in (self.multi_gate, self.multi_up, self.multi_down)) and self.multi_gate.K == self.multi_up.K# Codebook: mpw_gemm is templated on it and takes one flag for all three projections