For 17 or more rows the rotation is a batch of GEMMs, one a (part, 128-column group): the input
fp16(x / D) per part, the f16 rotation as B, a batched form of the tiled fp16 XMX kernel
(xmx_f16_batched) into f32, then libref's quantiser a (row, part, group). The input rounded once
to fp16 where libref sums in double: a fast kernel. KL against the exact reference: mean 0.0037,
top-1 97.2% (0.0035 / 95.6% before: within the noise of 250 positions). Up to 16 rows the float-pair
kernel stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
xmx_f16_tiled: a 128 x 128 work-group tile, 4 x 2 sub-groups of 32 x 64 (16 accumulators, the
large register file), K in steps of 32 with A and a VNNI B staged in local memory, double
buffered, each sub-group's A tiles loaded once a K16 step; the accumulators stored straight to an
f32 scratch and scaled into y by a second kernel (a generic store in the epilogue spilled them and
ran 3x slower than the old tiling). ~30 TFLOPS on the 27B's prefill shapes in a standalone probe
against ~18 / ~11 for the previous per-sub-group tiling (the card's measured fp16 DPAS peak: ~98).
gemm_nt_q over a 1792-token prefill 6.4 -> 3.7 s. KL against the exact reference unchanged (mean
0.0035, top-1 95.6%): the same products.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
- gdn_chunk_scan for head_k = 128, chunk 64: a work-group of 256 a (sequence, head, block of 32
value columns), the chunk's k, q (rows padded), the block's slices of v, S, W, V' and the sA rows
in local memory (~124 KB); every phase of a chunk is thousands of independent chains -- W[j][e],
V'[i][e], R[i][j], O[i][e], S[d][e] -- each one work-item's, in libref's order, A staged in local
memory, the decays e^{g_i - g_j} (libref's double exp) once a call. Still bit-identical (rel_l2 0,
the 27B's geometry, 1..32 rows and multi-chunk). 233 -> 96 ms a call at 1792 tokens.
- m2xfp4 at M >= 17 now fp16 on XMX: the weight times 2^(127 - e_max(n)), exact in fp16; the
activation fp16(a * a_scale / R_m); y = acc * R_m * 2^(e_max - 127) in a new scaled fp16 XMX
kernel (xmx_f16_scaled). fp16's 2^-11 step instead of bf16's 2^-8.
KL on the 27B against an XE2_EXACT=1 reference (every kernel exact, each matched to libref bit for
bit; 250 positions, full vocabulary): mean 0.0041 -> 0.0035, p99 0.027 -> 0.021, top-1 96.8% ->
95.6%, PPL ratio 0.998. The fast set's KL is dominated by the model's own fp8 activation quantiser
re-rounding small upstream differences.
27B prefill of 1792 tokens: 26.3 -> 19.7 s (68 -> 91 tok/s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
xe2_gemm_nt_xmx / xe2_logits_gemm_xmx (M >= 17, bf16): joint_matrix M8 N16 K16 with use::b loaded
column-major straight from the [N, K] weight, eight sub-groups a work-group on one 64-column slice
so a B tile is in cache for all of them; tail rows go to the GEMV and shapes the tiles cannot read
to the exact kernel. xe2_attn_paged: one pass with an online softmax, keys over eight sub-groups,
head_dim over lanes, libref's masks, windows, ragged batches and fp8 descales. Both keep their
exact twins under XE2_EXACT=1.
rad-kbench: fixture 499/499, MiniCPM5-2B 482/482 (worst rel_l2 1.7e-4). KL against the libref
reference over 1914 positions: mean 5.8e-4, p99 3.2e-3, top-1 98.7% -- inside the bound.
Prefill of a 1795-token prompt: 4.57 s, 393 tok/s (was ~17); decode 33.2 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1