libxe2: kv_store and attn_paged, correctness first

The paged cache in libref's and libr4d's layout. attn_paged runs one work-group a (query row, head)
in libref's order: each key's dot summed over d serially by its lane, the max over the group, then
weights by chunk in local memory with the sum and every acc[d] accumulated in key order, exp in
double. Scores are recomputed rather than kept, since 131072 keys of them do not fit local memory.
Masks, sliding windows, ragged batches and fp8 descales are libref's. kv_store skips a slot past
the cache instead of refusing the launch, which would need the host to read device memory.

rad-kbench against libref: fixture 178/178, MiniCPM5-2B 160/160 (rel_l2 0).

docs/SYCL_PROGRESS.md: the HIP build compiles (785/785 targets for gfx1201 in the ROCm 10.1
container) at the commit holding every core-side change.

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 16:12:32 +02:00
1 parent 649178eb59
commit ed76fc8aaa
4 files changed
+298 -5

No files matched your search

+12
View File
@@ -84,6 +84,18 @@ const RadKernelInfo kKernels[] = {
.dtypes = "float x and head, f32 logits",
.domain = RAD_DOMAIN_DEVICE, .constraints = cFloatDtype, .n_constraints = 1,
.launch = xe2::logits_gemm },
{ .name = "xe2_kv_store", .op = "kv_store", .family = "attn",
.computes = "this step's K and V into the paged cache at slot_mapping; fp8 stores k/k_scale",
.shape = "any head_dim, kv heads and block size; a negative or out-of-range slot is skipped",
.dtypes = "bf16 k and v, bf16 or E4M3 cache",
.domain = RAD_DOMAIN_DEVICE, .launch = xe2::kv_store },
{ .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",
.shape = "head_dim <= 512, 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, .launch = xe2::attn_paged },
};
const RadPluginInfo kInfo = {