mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2808] [Engine] sycl: prompt attention over 8-query selection unions on XMX (opt-in STRATA_PROMPT_ATTN_UNION=1) #4277
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4277
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2808
Author: @hotschmoe
Created: 10/16/2026
Status: 🔄 Open
Base:
main← Head:pr/sycl-prefill-attn-xmx📝 Commits (1)
2c97fc0sycl: prompt attention over 8-query selection unions on XMX (opt-in STRATA_PROMPT_ATTN_UNION=1)📊 Changes
6 files changed (+875 additions, -0 deletions)
View changed files
📝
docs/INTEL.md(+49 -0)📝
sycl/CMakeLists.txt(+7 -0)➕
sycl/include/strata/kernels/qsa_prompt_attn_union.hpp(+25 -0)📝
sycl/src/kernels/cuda/qsa_prompt_attn.dp.cpp(+4 -0)➕
sycl/src/kernels/cuda/qsa_prompt_attn_union.dp.cpp(+477 -0)➕
sycl/src/kernels/qsa_prompt_attn_union_parity.cpp(+313 -0)📄 Description
Problem and result
On the SYCL port the QSA prompt attention runs the FP32 decode kernel, 32 positions per launch, and every position gathers its own ~2,051 selected K/V cells. The XMX port (
STRATA_PROMPT_ATTN_XMX=1) is slower than that, anddocs/INTEL.mdlists a kernel over the union of neighbouring positions' selections as "not built".This adds that kernel, opt-in (
STRATA_PROMPT_ATTN_UNION=1). For every 8 neighbouring positions a first kernel builds the sorted union of their selected cells, each cell marked with the positions that chose it. The attention kernel dequantizes the INT8 K/V of 64-cell chunks of that union once to FP16 and runs S^T = K Q^T and O += P V on joint_matrix (8x16x16, FP32 sums) for all 96 rows (8 positions x 12 heads). A cell is -inf in the online softmax for the positions that did not select it, so every position attends to exactly the cells it attends to with the FP32 kernel.Result on 0.2.0-beta, two B70s: prompt reading 1,220 -> 1,414 tok/s at 4K (+16%) and 2,084 -> 2,387 tok/s at 32K (+15%). Decode is not touched (verify window 39.4 / 40.0 -> 39.4 / 39.2 ms). Unset, outputs and draft counts are identical to main.
Related discussion
Feature issue #2807 (closed in the 0.2.0 tracker reset). No maintainer agreement on scope yet. Opt-in, INT8 KV on Battlemage only; any other KV format or card, or a failed scratch allocation, keeps the existing path (one stderr line says why).
Approach
sycl/src/kernels/cuda/qsa_prompt_attn_union.dp.cpp(new): the union kernel (one work-group per 8 positions, 16K-cell local bitmaps), the attention kernel (one work-group per 8 positions and KV head, 12 sub-groups of 16, 256 GRF), the launcher and its per-queue scratch.sycl/include/strata/kernels/qsa_prompt_attn_union.hpp(new): the entry point (the contract ofqsa_prompt_attn_batch) and the switch.sycl/src/kernels/cuda/qsa_prompt_attn.dp.cpp: the include and the guarded call before the XMX v2 call (4 lines).sycl/src/kernels/qsa_prompt_attn_union_parity.cpp(new): the parity test (--selftestin ctest, skip code 77 off Battlemage).sycl/CMakeLists.txt,docs/INTEL.md.Left alone: the selection (block scores, top-k), decode, the FP32 and XMX v2 prompt kernels, other KV formats, every file outside
sycl/anddocs/.Validation
Setup: 0.2.0-beta
maine88ee39dagainst this branch rebased on it. 2x Intel Arc Pro B70 32 GB, kernel 7.1, Compute Runtime 26.22.38646.4 at run time; built with the repository dev image (sycl/tools/Dockerfileon the currentllama-sycl-b70:stable, IGC 2.41.5; an older cached base with IGC 2.36.3 cannot build 0.2.0, see #3219), AOTbmg-g31. Model Qwen3.8-Flash-Next ISTA GSQ-RCO IQ3_XXS,--layer-split 30 --prefill 8192 --max-context 65536 --kv int8 --spec 4 --mtp <BF16 draft layer> --mtp-max-t 4 --spec-min-p 0 --stream-experts --expert-cache auto, one slot, greedy, two fixed coding prompts with 512-token replies, a fresh engine per arm, then fresh 4K and 32K prompts. Coherence check and per-card health after every stop.Passed:
qsa_prompt_attn_union_parity --selftest(0.2.0-beta + this branch, head2c97fc0d, one B70): 5 of 5 PASS,FAILURES: 0(random INT8 pools behind a shuffled page table, 1.5K-40K contexts, ragged last groups, 2% non-resident pages, a bitwise rerun). Error against FP64 2.6e-3 - 5.0e-3 at an output scale of 3.3-3.6 (FP32 kernel 1.7e-6 - 2.6e-6); one chunk 0.88x (fresh selections, union 5.3x) to 5.45x (union 1.0x) of the FP32 kernel.e88ee39dSTRATA_PROMPT_ATTN_UNION=1Failed: none observed.
Not run: the teacher-forced NLL comparison on 0.2.0 (on 0.1.x main, 8 chats, 12,737 tokens: NLL 2.6234 unset vs 2.5506 set, inside the spread of a rounding-only control, so no quality change resolved either way);
--max-context 200000(not every expert fits on a plain two-card layer split); prompts above 32K on 0.2.0; CUDA/HIP/Metal (not touched);ctestas a whole.Limits
--vram-reserve-mibheadroom.docs/INTEL.mdentry quotes the 0.1.x measurement (main296b59d2); I can swap in the 0.2.0 numbers.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.