mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2588] [CLOSED] prompt attention (HIP): gate_attn in the WMMA kernel's epilogue (opt-in STRATA_ATTN_GATE=1, the same bits) #4147
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#4147
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/2588
Author: @libratechw
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:pr/prompt-attn-gate📝 Commits (1)
b496d3fprompt attention (HIP): gate_attn in the WMMA kernel's epilogue (opt-in STRATA_ATTN_GATE=1, the same bits)📊 Changes
5 files changed (+124 additions, -13 deletions)
View changed files
📝
CMakeLists.txt(+5 -1)📝
include/strata/kernels/qsa_prompt_attn.hpp(+8 -0)📝
src/kernels/cuda/qsa_prompt_attn.cu(+60 -5)📝
src/kernels/qsa_prompt_attn_parity.cpp(+40 -3)📝
src/prefill/prefill.cpp(+11 -4)📄 Description
Title
Issue: none
Summary
On the full-attention layers' prompt path, the attention writes
attnandgate_attnthen reads it back, multiplies eachvalue by the sigmoid of its gate and writes the o-projection's FP16 input. With
STRATA_ATTN_GATE=1the HIPSTRATA_PA_FASTWMMA kernel does that in its epilogue, withgate_attn's expression, soattnis not written and readback. The bits are the same. The gain is small (+0.6% on a 32K prompt), so it is opt-in. Say if you would rather not
carry it. (It was first part of #2019, which now carries only the q-preparation fusion.)
What changed
src/kernels/cuda/qsa_prompt_attn.cu,include/strata/kernels/qsa_prompt_attn.hpp:prompt_attn_wmma_kernel<SPLIT, GATED>andqsa_prompt_attn_batch_gated, which returns false (nothing launched) whereverqsa_prompt_attn_batchwould notrun the
STRATA_PA_FASTkernel.src/prefill/prefill.cpp: withSTRATA_ATTN_GATE=1(and unrotated K/V) it takes the gated launch; otherwise theattention and
gate_attnrun as before.src/kernels/qsa_prompt_attn_parity.cpp,CMakeLists.txt: a gated check (the FP16 bits against the attention followedby
gate_attn), and an argumentgatedthat makes the exit status that check's alone; ctesthip_prompt_attn_wmma_gatedruns it withSTRATA_PA_FAST=1: 0 values differ on gfx1151.Without the switch, the WMMA attention's output hash (
hip_prompt_attn_wmma, three cases,STRATA_PA_FAST=0and=1) is296b59d2's in every run (two rounds; measured on the build that also carried the q-preparation fusion, whose attention
files are this branch's).
Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1, Linux), on
296b59d2, the branch's binary without and withSTRATA_ATTN_GATE=1,UD-Q4_K_XL,
--serve --prefill 16384 --spec 4, the section-5 switches ofdocs/STRIX_HALO.mdwithSTRATA_PF_SWITCH_MIN_T=2048andSTRATA_PF_FUSED_KQ=1, a 32K chat request, fresh servers alternating, 7 pairs: 1,243 -> 1,253 tok/s (median), the median of the pair ratios +0.6%, 7 of 7pairs faster.
The records and scripts are in libratechw/Strata@686de2e9,
2019g/.A check outside ctest (a local copy of the parity test, in the records): with an output row stride of 6,152 instead of
6,144, the gated epilogue matches attention +
gate_attnand leaves the padding untouched in the tool's three cases.Builds and tests on this branch:
hip_prompt_attn_wmma_gatedamong them), 5 skip, and the same three fail as on296b59d2(ple_parity,expert_parity,pool_test).strata_kernels,strata_prefillandstrata_mmqcompile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151,gfx1200 and gfx1201.
ple_parityfails as on296b59d2.prefill.cpp).Not run: other gfx11 / gfx12 cards, UD-IQ4_XS.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.