mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4567] [CLOSED] [Engine] QSA decode attention: opt-in 32-cell chunks (STRATA_QSA_ATTN_VARIANT=2) #5094
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#5094
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/4567
Author: @Jackwwg83
Created: 10/29/2026
Status: ❌ Closed
Base:
main← Head:qsa-attn-32cell📝 Commits (1)
b63b372QSA decode attention: opt-in 32-cell chunks (STRATA_QSA_ATTN_VARIANT=2)📊 Changes
4 files changed (+112 additions, -25 deletions)
View changed files
📝
CMakeLists.txt(+9 -0)📝
include/strata/kernels/qsa_decode_attn.hpp(+3 -0)📝
src/kernels/cuda/qsa_decode_attn.cu(+51 -19)📝
src/kernels/qsa_merge_daily_parity.cpp(+49 -6)📄 Description
What
This change adds an opt-in variant of the batched QSA decode attention.
STRATA_QSA_ATTN_VARIANT=2splits the selected cells into 32-cell chunks instead of 64.The merge pass reads the matching chunk count.
The default path does not change: same kernels, same dispatch, same bits.
Only the exact value
2enables the variant.Why
At long context the chunk kernel launches too few blocks to fill a large GPU.
Half-size chunks double the number of blocks and keep more of the GPU busy.
Measured with a kernel micro-benchmark on an AMD Radeon AI PRO R9700 (gfx1201, 64 CUs):
131,072-token context, T=4 verify window, int8 KV, one QSA layer.
That is 34 us per layer, about 0.4 ms per decode window over the 12 QSA layers of Qwen3.8-Flash-Next.
We run it in production on an R9700 + Ryzen AI Max+ 395 box, together with other changes.
Cost
The partial-result scratch is about twice as large (
qsa_decode_attn_scratch_floatssizes it).The process reads the variable once. Set it before the first scratch query or graph capture.
Numerics
Accumulation stays in FP32. Smaller chunks change the order of the partial sums, so results can differ at the bit level.
qsa_variants_parity --variantscompares the batch call and its graph replay with the default kernel over FP16, int8, Q4_0 and K8V4 pools, masked pages, mixed widths, chunk boundaries and 1-6 queries.Tolerance:
abs(v2 - ref) <= 2e-5 + 2e-5 * abs(ref). The default control requires identical bits.Results on this branch (v0.2.7 + this change):
The variant-2 parity on the R9700 passed on our v0.2.2-based branch with the same kernel code. On this branch the R9700 was serving production, so the larger scratch did not fit. CUDA was not built (no NVIDIA card here); the change keeps the existing CUDA guards and template instantiations.
Test
A missing GPU returns 77 (skipped).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.