[PR #2804] [Engine] sycl: KREG small-batch mmvq kernels for Q4_K/Q5_K/Q6_K/IQ4_XS at 1-8 columns (opt-in STRATA_MMVQ_KREG=1) #4273

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2804
Author: @hotschmoe
Created: 10/16/2026
Status: 🔄 Open

Base: main ← Head: pr/sycl-mmvq-kreg


📝 Commits (1)

  • 0928c7a sycl: KREG small-batch mmvq kernels for Q4_K/Q5_K/Q6_K/IQ4_XS at 1-8 columns (opt-in STRATA_MMVQ_KREG=1)

📊 Changes

5 files changed (+774 additions, -1 deletions)

View changed files

📝 docs/INTEL.md (+55 -0)
📝 sycl/CMakeLists.txt (+1 -1)
📝 sycl/include/strata/kernels/native_mmvq.hpp (+1 -0)
📝 sycl/src/kernels/cuda/native_mmvq.dp.cpp (+312 -0)
➕ sycl/src/kernels/mmvq_kreg_parity.cpp (+405 -0)

📄 Description

Problem and result

On the Arc Pro B70 the SYCL port's decode GEMVs for Q4_K, Q5_K, Q6_K and IQ4_XS (native_mmvq, 1-8 columns) are bound by instruction issue, not memory: the wide kernels re-read every column's activations for every row. This adds an opt-in kernel family, KREG: one work-group covers a row's whole K, each lane loads its slice of every column's activations once into registers, and the group streams tiles of 2-8 rows against them. STRATA_MMVQ_KREG=1 turns it on. Unset, the default path is unchanged (output identical to main, measured below).

Result on 0.2.0-beta, two B70s, one stream: the verify window 39.4 / 40.0 -> 35.4 / 35.4 ms (-10% / -12%), decode 70.6 / 73.9 -> 83.2 / 91.0 tok/s. Part of the tok/s gain is the changed output drafting better on these prompts; the window time is the fair comparison. Prompt reading unchanged.

Feature issue #2803 (closed in the 0.2.0 tracker reset). No maintainer agreement on scope yet. Independently tested by @deriknel on two B70s with --pipeline-windows 2 and a 26-layer split (comment below, before the reset): the bench windows 8% shorter, +7% mean over five greedy prompts, flag unset matching the build without the PR, a 148K prompt, image input and a 5-minute soak with no failed request or xe reset. Thank you.

Approach

  • sycl/src/kernels/cuda/native_mmvq.dp.cpp: native_mmvq_kreg_kernel with traits KregQ4K, KregQ5K, KregQ6K, KregIQ4XS (the wide kernels' lane split and dot expressions; K-quant scales decoded branch-free; IQ4_XS's codebook from a 256-entry local table), a transposed sub-group butterfly and a double-buffered local sum across sub-groups. Rows per tile and the 256-register mode per format and column count come from a sweep on the B70.
  • try_kreg<F>() reads the latched flag first and declines n_in above 32,768 and misaligned matrices; the existing kernels then run as before. One guarded hook per entry point; the output head goes through native_mmvq, so it is covered.
  • Rebase on 0.2.0: native_q6_k_mmvq now has q6_planar_mmvq where this PR adds its hook. Order kept as STRATA_Q6_PACKED, then planar, then KREG (the same resolution @deriknel used), so a planar copy is never bypassed.
  • sycl/src/kernels/mmvq_kreg_parity.cpp (new, in the parity loop, --selftest): KREG and the default kernels against a float64 reference over the same bytes for each format, 5 shapes and 1-8 columns; T-column KREG bitwise equal to T one-column calls; a power check. --bench times both on random weights.
  • sycl/include/strata/kernels/native_mmvq.hpp and docs/INTEL.md.

Left alone: other formats (Q8_0, IQ4_NL, IQ3_S, Q2_0, ...), the multi/small/wave kernels, tensors packed by STRATA_Q6_PACKED, include/, src/, CUDA/HIP.

Validation

Setup: 0.2.0-beta main e88ee39d against 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/Dockerfile on the current llama-sycl-b70:stable, IGC 2.41.5; an older cached base with IGC 2.36.3 cannot build 0.2.0, see #3219), AOT bmg-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:

  • mmvq_kreg_parity --selftest (0.2.0-beta + this branch, head 0928c7ad, one B70): mmvq_kreg_parity: 0 failures, mmvq_kreg_parity OK.
  • Engine A/B (tok/s, tokens per verify window, ms per window):
prompt 1 prompt 2 4K / 32K prompt tok/s
main e88ee39d 70.6, 2.78, 39.4 ms 73.9, 2.96, 40.0 ms 1,219 / 2,078
this branch, flag unset 70.6, 2.78, 39.4 ms 73.8, 2.96, 40.1 ms 1,226 / 2,087
STRATA_MMVQ_KREG=1 83.2, 2.94, 35.4 ms 91.0, 3.22, 35.4 ms 1,225 / 2,086
  • Flag unset: output SHAs and draft counts identical to main on both prompts. Flag set: coherent, output differs (another FP32 summation order). Coherence true and per-card health passed after every stop.

Failed: none observed.

Not run: the --bench kernel timings on 0.2.0 (kernel code unchanged by the rebase; the earlier table is in docs/INTEL.md), two streams on main (--batch-mtp refused on a layer split), --max-context 200000, CUDA/HIP builds (not touched), Arc A-series, ctest as a whole.

Limits

  • Not bitwise equal to the default kernels, so greedy text forks after some tokens and MTP acceptance moves with it.
  • IQ4_XS at 1 column on small matrices (2560 x 512 / 640) is 0.90-0.98x of the default kernel; KREG still takes it so multi-column calls stay bitwise equal to one-column calls.
  • The docs/INTEL.md section quotes the earlier measurement on 0.1.x main 296b59d2; I can swap in the 0.2.0 numbers above.
  • Prepared with AI assistance (Claude Code): the code, the measurements and this text were produced by Claude on the submitter's two Arc Pro B70s, at the submitter's request.

🤖 Generated with Claude Code


🔄 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/2804 **Author:** [@hotschmoe](https://github.com/hotschmoe) **Created:** 10/16/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/sycl-mmvq-kreg` --- ### 📝 Commits (1) - [`0928c7a`](https://github.com/Niko1221/Strata/commit/0928c7ad0b694e2e7c193ff3ae4f2542be0e48f9) sycl: KREG small-batch mmvq kernels for Q4_K/Q5_K/Q6_K/IQ4_XS at 1-8 columns (opt-in STRATA_MMVQ_KREG=1) ### 📊 Changes **5 files changed** (+774 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/INTEL.md` (+55 -0) 📝 `sycl/CMakeLists.txt` (+1 -1) 📝 `sycl/include/strata/kernels/native_mmvq.hpp` (+1 -0) 📝 `sycl/src/kernels/cuda/native_mmvq.dp.cpp` (+312 -0) ➕ `sycl/src/kernels/mmvq_kreg_parity.cpp` (+405 -0) </details> ### 📄 Description ## Problem and result On the Arc Pro B70 the SYCL port's decode GEMVs for Q4_K, Q5_K, Q6_K and IQ4_XS (`native_mmvq`, 1-8 columns) are bound by instruction issue, not memory: the wide kernels re-read every column's activations for every row. This adds an opt-in kernel family, KREG: one work-group covers a row's whole K, each lane loads its slice of every column's activations once into registers, and the group streams tiles of 2-8 rows against them. `STRATA_MMVQ_KREG=1` turns it on. Unset, the default path is unchanged (output identical to main, measured below). Result on 0.2.0-beta, two B70s, one stream: the verify window 39.4 / 40.0 -> 35.4 / 35.4 ms (-10% / -12%), decode 70.6 / 73.9 -> 83.2 / 91.0 tok/s. Part of the tok/s gain is the changed output drafting better on these prompts; the window time is the fair comparison. Prompt reading unchanged. ## Related discussion Feature issue #2803 (closed in the 0.2.0 tracker reset). No maintainer agreement on scope yet. Independently tested by @deriknel on two B70s with `--pipeline-windows 2` and a 26-layer split (comment below, before the reset): the bench windows 8% shorter, +7% mean over five greedy prompts, flag unset matching the build without the PR, a 148K prompt, image input and a 5-minute soak with no failed request or xe reset. Thank you. ## Approach - `sycl/src/kernels/cuda/native_mmvq.dp.cpp`: `native_mmvq_kreg_kernel` with traits `KregQ4K`, `KregQ5K`, `KregQ6K`, `KregIQ4XS` (the wide kernels' lane split and dot expressions; K-quant scales decoded branch-free; IQ4_XS's codebook from a 256-entry local table), a transposed sub-group butterfly and a double-buffered local sum across sub-groups. Rows per tile and the 256-register mode per format and column count come from a sweep on the B70. - `try_kreg<F>()` reads the latched flag first and declines n_in above 32,768 and misaligned matrices; the existing kernels then run as before. One guarded hook per entry point; the output head goes through `native_mmvq`, so it is covered. - Rebase on 0.2.0: `native_q6_k_mmvq` now has `q6_planar_mmvq` where this PR adds its hook. Order kept as `STRATA_Q6_PACKED`, then planar, then KREG (the same resolution @deriknel used), so a planar copy is never bypassed. - `sycl/src/kernels/mmvq_kreg_parity.cpp` (new, in the parity loop, `--selftest`): KREG and the default kernels against a float64 reference over the same bytes for each format, 5 shapes and 1-8 columns; T-column KREG bitwise equal to T one-column calls; a power check. `--bench` times both on random weights. - `sycl/include/strata/kernels/native_mmvq.hpp` and `docs/INTEL.md`. Left alone: other formats (Q8_0, IQ4_NL, IQ3_S, Q2_0, ...), the multi/small/wave kernels, tensors packed by `STRATA_Q6_PACKED`, `include/`, `src/`, CUDA/HIP. ## Validation Setup: 0.2.0-beta `main` e88ee39d against 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/Dockerfile` on the current `llama-sycl-b70:stable`, IGC 2.41.5; an older cached base with IGC 2.36.3 cannot build 0.2.0, see #3219), AOT `bmg-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:** - `mmvq_kreg_parity --selftest` (0.2.0-beta + this branch, head 0928c7ad, one B70): `mmvq_kreg_parity: 0 failures`, `mmvq_kreg_parity OK`. - Engine A/B (tok/s, tokens per verify window, ms per window): | | prompt 1 | prompt 2 | 4K / 32K prompt tok/s | |---|---|---|---| | main e88ee39d | 70.6, 2.78, 39.4 ms | 73.9, 2.96, 40.0 ms | 1,219 / 2,078 | | this branch, flag unset | 70.6, 2.78, 39.4 ms | 73.8, 2.96, 40.1 ms | 1,226 / 2,087 | | `STRATA_MMVQ_KREG=1` | 83.2, 2.94, 35.4 ms | 91.0, 3.22, 35.4 ms | 1,225 / 2,086 | - Flag unset: output SHAs and draft counts identical to main on both prompts. Flag set: coherent, output differs (another FP32 summation order). Coherence true and per-card health passed after every stop. **Failed:** none observed. **Not run:** the `--bench` kernel timings on 0.2.0 (kernel code unchanged by the rebase; the earlier table is in `docs/INTEL.md`), two streams on main (`--batch-mtp` refused on a layer split), `--max-context 200000`, CUDA/HIP builds (not touched), Arc A-series, `ctest` as a whole. ## Limits - Not bitwise equal to the default kernels, so greedy text forks after some tokens and MTP acceptance moves with it. - IQ4_XS at 1 column on small matrices (2560 x 512 / 640) is 0.90-0.98x of the default kernel; KREG still takes it so multi-column calls stay bitwise equal to one-column calls. - The `docs/INTEL.md` section quotes the earlier measurement on 0.1.x `main` 296b59d2; I can swap in the 0.2.0 numbers above. - Prepared with AI assistance (Claude Code): the code, the measurements and this text were produced by Claude on the submitter's two Arc Pro B70s, at the submitter's request. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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#4273
No description provided.