libr4d: gemm_mxfp4a8_gemv, the MXFP4 x fp8 GEMM for one to eight rows

One stream's decode (M = 1 + the draft depth) is a pure weight stream; the decode row stages the
weight through LDS and leaves narrow projections at a third to two thirds of DRAM bandwidth. The new
row (priority 58; M <= 8, K % 64, N % 16; the same packed weight bytes as every MXFP4 row) keeps the
weight in registers: WMMA from register fragments when K % 128 == 0, v_dot4 otherwise. The form and
the wave count per block depend on K alone, so a row's output bits do not depend on M (a verify
step's first row equals the plain decode of it). The scale and reference planes must be 4-byte
aligned.

Selftest: every reachable instantiation (both forms, both activation grids, M = 1..8, tile counts
divisible by 4, by 2 only and odd, parts), the output prefilled with NaN, an odd column stride, and
the first row's bits against M for gemv and decode. --perfmx times the MXFP4 rows at one shape.

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 d6957e88a1
commit 75b4d0baa7
5 files changed
+458 -7

No files matched your search

+3
View File
@@ -49,6 +49,8 @@ enum {
R4D_PRIO_GEMM_SKINNY = 50,
/* The MXFP4 decode row outranks the MXFP4 skinny row, whose band it shares up to N = 36864. */
R4D_PRIO_GEMM_MXDEC = 55,
/* The MXFP4 gemv row (one to eight rows) outranks the decode row, whose band it shares there. */
R4D_PRIO_GEMM_MXGEMV = 58,
/* The skinny m64 row has no upper bound on M, so the tiled bf16 row (M > 64 only) must outrank
* it, and stays below m16, whose band it never enters. */
R4D_PRIO_GEMM_BF16_TILED = 55,
@@ -450,6 +452,7 @@ int r4d_rad_gemm_mxfp4a8_tiled(const RadArgs*, RadStream);
int64_t r4d_rad_gemm_mxfp4a8_tiled_scratch(const RadArgs*);
int r4d_rad_gemm_mxfp4a8_decode(const RadArgs*, RadStream);
int64_t r4d_rad_gemm_mxfp4a8_decode_scratch(const RadArgs*);
int r4d_rad_gemm_mxfp4a8_gemv(const RadArgs*, RadStream);
int r4d_rad_dequant_w4 (const RadArgs*, RadStream);
int r4d_rad_rowtopk (const RadArgs*, RadStream);
int64_t r4d_rad_rowtopk_scratch(const RadArgs*);