moe_mxfp4: the small-M form at GLM's TP4 slices too

At TP4 the launcher fell back to the expert-major form for every decode step. The small-M form
now takes gate_up from 9 to 384 routed rows (past one token's 8, where it reads 5 % slower) and
down up to 384 at the K256 x4 tiles. perfmx --perfmx-tp 4, cold, gfx1201, output byte-identical:
gate_up 3 to 18 % faster from 2 to 48 tokens, down 37 % at one token and 4 % at 48.

Served at TP4 with --vision-tower-placement ram, BetterBench against the same tree without it:
decode 52.3 -> 55.7 tok/s, 1/2/3/4 conversations 49.8/73.5/85.6/91.1 -> 52.7/76.5/90.0/96.4,
prefill unchanged. Temp-0 replies identical, needles 8/8 at 4 x 119k.
This commit is contained in:
AnimusNull authored and AnimusNull committed 2026-11-05 14:18:21 +00:00
1 parent 220cb3f12c
commit b954585f9f
2 files changed
+18 -9

No files matched your search

+14 -7
View File
@@ -1161,14 +1161,19 @@ int body(const RadArgs* a, RadStream stream) {
return bm == 64 ? MX_P64(64, 64, 256, 1, false) : MX_P64(32, 64, 256, 1, false);
#undef MX_P64
}
/* The small-M form at GLM's TP8 slices, ahead of the expert-major band: gate_up up to 384
* routed rows, down up to 32, where it stops gaining (at 5 to 8 tokens it reads 3 to 5 %
* slower than the staged form). At those slices on gfx1201 (perfmx, cold) it is 6 to 16 %
* faster than the expert-major form for gate_up from 1 to 48 tokens, and 4 to 23 % for down
* from 1 to 4. */
/* The small-M form at GLM's slices, ahead of the expert-major band (perfmx, cold, its output
* byte-identical to the expert-major form's). At the TP8 slices: gate_up up to 384 routed rows,
* down up to 32, where it stops gaining (at 5 to 8 tokens it reads 3 to 5 % slower than the
* staged form); on gfx1201 it is 6 to 16 % faster than the expert-major form for gate_up from
* 1 to 48 tokens, and 4 to 23 % for down from 1 to 4. At the TP4 slices (--perfmx-tp 4):
* gate_up from 2 to 48 tokens, 3 to 18 % faster (at one token it reads 5 % slower), and down
* up to 48 tokens at the K256 x4 tiles, 37 % faster at one token and 4 % at 48. */
const bool tp8_small = tp8 && m.T <= (m.sorted_a ? 32 : 384);
const bool tp4 = glm_prefill && !tp8;
const bool tp4_small = tp4 && m.T <= 384 && (m.sorted_a || m.T > m.topk);
if (g_mx_small_pin == 1 || g_mx_small_pin == 3
? glm_prefill && m.T <= 384
: g_mx_small_pin != 2 && tp8 && m.T <= (m.K <= 256 ? 32 : 384)) {
: g_mx_small_pin != 2 && (tp8_small || tp4_small)) {
const long rows = std::min<long>(m.experts, m.T) + 1;
#define MX_SMALL(SK, CT) \
R4D_EMIT(stream, (moe_mxfp4_small_kernel<SK, CT>), \
@@ -1176,7 +1181,9 @@ int body(const RadArgs* a, RadStream stream) {
(const uint8_t*)aq->data, (const float*)as->data, w[0]->data, s[0]->data, \
w[1]->data, s[1]->data, (const int*)sorted->data, (const int*)off->data, \
(uint16_t*)y->data, m)
return m.K <= 256 || g_mx_small_pin == 3 ? MX_SMALL(256, 4) : MX_SMALL(512, 1);
return m.K <= 256 || g_mx_small_pin == 3 || (g_mx_small_pin == 0 && tp4 && m.sorted_a)
? MX_SMALL(256, 4)
: MX_SMALL(512, 1);
#undef MX_SMALL
}
/* The expert-major form up to a routed-row bound per projection (token rows: gate_up, sorted