mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5014] [CLOSED] [Engine] q36: faster long prompts, decode and sampled MTP on gfx1151 #5285
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#5285
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/5014
Author: @storm-ace
Created: 11/2/2026
Status: ❌ Closed
Base:
main← Head:fix/q36-long-context-decode📝 Commits (5)
6c83169q36: decode attention reads each K / V cell once per GQA group0323b0bq36: MTP drafts for sampled requests, grouped prompt attentionfc3893aq36: flash prompt attention on WMMA, hipBLASLt rowsfdcf58edocs(q36): end-to-end numbers, the occupancy findingeb71c30q36: keep the WMMA types HIP-only, FA on by default on gfx1151 only📊 Changes
3 files changed (+556 additions, -12 deletions)
View changed files
📝
docs/QWEN36.md(+46 -0)📝
src/qwen35/q36_engine.cu(+474 -12)📝
tools/hip/gfx1151-hipblaslt-100500.txt(+36 -0)📄 Description
Problem and result
Qwen3.6-35B-A3B (UD-Q4_K_XL) as a coding-agent backend on a Strix Halo (Ryzen AI MAX+ PRO 395, Radeon 8060S, gfx1151, Windows) slowed down sharply with context: decode fell from ~30 tok/s after an 8K prompt to ~12 tok/s after 32K, a 35K-token prompt took ~110 s to read, and sampled requests (agents run at temperature > 0) never used the MTP drafts. Through the server, a ~36K-token request (prompt + 300 tokens at temperature 0.6) went from 131.8 s to 52.0 s: prompt read 323 -> 871 tok/s, decode 13.9 -> 28.5-33.2 tok/s.
Related discussion
None yet. This changes defaults of the q36 path; each change is listed below with the switch that turns it off. The CUDA build was not run and the hardware runs are from one machine (see Not run). I am happy to split it into smaller PRs or turn any part opt-in if you prefer that scope.
Approach
All in
src/qwen35/q36_engine.cu, plus table rows and docs:k_attn_part_gqa<G>).k_attn_partran one block per query head, so the 8 query heads of a KV head each read that head's whole K/V cache (8x the traffic), and each thread walked its own 1 KB K row 4 bytes at a time. One block per KV head and 256-cell chunk now computes the G heads together, K is staged in LDS tiles and loaded coalesced, and the rows of a verify window on the same chunk launch next to each other. Each head sums its cell ink_attn_part's order: bitwise equal (STRATA_Q36_VERIFY=1compares). Off:STRATA_Q36_OLD_KERNELS=1.sample_speckeeps the draft with the probability p(draft) of the distributionsample()draws from (temperature, top-k/p, min-p, penalties) and otherwise draws from that distribution without the draft: the speculative-sampling rule for a one-token draft, so the tokens keep exactly the plain sampler's distribution (not its random stream).spec_steptakes aJudgethat decides the window from the rows' logits. Off:STRATA_Q36_NO_SPEC_SAMPLE=1.q16as[kvh][t][g][HD]) instead of G narrow ones, each query slice covering only the cells its rows see. Bitwise equal on the checked prompt. Off:STRATA_Q36_ATT_OLD=1.k_attn_fa_wmma, RDNA3 / RDNA3.5v_wmma_f32_16x16x16_f16, wave32): scores, causal mask, online softmax and P V fused, no T x P score matrix. 64 grouped query rows per block, 16-cell K/V tiles in LDS (V transposed). FP16 operands, FP32 accumulation: not the GEMM path's bits (KL below). On by default only on gfx1151, where it was measured; compiled for the other gfx11 chips but only withSTRATA_Q36_FA=1(not run there). Off:STRATA_Q36_NO_FA=1.tools/hip/gfx1151-hipblaslt-100500.txtand fell back to hipBLAS (STRATA_HIPBLASLT_VERBOSE=1:launches=0 fallbacks=1250). 35 rows added (hidden 2048 shapes, T = 16..4096), calibrated withtune_hipblaslton this GPU (up to 5.6x the hipBLAS time per the tuner). Off:STRATA_HIPBLASLT_TABLE=off.STRATA_Q36_PROF=1times the prompt attention's parts and the layers by type in--bench-pp(host-side syncs; diagnostics only).docs/QWEN36.md("Long context and sampled requests") documents each change, its switch and the numbers. The FA kernel's comment documents the gfx11 fragment layout it relies on.Validation
Environment: Ryzen AI MAX+ PRO 395, Radeon 8060S (gfx1151, 16 GB carve-out + shared, 48 GB seen by Windows), Windows 11 Pro 10.0.26200, ROCm 10.2.0a20260930 (TheRock wheels via
tools/hip/build_windows.bat,STRATA_HIP_ARCHS=gfx1151), Qwen3.6-35B-A3B-UD-Q4_K_XL, every expert in VRAM,--max-context 131072, prompt chunk 4096 (auto).Passed
6c831690:STRATA_Q36_VERIFY=1 strata --native <gguf> --max-context 8192 --no-graph --mtp 0 --n 48 --tokens <2600 ids>->strata-q36 VERIFY: 22512 comparisons, 0 mismatches.0323b0ba: teacher-forced, 1,229-token real-text prompt (tools/qwen35/parity_prompts.idsrow 1 + its greedy continuation),STRATA_Q36_CHUNK=256, 32 steps,--dump-full-logits, againstSTRATA_Q36_ATT_OLD=1: KL 0, every logit equal, top-1 32/32.fc3893a1(FA + table rows) against the old path (STRATA_HIPBLASLT_TABLE=off STRATA_Q36_NO_FA=1 STRATA_Q36_ATT_OLD=1), same harness: 256-cell chunks mean KL 2.17e-6, max 1.27e-5, top-1 32/32; chunk 4096 mean KL 1.15e-6, max 9.05e-6, top-1 32/32. (For scale: the floor in this doc's KL table, llama.cpp CPU vs HIP, is 0.0019-0.056.)--bench-pp 32768 --bench-tg 0, 3 repetitions each,STRATA_Q36_PROF=1(its syncs included):c62d5e3a+ GQA decode onlyserve/server.pyof the installed Strata Control, engine from this branch), salted prompts ofq36_engine.cusource, nothing reused,max_tokens300, temperature 0.6, one request per size per build; the engine'sstrata serve: session 0: prompt ...lines:The decode after 36K varied between 33.2 and 28.5 tok/s across these runs with the same decode code; the second run came after about an hour of continuous load.
eb71c306) run through the Strata desktop app (its Qwen3.6 run config pointed at this branch's engine) and used interactively by me; answers looked right and no errors were seen. This is a manual check, not a measurement.check,metal-linkandtitlepassed.Failed: none observed.
Not run
__HIPCC__and the kernel body behind the gfx11 macros, so the CUDA build should compile the kernel's empty body, but that is unverified.--parallel> 1 and pictures were not measured with these changes.Limits
100500) on gfx1151 only, like the rest of that file.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.