libxe2: bf16 GEMV at 9-16 rows on DPAS, the weight read once

At 9 <= M <= 16 the bf16 skinny GEMM (gemm_nt, logits_gemm) fell to the SIMT kernel's one column a
sub-group, 6-8x the 8-row DPAS kernel's time on the same weight. The ESIMD kernel gains RC = 16: two
8-row DPAS on each transposed weight tile, rows past M clamped by the 2D load and not stored.

MiniCPM5-2B bf16 on the Arc Pro B65 (rad-kbench --bench, cold weights, M = 16): gate_up
712 -> 104 us, down 465 -> 61, qkv 148 -> 29, o 145 -> 25. Twelve concurrent 256-token streams:
198 -> 654 tok/s aggregate. rad-kbench gemm_nt + logits_gemm: MiniCPM5 360/360, fixture 686/686.
XE2_GEMV_SIMT=1 keeps the SIMT form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-11-08 01:38:14 +01:00
1 parent 3582900903
commit 2f1fdd4d11
2 files changed
+32 -11

No files matched your search

+11 -1
View File
@@ -6,7 +6,8 @@
* against the same 8 columns of the activation, and keeps a partial sum a column; the sub-group then
* reduces and lane 0 stores. Measured on the B65 at a 1.8k context: one column 9.1 ms a step of
* gemm_nt, two 8.5 (~465 GB/s of the card's ~600), four 10.9 (fewer sub-groups, more registers).
* For 2 <= M <= 16, one column a sub-group with a partial sum a row. A weight byte is read once per step whatever M is, so the cost is the weight's
* For 2 <= M <= 16 the ESIMD kernel (xe2_gemv_esimd.cpp) where its 2D loads can read the operands, else
* one column a sub-group with a partial sum a row. A weight byte is read once per step whatever M is, so the cost is the weight's
* bytes over the card's bandwidth.
*
* Not libref's order: each lane sums its own strided slice and the slices are reduced as a tree, so
@@ -283,6 +284,15 @@ int gemv(const RadArgs* a, RadStream st, const char* nkey, const char* kkey, int
}
if (mm <= 8 && N % 16 == 0 && K % 16 == 0 && K <= 6144 && !simt)
return launch_dpas8(*q, ab, bb, yb, ydt, N, K, ars, brs, yrs, ycs, mm);
/* 9 <= M <= 16 (9-16 sequences decoding, or a deep verify): the ESIMD kernel's two-band form, two
* 8-row DPAS on each weight tile, so the weight is still read once. The SIMT form below read it
* at 6-8x the 8-row cost (MiniCPM5-2B gate_up at M = 16: 712 -> 104 us). */
if (mm > 8 && !simt && N % 16 == 0 && K % 16 == 0 && ycs == 1 && rad_ptr_aligned(ab, 64) &&
rad_ptr_aligned(bb, 64) && rad_ptr_aligned(yb, 64) && (brs * 2) % 64 == 0 && (ars * 2) % 64 == 0 &&
(yrs * (ydt == RAD_F32 ? 4 : 2)) % 64 == 0) {
const int S = gemv_esimd_splits(N, K);
if (S > 0) return gemv_esimd(*q, 16, ab, ars, mm, bb, brs, yb, ydt, yrs, N, K, S);
}
return launch<1, kMaxM>(*q, ab, bb, yb, ydt, N, K, ars, brs, yrs, ycs, mm);
}