[PR #3941] [Engine] sycl: QSA block scores on XMX (joint_matrix) - 128K prefill -10.5% TTFT on a B70 #4841

Open
opened 2026-11-07 15:39:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3941
Author: @kennyko2002
Created: 10/24/2026
Status: 🔄 Open

Base: main ← Head: pr-qsa-xmx


📝 Commits (2)

  • f0f3985 sycl: QSA block scores on XMX (joint_matrix) for Battlemage - 128K prefill -11.7% TTFT
  • c2493b4 sycl: STRATA_VERIFY_TRACE=1 dumps the device breadcrumbs at the end of a run

📊 Changes

3 files changed (+201 additions, -1 deletions)

View changed files

📝 sycl/CMakeLists.txt (+5 -0)
📝 sycl/src/kernels/cuda/qsa_select.dp.cpp (+191 -1)
📝 sycl/src/program/generate.cpp (+5 -0)

📄 Description

Ports the SYCL branch of qsa_block_scores_tc() to joint_matrix, and registers the qsa_select_bench that upstream wrote but never added to the build.

qsa_block_scores_tc() returned false on SYCL ("SYCL: the tensor-core kernel is not ported yet; the caller takes the older kernel"), so the prompt's QSA selection ran the warp kernel: one warp per (query, block), four 128-wide dots with five shuffles each. It was 6.40 ms per 256 queries x 32,769 blocks (1.34 TFLOPS) and 23.0 s of the 95.0 s 128K prefill on an Arc Pro B70.

block_scores_xmx() implements the CUDA kernel's tiling (16 queries x 16 blocks per C tile, K = 128, the four indexer heads relu'd and summed in head order) with the same B-operand packing idiom as iq_kernels' xmx_gemm_iq. Both operands are split into an FP16 hi and lo part and multiplied three ways (lo*hi, hi*lo, hi*hi - the CUDA TF32 kernel's order), which keeps FP32-level scores. The tail block n_bid (the dead key, +1e9) still comes from block_scores_tail_kernel, as on CUDA.

Measured (Arc Pro B70 / bmg-g31, Qwen3.8-Flash-Next IQ3_XXS, --prefill 32768, 128,000-token prompt, greedy 256 tokens):

