mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2802] [Engine] sycl: cheaper IQ decodes in the grouped expert kernels (STRATA_IQ_DECODE_FAST=1, opt-in, bitwise) #4271
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#4271
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/2802
Author: @hotschmoe
Created: 10/16/2026
Status: 🔄 Open
Base:
main← Head:pr/sycl-iq-expert-decode📝 Commits (1)
7035777sycl: cheaper IQ decodes in the grouped expert kernels (STRATA_IQ_DECODE_FAST=1, opt-in, bitwise)📊 Changes
5 files changed (+853 additions, -0 deletions)
View changed files
📝
docs/INTEL.md(+44 -0)📝
sycl/CMakeLists.txt(+2 -0)➕
sycl/src/kernels/cuda/iq_decode_tables.inc(+333 -0)📝
sycl/src/kernels/cuda/iq_kernels.dp.cpp(+426 -0)📝
sycl/src/kernels/native_grouped_parity.cpp(+48 -0)📄 Description
Problem and result
The SYCL lane kernels that read the routed experts (
native_gu_kernel/native_down_kernel, 8 lanes a row) are ALU-bound on an Arc Pro B70, not memory-bound: 280-480 instructions per 32-weight part for its 8 dp4a, reading the experts at 19-44% of DRAM bandwidth. Most of it is the dpct per-byte emulation ofbyte_level_permutein the Q2_0 dot, the compare/select chain of the IQ4_NL codebook lookup, the popcount/multiply ksigns unpacking, and 64-bitkbx * sizeof(block)products every iteration.STRATA_IQ_DECODE_FAST=1switches the seven IQ expert formats (IQ2_XXS, IQ2_XS, IQ3_XXS, IQ3_S, IQ2_S gate/up; IQ4_NL, Q2_0 down) to kernels that produce the same bits with fewer instructions. Off by default; without the flag the engine runs exactly the code it ran before.Result on 0.2.0-beta, two B70s, one stream: decode 70.5 / 73.7 -> 76.7 / 80.1 tok/s (+8.7%), with output tokens and draft counts identical, so the gain is kernel time alone (verify window 39.5 / 40.2 -> 36.3 / 36.9 ms). Prompt reading unchanged.
Related discussion
Feature issue #2801 (closed in the 0.2.0 tracker reset). No maintainer agreement on scope yet; opt-in and SYCL-only so the default path stays byte-identical. Happy to change the switch name or drop formats.
Approach
sycl/src/kernels/cuda/iq_kernels.dp.cpp:IqFast<TY>decode traits whoseprepyields the same integers asMulti<TY>::prep/ thevec_dot_*_q8_1dot and reuses the sameactsandfinish; ksigns masks from a 2 KB table, the IQ4_NL codebook through four 256-entry position tables, Q2_0 fields spread with shifts and masks, aligned 8-byte loads.rows_dot_fastkeeps the k order, per-entry float sum order andlanes_sumof the current dots, so the bits cannot move. Two rows per lane in 16-lane sub-groups. One hook line at the top oflaunch_gu_port/launch_down_portthat returns at once when the latched flag is off.STRATA_IQ_DECODE_FAST_FMTS=<ggml ids>restricts it for an A/B.sycl/src/kernels/cuda/iq_decode_tables.inc(new): the two tables with the formulas that generate them.sycl/src/kernels/native_grouped_parity.cpp:--iqmode, fast against current, bitwise, every IQ gate/up format with both IQ down formats, groups of 1..6 entries, scattered destinations, stale scratch, rows a call must not write.sycl/CMakeLists.txt: ctestnative_grouped_parity_iq_decode.docs/INTEL.md: a section on the flag.Left alone:
include/,src/, CUDA and HIP, every kernel the default path runs, the K-quant / Q5_1 / Q8_0 expert formats, the prompt path.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:
native_grouped_parity --iq(0.2.0-beta + this branch, head70357772, one B70):0 failures, every case bitwise equal. Plainnative_grouped_parity:0 failures.e88ee39dSTRATA_IQ_DECODE_FAST=1Failed: none observed.
Not run: two concurrent streams (main refuses
--batch-mtpon a layer split),--max-context 200000(a plain two-card layer split does not fit all 24,576 experts), CUDA/HIP/Metal builds (no file touched), Arc A-series cards,ctestas a whole (the parity binaries were run directly).Limits
STRATA_GU_LANES/STRATA_DOWN_LANESkeep the current kernels.docs/INTEL.mdsection quotes the earlier measurement on 0.1.xmain296b59d2(79.5 -> 85.6 tok/s); I can swap in the 0.2.0 numbers above if you prefer.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.