Archived
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:
1 parent
96b3e1be83
commit
b57c2db60c
4 files changed
+143
-85
No files matched your search
+5
-4
@@ -127,13 +127,14 @@ const RadKernelInfo kKernels[] = {
|
||||
.dtypes = "bf16 k and v, bf16 or E4M3 cache",
|
||||
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::kv_store },
|
||||
{ .name = "xe2_attn_paged", .op = "attn_paged", .family = "attn",
|
||||
.computes = "paged attention in one pass with an online softmax: a work-group a (row, head), "
|
||||
"keys over eight sub-groups, head_dim over lanes (not libref's order). "
|
||||
"XE2_EXACT=1 runs xe2_attn_paged_ref instead",
|
||||
.computes = "split-KV paged attention with an online softmax: a work-group a (row, kv head, "
|
||||
"key partition), its sub-groups the kv head's query heads, partitions merged from "
|
||||
"scratch (not libref's order). XE2_EXACT=1 runs xe2_attn_paged_ref instead",
|
||||
.shape = "head_dim a multiple of 16 up to 256 (else the exact kernel); any gqa, causal or "
|
||||
"not, sliding window, ragged batches",
|
||||
.dtypes = "bf16 query, bf16 or E4M3 cache with per-(seq, head) descales, bf16 out",
|
||||
.domain = RAD_DOMAIN_DEVICE, .priority = 10, .launch = xe2::attn_paged_fast },
|
||||
.domain = RAD_DOMAIN_DEVICE, .priority = 10, .launch = xe2::attn_paged_fast,
|
||||
.scratch = xe2::attn_paged_scratch },
|
||||
{ .name = "xe2_attn_paged_ref", .op = "attn_paged", .family = "attn",
|
||||
.computes = "paged attention, one work-group a (row, head), libref's order: serial dots, "
|
||||
"keys summed in order; the correctness-first form",
|
||||
|
||||
Reference in new issue
Block a user