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.

Fused MoE: add the K4S6 and K5S6 shapes

YanissAmz18462aa0e905
diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_fused.cu b/exllamav3/exllamav3_ext/quant/exl3_moe_fused.cu
index 2ab3d9c..a896327 100644
--- a/exllamav3/exllamav3_ext/quant/exl3_moe_fused.cu
+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_fused.cu
@@ -102,7 +102,7 @@ template <class S> void mf_launch
}
} // namespace
-#define MF_SHAPES(X) X(mf::QwenShape) X(mf::SmallTestShape) X(mf::SmallK3Shape) X(mf::QwenK3S4) X(mf::QwenK3S5) X(mf::QwenK4S4) X(mf::QwenK4S5) X(mf::SmallK3S4) X(mf::SmallK3S5) X(mf::SmallK4S4) X(mf::SmallK4S5) X(mf::QwenK6S6) X(mf::SmallK6S6)
+#define MF_SHAPES(X) X(mf::QwenShape) X(mf::SmallTestShape) X(mf::SmallK3Shape) X(mf::QwenK3S4) X(mf::QwenK3S5) X(mf::QwenK4S4) X(mf::QwenK4S5) X(mf::SmallK3S4) X(mf::SmallK3S5) X(mf::SmallK4S4) X(mf::SmallK4S5) X(mf::QwenK6S6) X(mf::SmallK6S6) X(mf::QwenK4S6) X(mf::QwenK5S6) X(mf::SmallK4S6) X(mf::SmallK5S6)
bool exl3_moe_fused_supported(int64_t D, int64_t H, int64_t LR, int64_t NEXP, int64_t TOPK, int64_t INTER, int64_t RB, int64_t SB)
{
diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu b/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu
index 158c6c3..824e4a5 100644
--- a/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu
+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu
@@ -103,6 +103,7 @@ void mf9_half(at::Tensor& x, const at::Tensor& fn, const at::Tensor& fn_scale, c
#define XW(SH) if (Match7<mf::Wide<SH>>::eq(D, H, LR, NEXP, TOPK, INTER, RB, SB)) { L7(mf::Wide<SH>, false, 4, 1); return; }
XW(mf::QwenShape) XW(mf::SmallTestShape) XW(mf::QwenK3S4) XW(mf::QwenK3S5) XW(mf::QwenK4S4) XW(mf::QwenK4S5)
XW(mf::SmallK3S4) XW(mf::SmallK3S5) XW(mf::SmallK4S4) XW(mf::SmallK4S5)
+ XW(mf::QwenK4S6) XW(mf::QwenK5S6) XW(mf::SmallK4S6) XW(mf::SmallK5S6)
#undef XW
TORCH_CHECK(false, "mf9: shape not instantiated for wide launches");
}
@@ -126,6 +127,7 @@ void mf9_half(at::Tensor& x, const at::Tensor& fn, const at::Tensor& fn_scale, c
switch ((variant >> 8) & 3) { case 1: L7A(mf::QwenK4S5, true, 2, 1, 1); break; case 2: L7A(mf::QwenK4S5, true, 2, 1, 2); break; default: L7A(mf::QwenK4S5, true, 2, 1, 3); } return; }
X9D(mf::QwenK3S4) X9D(mf::QwenK3S5) X9D(mf::QwenK4S4) X9D(mf::QwenK4S5)
X9D(mf::QwenK6S6) X9D(mf::SmallK6S6)
+ X9D(mf::QwenK4S6) X9D(mf::QwenK5S6) X9D(mf::SmallK4S6) X9D(mf::SmallK5S6)
X9D(mf::SmallK3S4) X9D(mf::SmallK3S5) X9D(mf::SmallK4S4) X9D(mf::SmallK4S5)
#undef X9D
TORCH_CHECK(false, "mf9: shape not instantiated");
diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_fused_idx.h b/exllamav3/exllamav3_ext/quant/exl3_moe_fused_idx.h
index d2280df..9d7f558 100644
--- a/exllamav3/exllamav3_ext/quant/exl3_moe_fused_idx.h
+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_fused_idx.h
@@ -49,6 +49,11 @@ struct SmallK4S4 { static constexpr int D = 256, H = 4, LR = 32, NEXP = 64, TOPK
struct QwenK6S6 { static constexpr int D = 2560, H = 4, LR = 320, NEXP = 512, TOPK = 10, INTER = 640, RB = 6, SB = 6; }; // the MTP drafter layer of the public pack (routed K6, shared K6)
struct SmallK6S6 { static constexpr int D = 256, H = 4, LR = 32, NEXP = 64, TOPK = 4, INTER = 128, RB = 6, SB = 6; };
struct SmallK4S5 { static constexpr int D = 256, H = 4, LR = 32, NEXP = 64, TOPK = 4, INTER = 128, RB = 4, SB = 5; };
+// 4 bpw and 5 bpw routed experts with a K6 shared expert (the layout of the public 4.05 bpw pack; K5S6 is its 5 bpw sibling), and small twins
+struct QwenK4S6 { static constexpr int D = 2560, H = 4, LR = 320, NEXP = 512, TOPK = 10, INTER = 640, RB = 4, SB = 6; };
+struct QwenK5S6 { static constexpr int D = 2560, H = 4, LR = 320, NEXP = 512, TOPK = 10, INTER = 640, RB = 5, SB = 6; };
+struct SmallK4S6 { static constexpr int D = 256, H = 4, LR = 32, NEXP = 64, TOPK = 4, INTER = 128, RB = 4, SB = 6; };
+struct SmallK5S6 { static constexpr int D = 256, H = 4, LR = 32, NEXP = 64, TOPK = 4, INTER = 128, RB = 5, SB = 6; };
template <class S>
struct Dm