libxe2: Phase 4 step 2 -- bf16 XMX GEMM for prefill and a one-pass paged attention

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
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-23 20:34:02 +02:00
1 parent a65ab54213
commit 96b3e1be83
5 files changed
+381

No files matched your search

+17
View File
@@ -382,6 +382,23 @@ the rest under 1.5% each.
The B65's fast path is as far from libref as the production CPU library is. Greedy against libref:
7/8 prompts identical, the eighth diverging at token 18 on a 0.008-nat near-tie.
## Phase 4, step 2 (2026-10-23): XMX GEMM and one-pass attention
- `xe2_gemm_nt_xmx` / `xe2_logits_gemm_xmx` (priority 5, `M >= 17`, bf16): joint_matrix M8 N16 K16,
use::b loaded column-major straight from the [N, K] weight (probed exact on the card), eight
sub-groups a work-group sharing one 64-column slice; tail rows by the GEMV, odd shapes to the exact
kernel.
- `xe2_attn_paged` (priority 10): one pass, online softmax, keys over eight sub-groups, head_dim over
lanes; the exact kernel underneath.
- rad-kbench: fixture 499/499, MiniCPM5 482/482 (worst rel_l2 1.7e-4); every new row reached.
- KL against the libref reference (same corpus as D13): normal batching (XMX + fast attention)
mean 5.8e-4, p99 3.2e-3, top-1 98.69%, PPL x1.0001; 16-token chunks (GEMV + fast attention)
5.8e-4 / 2.9e-3 / 98.59%. Inside the bound.
- **Prefill 1795 tokens: TTFT 4.57 s = 393 tok/s (was ~17).** Decode 33.2 tok/s over 512 tokens, but
16.2 tok/s right after a 1.8k-token prompt: single-row decode attention runs 16 work-groups (one a
head) on a 160-engine card, and each kv head is read by 8 query heads. Next: split the keys across
work-groups and share a kv head's reads across its query heads.
## Next steps
1. ~~Milestone B, part 2: `minicpm5-2b-fp8.rad`~~ **Dropped by the user (2026-10-23): "instead of the