From f49aee84f0871557f943b152fb2a4c6ade340cbb Mon Sep 17 00:00:00 2001 From: pascallinxweiler Date: Sat, 24 Oct 2026 06:28:35 +0200 Subject: [PATCH] libxe2: attention value rows 16 bytes at a time at head_dim 256 -- 2.72 -> 0.88 s a 27B prefill The lane-per-key attention read bf16 value rows with 16-byte loads only at head_dim 128; at 256 (Qwen3.8's full attention, 16 dims a lane) every element went through the generic loader. Two 16-byte loads a lane now. rad-kbench 138/138 on the fixture and 33/33 on the 27B (worst rel_l2 1.5e-4). SYCL_PROGRESS records the first 27B BetterBench run (5720a95): decode median 19.1 tok/s, prefill 113.4 tok/s at 2000. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1 --- docs/SYCL_PROGRESS.md | 3 +++ libxe2/xe2_attn_fast.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docs/SYCL_PROGRESS.md b/docs/SYCL_PROGRESS.md index fe5be029..9f7f1bb2 100644 --- a/docs/SYCL_PROGRESS.md +++ b/docs/SYCL_PROGRESS.md @@ -159,6 +159,7 @@ fonts (this host has none; the first post had no text) -- all unpacked without r |---|---|---|---|---|---|---|---|---| | 2026-10-23 | `874f8d2` | minicpm5-2b-bf16 | sycl, correctness-first kernels | `--num-speculative-tokens 0 --max-model-len 8192 --max-num-seqs 4` | 17.3 / 17.3 @2000 (8000+ skipped: over the 8192 context) | 4.2 / 3.5 | first run | `~/radiance-bench/runs/20261023-165102-minicpm5-2b-bf16-874f8d2/results.html`, posted with `report.jpg` | | 2026-10-23 | `a869226` | minicpm5-2b-bf16 | sycl, Phase 4 step 1 (GEMV) | same | 17.5 / 17.4 @2000 | 25.3 / 16.2 | decode +504.5% | `~/radiance-bench/runs/20261023-194856-minicpm5-2b-bf16-a869226/results.html`, posted with `report.jpg` | +| 2026-10-24 | `5720a95` | qwen38-27b-m2xfp4 (Qwen3.8-27B-DFLASH2-PARO-M2XFP4) | sycl, fast m2xfp4 GEMV / DPAS verify / tiled XMX prefill, DFlash2 drafter on | `--max-model-len 8192 --max-num-seqs 4` | 113.4 / 113.3 @2000 | 19.1 / - | first run | `~/radiance-bench/runs/20261024-060226-qwen38-27b-m2xfp4-5720a95/results.html`, posted with `report.jpg` | | 2026-10-23 | `b07da2a` | minicpm5-2b-bf16 | sycl, Phase 4 steps 2-6 (XMX prefill, split-KV attention, norms, GEMV split) | same | 1575.6 / 1547.1 @2000 | 51.8 / 41.4 | decode +104.7%, prefill 90x | `~/radiance-bench/runs/20261023-221354-minicpm5-2b-bf16-b07da2a/results.html`, posted with `report.jpg` | ## Models @@ -558,6 +559,8 @@ from bf16 to fp16 activations took it 0.0041 -> 0.0035. local-memory-tiled XMX kernel (128 x 128 tiles, 32 x 64 a sub-group, ~30 TFLOPS against the card's ~98 fp16 DPAS peak, measured): 6.4 -> 3.7 s - givens_dense_quant as batched XMX GEMMs for rows >= 17: 2.07 -> 0.70 s +- attn_paged at head_dim 256: the value rows read 16 bytes at a time (they were scalar): 2.72 -> + 0.88 s (rad-kbench 138/138 fixture, 33/33 on the 27B) - tried and dropped: a chunk-parallel kkt_solve (exact but slower, 1.44 -> 2.14 s). Remaining prefill (profiled): chunk scan 4.6 s, GEMMs 3.7, attention 2.7 (head_dim 256, the diff --git a/libxe2/xe2_attn_fast.cpp b/libxe2/xe2_attn_fast.cpp index a36363ee..175e563c 100644 --- a/libxe2/xe2_attn_fast.cpp +++ b/libxe2/xe2_attn_fast.cpp @@ -215,6 +215,13 @@ int attn_paged_fast(const RadArgs* a, RadStream st) { const sycl::vec vv = *(const sycl::vec*)( (const uint16_t*)cb + kbj + head_dim + lane * 8); for (int e = 0; e < 8; ++e) acc[e] += wj * (rad_bf16_to_f32(vv[e]) * vds); + } else if (vec_kv && per == 16) { + /* head_dim 256 (Qwen3.8's full attention): two 16-byte loads a lane */ + const uint16_t* vr = (const uint16_t*)cb + kbj + head_dim + lane * 16; + const sycl::vec v0 = *(const sycl::vec*)vr; + const sycl::vec v1 = *(const sycl::vec*)(vr + 8); + for (int e = 0; e < 8; ++e) acc[e] += wj * (rad_bf16_to_f32(v0[e]) * vds); + for (int e = 0; e < 8; ++e) acc[8 + e] += wj * (rad_bf16_to_f32(v1[e]) * vds); } else { for (int e = 0; e < per; ++e) acc[e] += wj * (rad_load_f32(cb, cdt, kbj + (head_dim + lane * per + e) * sd) * vds);