mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1888] [CLOSED] QSA decode attention: split each query's cells across blocks on the int8 mma path (STRATA_QSA_SPLIT_ATTN=1, opt-in) #3738
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#3738
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/1888
Author: @KarlGrier
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:qsa-split-decode-attn📝 Commits (1)
79043beQSA decode attention: split each query's cells across blocks on the int8 mma path (STRATA_QSA_SPLIT_ATTN=1, opt-in)📊 Changes
4 files changed (+319 additions, -0 deletions)
View changed files
📝
include/strata/kernels/qsa_prompt_attn.hpp(+8 -0)📝
src/core/mtp.cpp(+4 -0)📝
src/core/verify.cpp(+7 -0)📝
src/kernels/cuda/qsa_prompt_attn.cu(+300 -0)📄 Description
Title
Issue: none (an opt-in speed change)
Summary
STRATA_QSA_SPLIT_ATTN=1(opt-in, off by default) runs the QSA layers' decode attention - the verify window's and the draftlayer's - through the prompt path's int8 tensor-core kernel, with each query's cells split among up to 20 blocks (about two
blocks per SM in one wave) and the splits merged with the log-sum-exp rescale. It applies to int8 KV on sm_80 and newer;
everywhere else, and with the switch unset,
qsa_decode_attn_batchruns as before. The idea is from Eddoursul's fork(
fd23d91); the kernel here is written against this tree'sqsa_prompt_attn.cuand its helpers.It sums in another order than
qsa_decode_attn_batch, so the output is not bit-identical with the switch on (arounding-level change); with it off nothing changes.
Measured 2026-10-10 on one PC: RTX 5080 16 GB + RTX 4060 Ti 8 GB (driver 610.57.04, CUDA 13.3), Ryzen 9 9950X3D (16 cores), 96 GB DDR5, Linux 7.0; Qwen3.8-Flash-Next GSQ-RCO IQ3_S at a 131,072-token context. Served, stock against stock + this patch only, A B B A with a fresh server per arm (the model files evicted from the page cache before each), both arms with
--expert-cache auto --prefill auto:16384 --spec 4 --spec-min-p 0.5 --mtp --max-context 131072 --kv int8 --kv-resident 32768 --pcie-frac 0 --ple-inflight 128 --vram-reserve-mib 713withSTRATA_IO_THREADS=64 CUDA_MODULE_LOADING=LAZY STRATA_GR_V3=1 STRATA_PF_FUSED=1 STRATA_MMVQ_IL=1 STRATA_ADAPT_LAG=2 STRATA_DISJOINT_ADAPT=1(the stock flags of my community benchmark report, #1681); the patch's arm addsSTRATA_QSA_SPLIT_ATTN=1. Requests carry no sampling fields, so the server's configured defaults apply: temperature 1.0, top-p 0.95, top-k 20, min-p 0.05, reasoning effort high. Decode screen: long reasoning math and code (4,096 tokens each), five short questions, a 32K prompt with 768 tokens out; decode figures are the engine's own (accepted output tokens / decode time). Prompt-read screen: time to first token for prompts of 1K x3, 4K x3, 32K x2 and 120K x2 tokens (each a different text, 768 tokens out; its decode column comes from short sampled answers and varies more than the decode screen).In short (this patch against the same stock build, means of the two A B B A arms each):
STRATA_ROUTE_TAIL_SKIP=0The RTX 5080 alone, against v0.1.42
61b3fb5dwith upstream's defaults: v0.1.42 turns onSTRATA_ROUTE_TAIL_SKIP=7for single-GPU serve, so both arms skip low-ranked missed experts (what single-card users get).The RTX 5080 alone, against v0.1.42 with
STRATA_ROUTE_TAIL_SKIP=0in both arms (the tail skip off: the answers of a build without it).The RTX 5080 with the RTX 4060 Ti as the helper expert cache (
--expert-cache-device1 3300), measured on v0.1.41fb58e0dbwith this change on v0.1.41, before the rebase. The tail skip does not apply with a helper GPU.What changed
src/kernels/cuda/qsa_prompt_attn.cu:decode_attn_i8_split_kernel(the int8 q.k / p.v of one split of one query'scells, the same fragments and cp.async pipeline as the prompt kernel, partials in the decode scratch) and
decode_attn_merge_kernel(the splits of each query and head merged in split order);qsa_decode_attn_split()picks thesplit count and returns false (nothing launched) unless int8 KV on sm_80+, or when its partials would not fit the
caller's scratch. HIP: returns false before any launch (the kernels use the file's
mma16816/cp_async16, whichcompile to traps there, like the existing prompt kernels).
include/strata/kernels/qsa_prompt_attn.hpp: its declaration.src/core/verify.cpp,src/core/mtp.cpp: with the switch set, the verify window's and the draft layer's QSA attentiontry
qsa_decode_attn_split()first and keepqsa_decode_attn_batch()when it returns false.Left alone: the prompt path, KV formats other than int8 (K8V4, q4), the GDN layers, the switch-off path (no new work, the
same launches).
Extra Notes
How the default path was checked. exact7 (the CLI, seven fixed computations:
--adapt-swaps 0 --suffix-draft 0 --expert-cache 3500) on v0.1.4261b3fb5dand on this branch, both cards, the measurements' flags (above) plusSTRATA_PREFILL_CPU_SHARE=0on both (with the CPU prompt-read share on, short-prompt outputs depend on timing and the stock build does not repeat itself; with it off, stock v0.1.42 run twice gave the same seven hashes; the CLI does not use v0.1.42's tail skip, whose default is set only at serve start-up). With the switch unset: 7/7 identical to v0.1.42. WithSTRATA_QSA_SPLIT_ATTN=1: 3/7 identical; the other 4 differ because the attention sums in another order (a rounding-level change; the scoring check below).61b3fb5d02deb3f102deb3f1(=)2dbacf646c9b2d106c9b2d10(=)0cd91a5cae3b089bae3b089b(=)2d7b911538e671a238e671a2(=)c917d6d83e2193763e219376(=)3e219376(=)651f56c8651f56c8(=)651f56c8(=)a393ca0aa393ca0a(=)a393ca0a(=)The patch's own checks.
STRATA_QSA_SPLIT_ATTN=0, on a local build of this branch with a scoring hook that is not part of the change): mean NLLon minus off, math -0.0005 nats, a text corpus -0.0016 nats. My bound for a rounding-level change is 0.005.
tools/needle_bench.py) with the switch on, 32K and 128K prompts at depths 10, 50 and 90 %: 6/6found.
Upstream's tests (ctest, the whole suite, among them verify_parity, verify_batch_parity, spec_verify_parity, qsa_parity and spec_prob_test): v0.1.42 109/112 pass, this branch 109/112 pass; the same 3 fail on both (expert_parity, ple_parity, pool_test): they read model files from fixed paths that this PC does not have.
Not tested:
draft. On HIP
qsa_decode_attn_split()returns false before any launch (#if defined(__HIPCC__), like the file'sprompt kernels), but the file was not compiled for HIP here. SYCL is its own tree and is not touched.
qsa_decode_attn_batch()and were not run.--batch-groups), Windows, and other models.Measured and drafted with Claude Code.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.