mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#3843
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/2075
Author: @imanu86
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:pr/attn-daily📝 Commits (1)
901de01QSA decode attention: PR #540's two-cells-per-step chunk kernel on every CUDA card and a bounded merge (STRATA_ATTN_DAILY=1, opt-in, bit-exact); parity harness📊 Changes
4 files changed (+663 additions, -28 deletions)
View changed files
📝
CMakeLists.txt(+11 -0)📝
include/strata/kernels/qsa_decode_attn.hpp(+12 -0)📝
src/kernels/cuda/qsa_decode_attn.cu(+222 -28)➕
src/kernels/qsa_merge_daily_parity.cpp(+418 -0)📄 Description
Title
Issue: none (an opt-in speed change, bit-exact).
Summary
STRATA_ATTN_DAILY=1(opt-in, off by default) runs the QSA layers' decode attention - the verify window's and the MTPdrafter's, single query and batch - through PR #540's chunk kernel (
attn_chunk_kernel_pre75: two cells per stepwith a 12-shuffle reduction, cell-major probabilities, V loaded four at a time) on every CUDA card, and merges the
chunks with
attn_merge_v2_kernel, a merge that skips the chunks the chunk kernel marked empty. Upstream compiles thepre75 kernel only with
STRATA_EXPERIMENTAL_SM60and picks it below sm_75; here it is compiled in every CUDA buildand selected by the variable. The output is bit for bit the default kernels' (see below). HIP is untouched.
Why
The default
attn_chunk_kernelreduces each cell with 5warp_sumshuffles per head (60 per cell pair); the pre75body does two cells per step with
reduce12(16 shuffles) and reads the V rows four at a time. nsys on an RTX 3060(stage 0 of a layer split, 131K context):
attn_chunk_kernel99.8 us a call against 46.4 us with the pre75body; the same ratio on an RTX 2080 Ti. The decode attention is ~8% of the per-row cost of a window at 131K on these
cards, so the end-to-end gain is small but free.
What changed
src/kernels/cuda/qsa_decode_attn.cu:attn_chunk_kernel_pre75<M, NC, ...>compiled in every CUDA build;daily_attn()readsSTRATA_ATTN_DAILY; the kernel choiceSTRATA_ATTN_CHUNK_SEL(M, PRE)takes it on any cardwhen set (below sm_75 in an experimental build as before).
attn_merge_v2_kernelwith the chunk-empty marks;STRATA_ATTN_MERGE_V2=0|1forces the merge alone,STRATA_ATTN_PRE75=0turns the chunk kernel off (A/B).sptsharessq's shared memory, so the kernel uses 15,872 B like the default one (68-78 registers against 37-41,256 threads a block).
include/strata/kernels/qsa_decode_attn.hpp: the selection helpers.src/kernels/qsa_merge_daily_parity.cpp(tests): memcmp of the chunk kernel and the merge against upstream's onfour KV formats, widths at the chunk borders and non-resident pages;
--benchtimes the two chunk kernels back toback. Registered as ctest
qsa_merge_daily_parity_defaultand_daily.CMakeLists.txt: the harness.Bit for bit
reduce12adds at every level the same two pairs aswarp_sum's butterfly (xor 16, 8, 4, 2, 1; float additioncommutes), the V cells fold in the same cell order with the same
fmaf, the masked cells stay excluded; the merge v2does the same
fmafin the same order and skips exactly the chunks the chunk kernel marks empty.qsa_merge_daily_parityon an RTX 2080 Ti (v0.1.43 build, tests on): 1,168 cases, 0 differ (fp16 290, int8 291, q4_0 294, k8v4 293; 21,190,308 nonzero output values), withSTRATA_ATTN_DAILYunset and=1. In the engine the greedy text and the drafter's acceptance are unchanged (deterministic131K bench, forced tokens and windows).
Measurements
RTX 2080 Ti 22 GB (sm_75) + RTX 3060 12 GB (sm_86), Windows 11, CUDA 12.6, layer split, Qwen3.8-Flash-Next IQ3_XXS,
131K context,
--kv int8.qsa_merge_daily_parity --benchon the RTX 2080 Ti (CUDA events, 200 calls per arm, B-A-B: Daily kernel, upstreamkernel, Daily kernel again; int8 KV, 32,768-cell capacity, window of n_q queries):
fp16, q4_0 and k8v4 KV show the same ratios (0.57-0.63 for the chunk kernel, 0.24-0.51 for the merge). In the engine
(nsys, RTX 3060, 131K context)
attn_chunk_kernelwent from 99.8 us to 46.4 us a call.End to end it is part of a stack that matches its reference within noise; the attention alone is ~8% of the per-row
cost, so no separate end-to-end claim is made here.
Built and started on v0.1.43 with
STRATA_ATTN_DAILY=1(RTX 2080 Ti + RTX 3060 layer split, Windows): the engine serves as before, same answer.Risks / limits
Opt-in: nothing changes with the variable unset. The kernel body is PR #540's (sskver) and the merge is Hardin22's
attn_merge_v2_kernel, both carried in this fork since 0.1.40 and credited in the source. #1888 (split attention onthe int8 mma path, sm_80+) is a different kernel and not bit-exact; the two do not overlap (this one serves Turing).
Part of a series from a public patch registry (
stack/in the fork imanu86/Strata-2080Ti).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.