libxe2: split-KV attention -- a kv head's keys read once for its query heads, decode across the card

The long-context decode profile was 70% attention: one work-group a (row, head) left most of the
card idle at one row and read each kv head eight times. xe2_attn_paged now splits a row's keys into
partitions of 32 or more across work-groups, each work-group a (row, kv head, partition) whose
sub-groups are the kv head's query heads, the partial softmax states merged from 64 MiB of scratch
(the scratch hook); prefill-sized row counts take one partition and write directly.

rad-kbench 138/138 and 132/132, KL against libref mean 5.8e-4, p99 3.2e-3, top-1 98.5%. Decode
after a 1797-token prompt 16.2 -> 29.8 tok/s; short-context decode 32 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:42:38 +02:00
1 parent 96b3e1be83
commit b57c2db60c
4 files changed
+143 -85

No files matched your search

+1
View File
@@ -53,6 +53,7 @@ int logits_gemm_gemv(const RadArgs* a, RadStream s);
int gemm_nt_xmx(const RadArgs* a, RadStream s);
int logits_gemm_xmx(const RadArgs* a, RadStream s);
int attn_paged_fast(const RadArgs* a, RadStream s);
int64_t attn_paged_scratch(const RadArgs* a);
int gemm_zp_layout(const RadParam* p, int n_p, int operand, const RadEncoding* enc, const int* sel,
const RadTensor* planes, int n, RadLayout* out);
int gemm_zp_relayout(const RadParam* p, int n_p, int operand, const RadEncoding* enc,