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

+1
View File
@@ -53,6 +53,7 @@ The table lists a selection; `r4d_rows.cpp` and `r4d.h` hold the full set.
| `gemm_w2a8_nt` | 2-bit weight against int8 activation: the DFlash2 draft head |
| `gemm_mxfp4a8_nt_m64` | OCP-MXFP4 weight, fp8 activation, skinny |
| `gemm_mxfp4a8_decode` | the same operands for the decode band (M ≤ 128): split-K across workgroups with a last-arriver reduction, the partial in the op's scratch |
| `gemm_mxfp4a8_decode_shortk` | the decode kernel at 33..64 rows of a wide, short weight (N ≥ 8192, K ≤ 2560), above `gemm_mxfp4a8_gemv_wide`, which loses there |
| `gemm_mxfp4a8_tiled` | the prefill sibling: the activation re-tiled into fragment order in the op's scratch and read straight into registers, the weight unpacked once per K slab for a 256-row block |
| `attn_decode_h128_gqa4_fp8kv` / `..._bf16kv` | head_dim 128, 4 queries per KV head, sliding window: a block-diffusion drafter's geometry. Decode only; there is no prefill row at this geometry |
| `rowtopk_bf16` / `rowtopk_bf16_chunks` | exact per-row top-K over a bf16 matrix, two-stage |