mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2746] [CLOSED] [Engine] [SYCL] use packed word expansion for Q2_0 expert down on Battlemage #4238
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#4238
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/2746
Author: @xiangyuT
Created: 10/16/2026
Status: ❌ Closed
Base:
main← Head:feat/sycl-q2-down-word-expand📝 Commits (3)
fe47faasycl: expand Q2_0 down weights with packed word operations44b21f6sycl: keep Q2 decoder local to its kernel translation unite801853sycl: select Q2 word decoding without synthetic format IDs📊 Changes
1 file changed (+95 additions, -11 deletions)
View changed files
📝
sycl/src/kernels/cuda/iq_kernels.dp.cpp(+95 -11)📄 Description
Problem and result
Eligible Q2_0 expert-down kernels expand packed codes with byte/codebook operations. This patch uses exact packed-word shifts, masks and arithmetic while preserving INT8 DP4A operations, scales, FP32 accumulation and reduction order.
2026-10-20 retest on a single Arc Pro B70, 32 GiB container RAM limit, upstream 0.2.0-beta:
upstream/common frontend
e88ee39d1d6be6e3364183af3b39b62a7ed6f211; independent candidate97dd6dd8a10290165849d6764576ebb85f2c5032.All three lengths are complete.
These are standalone-PR results; no other preview optimizations are enabled.
Positive improvement means lower latency: mean of three request-wise
100 × (1 − candidate / mean(upstream-before, upstream-after))values.The displayed upstream time averages both bracketing blocks. TTFT is request-to-first nonempty SSE text;
TPOT is first-to-last nonempty SSE text arrival divided by engine-generated tokens minus one.
Tiny changes near baseline variation do not establish a meaningful improvement.
Related discussion
Source status (2026-10-20): source branch
feat/sycl-q2-down-word-expandnow points to the tested candidate97dd6dd8a10290165849d6764576ebb85f2c5032. This PR remains closed; GitHub still reports PR heade8018531183b8213ab4726f57656003a08452c20. All new measurements and validation in this description apply to the tested candidate. Reopening remains for maintainer review.This updates the existing PR after the 0.2.0-beta reset and current contribution requirements; it is not a competing submission.
Scope and reopening remain for maintainer review in this thread. Historical pre-beta evidence is folded below.
Related IQ decode implementation: #2802 / #2801 directly overlap in Q2 shift/mask expansion arithmetic, with additional formats and lane variants. Coordinate the common subset in these existing PRs to avoid duplicate implementations.
Approach
Battlemage, existing 8-lane/non-legacy/non-split Q2_0 down dispatch. No model-specific shape whitelist. Other formats and gate/up retain their algorithms. Non-Battlemage devices keep the original decoder; eligible Q2 calls still incur the added cached host device check.
New paths are now opt-in. Every control below is disabled when unset or
0.Set controls before starting the engine and restart after changes because values are cached/read during initialization.
Only the controls for this PR are set to
1in the measured candidate; pure upstream and the candidate-default check leave them unset.1STRATA_SYCL_Q2_WORD_EXPANDLeave Q2_WORD_EXPAND unset or set it to 0 to use the original decoder.
Validation
Passed
bmg-g31engine build. No non-SYCL backend files are changed.Sanitized operator output:
Failed
None observed in the completed checks listed above.
Not run
Runtime scope for this retest is the single B70/Linux/AOT setup below. Other GPUs, Windows, multi-GPU serving, JIT and whole-engine native recording were not revalidated.
Old cross-target compilation, broad prompt/logit corpora and historical microbenchmarks are not new-head evidence.
CUDA/HIP/Metal were not built: this patch touches only the separate SYCL implementation.
Environment, exact build settings and complete launch example
6.17.0-1007-intel, Intel xe; Xeon w5-3435X, host MemTotal 503.36 GiB.0000:cc:00.0; only that card is visible to the test container (logical GPU0).intel/omix:0.4.0-devel-ubuntu24.04, image IDsha256:53f0003fa66044935d69065836ba8ac40fab289b94655667fdeac0bdfa7e75c6.2026.1.1; compute runtime26.31.39395.13, device driver1.17.39395+13.--memory 34359738368 --memory-swap -1 --cpus 16 --shm-size 1g; one client, no batching. This is a cgroup limit on a larger host, not validation of a physically 32 GiB machine.llama.cppdependency3cf03257f219afbe7334045ff7c6a06ac68c627d; TLA disabled.ed59f92082b1e93c0e96d60a8b11aab089b52f09.de4b8e4d43b917e7706784d8bb445c9af86a3540; observed draft vocabulary106299(137.9 MiB head).Build the candidate with the following commands in the oneAPI environment. Build the upstream comparator identically,
substituting
/sources/baselineand/task/build-baseline. Sources are pinned to the full commits above.The following is a complete candidate configuration sample, not an unexplained environment-variable name.
Save it as
/task/pr2746-candidate.json./sources/baselineis the pinned upstream checkout used for the common Python frontend;/sources/pr2746is the candidate checkout;/taskis the writable test directory./opt/strata-venvis the serving Python environment mounted into the container. The/models/Strata/...paths are mountsfor the already-prepared pack/tokenizer, the two original GGUF shards and MTP runtime. Adjust those paths to the local files.
Direct launch with the same frontend/configuration (the collection harness additionally records engine IPC/output identity):
For the upstream arm, use
/task/build-baseline/strata, another log file, and remove only this PR'sSTRATA_SYCL_*entries.For the candidate-default correctness arm, keep the candidate executable and remove those same entries.
Leave every common setting, frontend and model unchanged. Clear inherited
STRATA_SYCL_*/STRATA_PRIVATE_*variables before launch.Initialize
/task/shared-calibrationin an excluded upstream process, issue a full-length warmup, stop it and restart for timing;all timed processes must read the same unchanged cache rather than calibrating during timing.
Startup checks for the retained run: context
131072, KVint8, resident KV32768, MTP maximum4, suffix lookup3,spec_min_p=0.50,pool_workers=15,pcie_frac=0.30. INFOspec=6is the verifier window with MTP maximum4and suffix drafting enabled.Observed initial resident / mirrored expert counts and mirror GiB: [(17756, 6820, 9.17)]. The
16384MiB setting is the mirror budget, not allocation.Sampled cgroup memory.current maximum across arms: 1.478–1.492 GiB; sampled swap maximum: 0 bytes. OOM / OOM-kill event deltas: [(0, 0)]. Driver allocations and shared host page cache are not established by these cgroup readings.
Request contents and standalone SSE reproduction example
The small Python example below reconstructs the same request objects used by the retained campaign (21 objects checked against
the three seven-request sequences), and sends one block to the already-running server. Save it as
/task/reproduce_requests.py.It is a portable reproduction client, not the IPC/cgroup collection harness used to produce the table.
The synthetic module may end in a truncated function; that is part of the fixed prompt.
For each of
4096,8192,32768, restart the engine for upstream-before, candidate and upstream-after,and run this client once per arm with a distinct output filename, for example:
For the 4K default-path check, restart the candidate with all new controls unset and use another output filename; exclude it from timing comparisons.
Exclude the first four requests; compare the final three. For full-length requests, check usage input counts
4096/8192/32768, actual output counts128/256/256,zero reused prompt tokens and matching output text. The retained campaign additionally checks engine token IDs.
Greedy sampling, seed
42, thinking off, sampler defaults and runtime settings are explicit in the configuration above.Host page cache is not flushed; no disk-cold TTFT is claimed. Suffix drafting is time-adaptive, so actual work counts are retained below.
Individual measured samples, baseline variation and actual draft work
Every block is one fresh engine, one excluded short warmup plus three excluded full-length warmups, then three measured requests.
Order is upstream-before / enabled candidate / upstream-after. There are six upstream and three candidate samples per length.
Limits
Development comparison on this single B70/model/configuration. Performance is not established for other hardware, workloads or contexts.
Default behavior is preserved by opt-in dispatch; no default change or formal benchmark approval is claimed.
The older measurements below use different source/defaults and RAM limits and are not the current comparison.
Historical pre-beta description and measurements — superseded by the 2026-10-20 retest above
The following original text is retained as historical evidence. In particular its default-on control descriptions and old tables
do not describe the rebased opt-in source or current 32 GiB measurements.
Summary
Replace the byte-permute/codebook expansion in Q2_0 expert down with exact packed-word shifts, masks and arithmetic. The decoder stays in the existing Q2_0 format specialization and is selected at compile time for the eligible down path. The existing INT8 DP4A operations, scales, FP32 accumulation and reduction order are preserved. On B70, warmed client TPOT improves by 4.18–4.48%; TTFT has no clear improvement.
The change is confined to
sycl/src/kernels/cuda/iq_kernels.dp.cpp; decoder helpers remain private to that translation unit. It follows upstreamintel_gpu_gen/IntelGpuGen::Battlemageclassification and the existing 8-lane, non-legacy, non-split dispatch conditions. There is no model-specific shape whitelist. Other formats and GU keep their existing algorithms and dispatch. Non-Battlemage devices retain the original decoder dispatch; eligible Q2 calls still incur the added cached host device check.Dispatch control
STRATA_SYCL_Q2_WORD_EXPANDcontrols the entire optimization:1: use word expansion when the existing dispatch and Battlemage guards allow it.0: use the original Q2_0 down path. There are no child switches.Set it before starting the engine and restart after changing it; the value is cached on first use. Normal operation needs no environment-variable setting.
B70 validation
Intel Arc Pro B70 32 GB, Linux/xe;
intel/omix:0.4.0-devel-ubuntu24.04, oneAPI DPC++ 2026.1.1, compute runtime 26.31.39395.13, Level Zero loader 1.32.0. Container limits: 128 GiB RAM and 16 CPU quota. Builds and GPU tests ran inside the container, with AOTbmg-g31.native_grouped_paritypass with default and fallback dispatch.Timings and endpoint identity checks below were collected at
fe47faa548ea6aba50101987bc255b5ed8eccd03, before the source cleanup. The current revision rebuilds the engine and parity targets and repeats decoder/down correctness validation. For these B70 AOT builds, executed kernel instructions and resource settings match the measured version; differences are limited to naming and non-executed markers after the final EOT. No new latency run is claimed.End-to-end performance
Baseline and frontend: upstream
296b59d2f73c8f04a805df29c2fa97655adace78. The candidate adds only this Q2 down change and uses its default production dispatch.Each input length uses baseline / candidate / baseline, restarting the engine for each arm. Exclude one short request and three full-input warmups, then measure three requests per arm. Changes average the three request-wise percentage changes relative to the mean of the matching before/after baseline samples; negative means faster. All three TPOT pairs improve at every input length.
TTFT is request send to the first nonempty SSE text arrival. TPOT is the first-to-last nonempty SSE arrival interval divided by generated tokens minus one. These are warmed, post-readiness measurements; the host page cache was not flushed.
Baseline before/after TPOT drift: +0.034%, +0.043%, -0.003%; TTFT drift: -0.177%, +0.362%, +0.017%, respectively.
Model and fixed configuration
ed59f92082b1e93c0e96d60a8b11aab089b52f09. Its routed expert down matrices use Q2_0.--expert-cache auto, reserve 1536 MiB, mirror budget 32768 MiB; auto prefill, no prefill borrowing.STRATA_VERIFY_DEVICE_PLAN=1,STRATA_VERIFY_NO_HOST=1,STRATA_STAGER_THREADS=12,STRATA_MIRROR_MIB=32768,STRATA_DECODE_TIMING=1,ONEAPI_DEVICE_SELECTOR=level_zero:gpu,SYCL_CACHE_PERSISTENT=0. Normal timing runs have no profiler.Down microbenchmark
Real GGUF weights at the model's down dimensions, K=640 and N=2560, with deterministic synthetic activations and fixed expert-group replay inputs. T is the token-window size. The probe directly selects the original or word-expansion down implementation in the same binary; end-to-end results above use production dispatch.
Three measured samples per baseline / candidate / baseline arm; each sample excludes at least 2 seconds/1000 calls of warmup and measures at least 3 seconds/2000 calls. These are steady graph-replay batched wall times including host submission and the final queue wait. They are not isolated GPU instruction latency, and their percentages are not added to endpoint gains.
All three corresponding samples improve for each listed row. These measurements and current validation cover single-card B70 AOT; Windows, multi-GPU operation and JIT paths on other devices were not tested.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.