warp (STRATA_SELECT_XMX=0) XMX Δ
TTFT on this base (8183c6b6 + #3934) 96.65 s 86.46 s -10.5%
PP 1357 tok/s 1522 tok/s +12.1%
TTFT measured on 011c9e60 earlier 97.09 s 85.70 s -11.7%
qsa select phase 23.0 s 11.3 s -51%

qsa_select_bench (256 queries x 32,769 blocks, 131k context): 6.40 ms -> 4.63 ms (1.4x), score max error 1e-7 of the scale against FP64 (the warp kernel's own is 1.2e-7), 256/256 selections identical to the warp kernel.

Not bitwise, as the CUDA TC path is not: the summation order differs, so an exact tie can select differently - at 8k the greedy continuation leaves the warp kernel's at token 27, at 128k at token 231 (deterministic; two runs are byte-identical). STRATA_SELECT_XMX=0 (new) or STRATA_QSA_WARP=1 (existing) keeps the warp kernel.

This needs #3934 to build on current main: without it src/kernels/cpu/iq_avx512.cpp fails with _pdep_u64 requires target feature 'bmi2'. The numbers above were measured with #3934 cherry-picked on top; that fix is not part of this PR.

Two smaller notes:

  • An N=32 tile (2 C tiles per sub-group, 8 accumulators, grf_size<256>) is faster in the worst-case benchmark (3.97 vs 4.63 ms) but slower in the engine (14.1 vs 11.3 s - half the work-groups, and the engine's reach is causal, so the grid matters more), so XNT stays 1 with the measurement in the comment.
  • This touches the same file as #2806 (decode QSA selection/attention launches); this is the prefill selection scorer only.

Open: the teacher-forced KL gate has not been run. STRATA_FOLLOW is only read on the serve request path, and the serve path cannot be fed raw token ids, so upstream's --tokens-file recipe does not run on SYCL yet. The expectation is the 1e-5 nats range (score error 1e-7 of the scale, selections bit-identical at 131k).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3941 **Author:** [@kennyko2002](https://github.com/kennyko2002) **Created:** 10/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr-qsa-xmx` --- ### 📝 Commits (2) - [`f0f3985`](https://github.com/Niko1221/Strata/commit/f0f3985c2f81716349bf24caea14cd877bfc6064) sycl: QSA block scores on XMX (joint_matrix) for Battlemage - 128K prefill -11.7% TTFT - [`c2493b4`](https://github.com/Niko1221/Strata/commit/c2493b4920c21163b0dc08149fbcb28978c8a33e) sycl: STRATA_VERIFY_TRACE=1 dumps the device breadcrumbs at the end of a run ### 📊 Changes **3 files changed** (+201 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `sycl/CMakeLists.txt` (+5 -0) 📝 `sycl/src/kernels/cuda/qsa_select.dp.cpp` (+191 -1) 📝 `sycl/src/program/generate.cpp` (+5 -0) </details> ### 📄 Description Ports the SYCL branch of `qsa_block_scores_tc()` to `joint_matrix`, and registers the `qsa_select_bench` that upstream wrote but never added to the build. `qsa_block_scores_tc()` returned `false` on SYCL (*"SYCL: the tensor-core kernel is not ported yet; the caller takes the older kernel"*), so the prompt's QSA selection ran the warp kernel: one warp per (query, block), four 128-wide dots with five shuffles each. It was **6.40 ms per 256 queries x 32,769 blocks (1.34 TFLOPS)** and **23.0 s of the 95.0 s 128K prefill** on an Arc Pro B70. `block_scores_xmx()` implements the CUDA kernel's tiling (16 queries x 16 blocks per C tile, K = 128, the four indexer heads relu'd and summed in head order) with the same B-operand packing idiom as `iq_kernels`' `xmx_gemm_iq`. Both operands are split into an FP16 hi and lo part and multiplied three ways (`lo*hi`, `hi*lo`, `hi*hi` - the CUDA TF32 kernel's order), which keeps FP32-level scores. The tail block `n_bid` (the `dead` key, +1e9) still comes from `block_scores_tail_kernel`, as on CUDA. **Measured** (Arc Pro B70 / bmg-g31, Qwen3.8-Flash-Next IQ3_XXS, `--prefill 32768`, 128,000-token prompt, greedy 256 tokens): | | warp (`STRATA_SELECT_XMX=0`) | XMX | Δ | |---|---:|---:|---| | TTFT on this base (8183c6b6 + #3934) | 96.65 s | **86.46 s** | **-10.5%** | | PP | 1357 tok/s | **1522 tok/s** | +12.1% | | TTFT measured on 011c9e60 earlier | 97.09 s | 85.70 s | -11.7% | | `qsa select` phase | 23.0 s | 11.3 s | -51% | `qsa_select_bench` (256 queries x 32,769 blocks, 131k context): **6.40 ms -> 4.63 ms (1.4x)**, score max error **1e-7 of the scale** against FP64 (the warp kernel's own is 1.2e-7), **256/256 selections identical to the warp kernel**. **Not bitwise**, as the CUDA TC path is not: the summation order differs, so an exact tie can select differently - at 8k the greedy continuation leaves the warp kernel's at token 27, at 128k at token 231 (deterministic; two runs are byte-identical). `STRATA_SELECT_XMX=0` (new) or `STRATA_QSA_WARP=1` (existing) keeps the warp kernel. **This needs #3934 to build on current `main`**: without it `src/kernels/cpu/iq_avx512.cpp` fails with `_pdep_u64 requires target feature 'bmi2'`. The numbers above were measured with #3934 cherry-picked on top; that fix is not part of this PR. Two smaller notes: * An N=32 tile (2 C tiles per sub-group, 8 accumulators, `grf_size<256>`) is faster in the worst-case benchmark (3.97 vs 4.63 ms) but slower in the engine (14.1 vs 11.3 s - half the work-groups, and the engine's `reach` is causal, so the grid matters more), so `XNT` stays 1 with the measurement in the comment. * This touches the same file as #2806 (decode QSA selection/attention launches); this is the prefill selection scorer only. **Open**: the teacher-forced KL gate has not been run. `STRATA_FOLLOW` is only read on the serve request path, and the serve path cannot be fed raw token ids, so upstream's `--tokens-file` recipe does not run on SYCL yet. The expectation is the 1e-5 nats range (score error 1e-7 of the scale, selections bit-identical at 131k). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4841
No description provided.