mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #329] [CLOSED] hip: gfx12 (RDNA4) WMMA kernel for the int8-KV QSA prompt attention (1.26-1.35x prompt processing) #2579
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#2579
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/329
Author: @bsorensen110
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:gfx12-wmma-prompt-attn📝 Commits (2)
e591767hip: gfx12 (RDNA4) WMMA kernel for the int8-KV QSA prompt attention540d17eFree CUDA resources and destroy events📊 Changes
4 files changed (+370 additions, -5 deletions)
View changed files
📝
CMakeLists.txt(+7 -1)📝
docs/AMD_HIP.md(+8 -0)📝
src/kernels/cuda/qsa_prompt_attn.cu(+331 -2)📝
src/kernels/qsa_prompt_attn_parity.cpp(+24 -2)📄 Description
What
The int8-KV QSA prompt attention (
qsa_prompt_attn_batch) has a tensor-core kernel on CUDA (sm_80mma.sync+cp.async) that is compiled out on HIP, so AMD runs the ordered FP32 kernel. This adds the gfx12 (RDNA4: gfx1200/gfx1201) equivalent onv_wmma_f32_16x16x16_f16.Prompt processing on a Radeon AI PRO R9700 with Swift 1.5 IQ3_XXS,
--kv int8: 1.35x at 31K tokens, 1.26x at 108K. Decode is unchanged, because the change only touches the prompt path.How
Same algorithm and accuracy contract as the CUDA kernel: FP16 hi+lo split of q and p, fixed summation order across the four 64-dim groups, online softmax, V scale folded into p. The parts that differ:
lholds rowl%16,k = 8*(l/16)+i. B lanelholds columnl%16, the samek. D lanelholds columnl%16, rows8*(l/16)+i. The 12 heads fill A rows 0-11, rows 12-15 are zero.cp.asyncon gfx12. The next chunk's 16-byte loads stay in registers while the current chunk computes, and are written to the warp's own LDS slice at the next step.v_perm_b32+ xor0x64806480+ one packed subtract of 1152. Checked over all 65,536 byte pairs.__gfx1200__/__gfx1201__) and run time (gcnArchName). Every other HIP target, fp16 and K8V4 pools, andSTRATA_PROMPT_ATTN_OLD=1keep the previous kernel. The CUDA path is unchanged.qsa_prompt_attn_paritynow builds on HIP, prints SKIP where the kernel is unavailable, and is registered with ctest.Measurements
R9700 (gfx1201), ROCm nightly, Ryzen 9 9950X, default
--resident-cpu-experts. Both arms ran from one binary with only the attention kernel switched (STRATA_PROMPT_ATTN_OLD=1for "old").Synthetic parity harness, int8, 32K ctx x 2048 queries:
End to end (engine's own prefill timing,
STRATA_PREFILL_TIMING=1):The QSA attention phase fell 6.5x (6.9 s to 1.1 s at 31K, 24.7 s to 3.8 s at 108K). Every other phase stayed within about 20 ms. At 108K the QSA select phase (not touched here) is now the largest remaining QSA cost, about 29% of the prompt.
Testing
ctest: 43/43 pass on this tree (built fromv0.1.30, no other patches), with the four standard exclusions (ple_parity,platform_memory_test,expert_parity,pool_test).hip_prefill_hipblaslt_gemmskips because no gfx1201 table ships.qsa_prompt_attn_parityis among the 43.Limits
qsa_prompt_attn.hpp). I have not run a teacher-forced top-1 comparison or an old-vs-old control, so the needle result plus the parity harness are the correctness evidence here.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.