mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5467] [Engine] q36: flash attention on mma.m16n8k16 for the prompt (fp16 K/V) #5437
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#5437
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/5467
Author: @bahooo22
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:pr-fa-mma📝 Commits (1)
04d13e7q36: FA-пилот — prompt attention на mma.m16n8k16 (fp16 K/V)📊 Changes
4 files changed (+591 additions, -0 deletions)
View changed files
➕
docs/research/fa-attention.md(+46 -0)➕
docs/research/fa-attention.ru.md(+45 -0)📝
src/qwen35/q36_engine.cu(+75 -0)➕
src/qwen35/q36_fa.cuh(+425 -0)📄 Description
Problem and result
The q36 prompt attention went through cuBLAS: about 45,000 launches on a 96k prompt and an attention-score buffer for the whole prompt; that branch cost 61.5 s of the 103.2 s prompt (super-chunk N=4). After the change the 10 attention layers of the KAT geometry run one mma kernel per layer per chunk: no score buffer, online softmax in exp2, causality as a parameter (j <= p0+i), K/V in fp16. At 96k, N=4, KAT IQ4_XS, q4_0 KV: prompt 1341.1 tok/s against 1019.1 without FA (+31.6 %), attention 61,543 -> 40,946 ms (-33 %), GDN and MoE untouched. Opt-in (STRATA_Q36_FA_LAYER, default -1 = cuBLAS) because fp16 K/V changes the summation order.
Related discussion
CUDA prompt flash attention for q36 had no dedicated issue; the nearest is the HIP analogue #3482 (Q4_0-KV prompt attention on RDNA4 matrix cores). Tracking issue: https://github.com/Niko1221/Strata/issues/5465. Design and pilot gates are in docs/research/fa-attention.md (EN/RU), included in this PR. Scope agreement requested before merge (feature, new kernel).
Approach
Validation
Passed (revision
04d13e7a, Windows 11, CUDA 13.3, sm_86, RTX 3060 Ti 8 GiB):Failed: none observed. The 8x16/Q-ldg/qdouble/qregs variants were rejected in the pilot and are not part of this PR.
Not run: HIP, SYCL, Metal; other geometries (kernel runs only for H=16, HKV=2, HD=256, sm_80+); a bit-exact comparison (impossible by design with fp16 K/V). Draft until backends are covered.
Limits
The pilot covers the KAT geometry only; another geometry keeps the cuBLAS branch. fp16 K/V means the output differs from cuBLAS in the last bits (cos 1.0, max_abs within 2e-3).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.