gemm_mxfp4a8_decode_shortk: the decode kernel at 33..64 rows of a wide, short weight, above gemv_wide

gemv_wide's blocks hold three or four row tiles over the whole K, so on a short K the cross-wave
reduction of a block outweighs its WMMAs, and on a wide N there are many such blocks. Swept over 24
per-rank shapes (Qwen3.8 and TranslateGemma at TP1/2/4/8, 1B/4B/8B-class dense) at 24..64 rows, each
row timed alone: gemv_wide is at least upstream's decode kernel everywhere except N >= 8192 with
K <= 2560 past 32 rows, where it lost by 7..30 % (19456 x 2560 at 64 rows 131.8 us against upstream's
104.5; 16384 x 2048 92.8 / 76.1; 9728 x 2560 74.1 / 67.4). This decode kernel takes that corner:
93.3, 68.6 and 52.5 us. A row of its own (same entry, scratch hook and tunables as the decode row,
priority 59, constraints M 33..64, N 8192..36864, K <= 2560) rather than a rule in the gemv entry,
so the planner's choice stays a table lookup. Narrower N stays with gemv_wide (5120 x 2176 at 40
rows 39.2 against 52.8), as does every shape of the models we serve. r4d_selftest: five numeric
cases over the corner, both activation grids and parts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-24 11:09:03 +02:00
1 parent d4eacec5c6
commit f3429d8c13
4 files changed
+38 -1

No files matched your search

+7
View File
@@ -26921,6 +26921,13 @@ static void device_phase(const Plugin& pl) {
mxfp4a8_numeric(pl, "gemm_mxfp4a8_gemv_wide", 64, 10288, 640, 0, false);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_gemv_wide", 33, 16, 128, 0, true);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_gemv_wide", 24, 34816, 5120, 0, true, {}, 17408);
/* decode_shortk: the decode kernel over its corner, both activation grids, a tile partly
* live, and parts. */
mxfp4a8_numeric(pl, "gemm_mxfp4a8_decode_shortk", 33, 16384, 2048, 0, true);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_decode_shortk", 48, 9728, 2560, 0, false);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_decode_shortk", 64, 19456, 2560, 0, true);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_decode_shortk", 50, 8192, 576, 0, true);
mxfp4a8_numeric(pl, "gemm_mxfp4a8_decode_shortk", 40, 19456, 2560, 0, true, {}, 9728);
mxfp4a8_m_invariant(pl, "gemm_mxfp4a8_gemv", 5120, 5120, true);
mxfp4a8_m_invariant(pl, "gemm_mxfp4a8_gemv", 1088, 576, true);
mxfp4a8_m_invariant(pl, "gemm_mxfp4a8_gemv", 1056, 576, false);