Repository navigation
strix-hip: 27B prefill attention: K/V via registers, V as f16 once, all-thread softmax (bit-identical, +3% at 12.5k) - #259
Merged
Conversation
…d as f16 once (bit-identical, -8..-28%) inferspark_prefill_paged_64 on gfx1151 converted every V element bf16 -> f32 -> f16 inside each P.V fragment: 256 ds_load_u16 plus ~540 VALU per KV tile per wave, for 16 WMMAs. It also loaded K and V synchronously into one shared buffer with nothing overlapping. The BF16 paged entry now sets ATLAS_STRIX_ATTN_BF16_REGKV, and its _64 kernel: - issues V's global load before Q.K^T and stores it after softmax; - issues the next tile's K load before P.V; - stores V to LDS as f16 (the same (__fp16)(float)bf16 value, computed once), so the P.V fragments are plain d16 / d16_hi loads. Every value and every summation order are unchanged, so the output is bit-identical: the harness output hash equals main's at kv 2k/8k/20k. strix kernel harness (27B geometry: 24 q / 4 kv heads, d=256, one 2048-row chunk, scattered paged BF16 KV), s117 + s118, interleaved x3, per chunk: - kv 2k: 6.0-6.5 ms -> 4.8-5.0 ms - kv 8k: 55-63 ms -> 43-52 ms - kv 20k: 197-213 ms -> 175-187 ms Prefetch alone is neutral, and V-f16 alone gets about half the gain. The strix-hip inferspark_prefill_paged.cu becomes a local copy of the gb10 file (it was a symlink) so the define touches no NVIDIA build. FP8 / NVFP4 / batched entries never set the gate (the register loader is BF16-only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
At BR64=64 the online softmax ran one thread per row (64 of 256), with a 32-deep serial exp chain per row per tile. Four threads per row now do the mask, the row max (order-independent) and p = sw_exp(s - m_new) for 8 columns each, the same expressions as before. One thread per row then sums p from shared memory in the original c order and updates m / l, so the output is bit-identical. The explicit masked p = 0 is kept. strix kernel bench, 27B geometry (s86): kv 2k 0.99-1.03x, 8k 1.05-1.12x, 16k 1.07-1.08x, 100% bit-equal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gfx1151 only. Changes
inferspark_prefill_paged_64for the BF16 paged entry, which is the 27B prefill attention.What changes
ds_load_u16+ ~540 VALU to d16/d16_hi loads.inferspark_prefill_paged.cubecomes a local copy of the gb10 file (it was a symlink) so the gate define touches no NVIDIA build. FP8 / NVFP4 / batched entries are unchanged.Bit-identical. The harness output hash equals main at kv 2k/8k/20k. Greedy logprob probes are IDENTICAL (dlp 0) on strix (s119, s122) and on DevLab.
Measured
Attention is 8% of a 6.6k prefill and 20% of a 20k prefill (s109/s111 rocprof), so the gain grows with context.
DevLab build of the branch: 40898966157 (success).
🤖 Generated with Claude Code