libxe2: gemm_nt_bias on the fast GEMMs, the epilogue in libref's order

gemm_nt_bias (Y = A B^T + bias, then gelu / gelu_tanh and a residual) had only the
correctness-first row: one work-item an output over ascending k. 22 architectures use it
(the ViT, SigLIP2, GLM-vision, SAM and Gemma4-audio blocks, Qwen3-ASR, nomic-bert, the
diffusion VAEs and UNets). The new row forms A B^T on the existing bf16 kernels (the skinny
GEMV at M <= 16, XMX above; each falls back to the exact kernel where its layout is refused)
into an f32 workspace, and gemm_plain runs only its epilogue on it, so the bias, activation,
residual and their roundings are the reference row's. XE2_EXACT=1 keeps the ref row.

rad-kbench: fixture 210/210 (worst rel_l2 1.7e-4), full fixture 2144/2144; the
Qwen3.5-9B vision tower's shapes all agree with libref. N = K = 4608 + gelu on the B65:
M = 1 1,627 -> 81 us, M = 16 8,221 -> 104, M = 128 74,573 -> 253, M = 512 302,924 -> 721.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
aneinanderandClaude Opus 5.5 committed 2026-11-08 12:54:54 +01:00
1 parent 6abca01f17
commit d04a27fad3
3 files changed
+50 -2

No files matched your search

+1
View File
@@ -81,6 +81,7 @@ int gemm_nt_q_m2_xmx(const RadArgs* a, RadStream s);
int givens_dense_quant(const RadArgs* a, RadStream s);
int gemm_nt_bias(const RadArgs* a, RadStream s);
int gemm_nt_bias_fast(const RadArgs* a, RadStream s);
int dflash_conv(const RadArgs* a, RadStream s);
int attn_dense(const RadArgs* a, RadStream s);
int logit_rerank(const RadArgs* a, RadStream s);