moe_gemm_q_mod4: the quantised grouped GEMM over four classes of experts

moe_gemm_q over four tables instead of two: expert e is entry e / 4 of class
e % 4. A separate op, because the declaration divides a table op's weights
over its table operands by count. The arguments are repacked to fit four
classes in 256 bytes; moe_gemm_q's arithmetic is unchanged. Where weights
do not divide evenly over the tables, the first tables take one more each
(510 experts: 128/128/127/127). libref and libavx serve the op.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-10-05 12:52:44 +02:00
1 parent bfae23e368
commit bc2e6ba614
17 files changed
+634 -137

No files matched your search

+11
View File
@@ -250,6 +250,17 @@ std::vector<Case> build_cases() {
add("moe_gemm_q", { HI("M", 9), HI("N", 64), HI("K", 256), HI("K_odd", 128),
HI("n_expert", 8), HI("top_k", 2), HI("group", 128),
HS("a_order", "sorted"), HS("dtype", "w8a8") });
/* Four classes at three widths -- a four-rank slice of a five-block expert is two blocks
* of one class and one of each other -- over ten experts, so classes 2 and 3 hold one
* fewer than 0 and 1: the gate/up pair and the down projection. */
add("moe_gemm_q_mod4", { HI("M", 9), HI("N", 128), HI("K", 128), HI("N_1", 256),
HI("N_2", 128), HI("N_3", 128), HI("parts", 2),
HI("n_expert", 10), HI("top_k", 2), HI("group", 128),
HS("a_order", "token"), HS("dtype", "w8a8") });
add("moe_gemm_q_mod4", { HI("M", 9), HI("N", 64), HI("K", 128), HI("K_1", 128),
HI("K_2", 256), HI("K_3", 128), HI("n_expert", 10),
HI("top_k", 2), HI("group", 128), HS("a_order", "sorted"),
HS("dtype", "w8a8") });
}
add("moe_scatter", { HI("M", 9), HI("n_expert", 8), HI("top_k", 2), HI("expert_base", 0) });