[GH-ISSUE #5465] [Engine] q36: flash attention for the prompt #4846

Open
opened 2026-11-07 16:29:20 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @bahooo22 on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5465

Problem: q36 prompt attention runs through cuBLAS — about 45,000 launches on a 96k prompt and a score buffer for the whole prompt; 61.5 s of the 103.2 s prompt (super-chunk N=4).
Proposal: one mma.m16n8k16 kernel per attention layer per chunk (k_fa_prefill), tile 4x32, online softmax in exp2, causality j <= p0+i, K/V in fp16; opt-in via STRATA_Q36_FA_LAYER (default -1 = cuBLAS fallback).
Environment: RTX 3060 Ti 8 GiB (sm_86), 32 GiB RAM, i7-4790K, Windows 11, CUDA 13.3; KAT IQ4_XS, 96k context, q4_0 KV, super-chunk N=4.
Tradeoff: fp16 K/V changes summation order (not bit-identical); cuBLAS stays for other geometries/KV types.
Pilot (KAT geometry H=16, HKV=2, HD=256, sm_80+): +31.6 % pp at 96k, attention 61,543 -> 40,946 ms, G1 cos 1.000000 / max_abs <= 1.2e-3.
Related: #3482 is the HIP analogue (Q4_0-KV prompt attention on RDNA4 matrix cores); a follow-up FA-q4_0 relates to #5069 (qwen35moe KV quantization).
Scope agreement requested before the PR (feature, new kernel). Carried by PR <PR_URL> (branch pr-fa-mma).

Originally created by @bahooo22 on GitHub (Nov 7, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5465 Problem: q36 prompt attention runs through cuBLAS — about 45,000 launches on a 96k prompt and a score buffer for the whole prompt; 61.5 s of the 103.2 s prompt (super-chunk N=4). Proposal: one mma.m16n8k16 kernel per attention layer per chunk (k_fa_prefill), tile 4x32, online softmax in exp2, causality j <= p0+i, K/V in fp16; opt-in via STRATA_Q36_FA_LAYER (default -1 = cuBLAS fallback). Environment: RTX 3060 Ti 8 GiB (sm_86), 32 GiB RAM, i7-4790K, Windows 11, CUDA 13.3; KAT IQ4_XS, 96k context, q4_0 KV, super-chunk N=4. Tradeoff: fp16 K/V changes summation order (not bit-identical); cuBLAS stays for other geometries/KV types. Pilot (KAT geometry H=16, HKV=2, HD=256, sm_80+): +31.6 % pp at 96k, attention 61,543 -> 40,946 ms, G1 cos 1.000000 / max_abs <= 1.2e-3. Related: #3482 is the HIP analogue (Q4_0-KV prompt attention on RDNA4 matrix cores); a follow-up FA-q4_0 relates to #5069 (qwen35moe KV quantization). Scope agreement requested before the PR (feature, new kernel). Carried by PR <PR_URL> (branch pr-fa-mma).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Add your graphics card with its VRAM, your RAM and your operating system.

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6705045576 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Add your graphics card with its VRAM, your RAM and your operating system. Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6711733055 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks, this follows the format now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4846
No description provided.