hip : skip fully masked KV tiles in WMMA Flash Attention - #28943
moristeven477-ship-it wants to merge 1 commit into
Conversation
Assisted-by: Codex
|
There already is an auxiliary kernel |
This comment was marked as spam.
This comment was marked as spam.
|
According to the llama.cpp AI usage policy:
|
Assisted-by: Claude Opus 5
|
In my config ( |
Overview
Improve HIP prefill when server slots share a unified KV cache. The AMD WMMA attention path still loads K/V and performs matrix multiplication for interior tiles masked out for the current sequence, as reported in #28495.
The 19-line change skips a non-sparse AMD WMMA iteration only when every relevant mask element is exactly
-INFINITY. A finite probe takes the existing path; otherwise a cooperative full-tile check and__syncthreads_ordecide whether to skip. The outer kernel still handles sinks and partial-result fixups. Ten operator fixtures cover interior masks, an off-probe visible element, and masked queries with sinks.Credit to DanoPTT and alankila for the reproductions and diagnosis in #28495 and #14924. Vulkan already has masked-block skipping (#17186). The WMMA dispatch changes in #26419 affect whether this path is selected on RDNA3/head256.
Additional information
RX 7900 XTX, Ubuntu 24.04, ROCm 7.2.1; Qwen3.8-27B-UD-Q4_K_M with full offload and Flash Attention. Context 98,304, two unified-cache slots, 40,960 input tokens and 64 output tokens, slots 0/1/0, prompt reuse disabled. Third-request means from three independent restarts per variant, in stock/patch/patch/stock/stock/patch order:
Paired benchmark base:
41abbfd599fbdd3470fcae0a1fb6530ad8403cd7. The benefit targets shared-cache prefill. Ordinary decode stays close to stock; split KV remains faster here when the prompts fit its fixed slot capacity.Validation:
4c9233c034fc450dcf34c7c0988aebe6da5cdf1a: all 11 local CI stages passed, including 3,988 executed Flash Attention CPU-reference checks. The 10 new fixtures pass on both stock and patch.6.4117 +/- 0.12601, Q8_06.4165 +/- 0.12618(eight chunks, context 4096).llama-benchat depths 0/8192/32768, F16 perplexity, and three 40K-input requests with outputs matching the original patched run. These follow-up checks are separate from the paired benchmarks.Runtime coverage is Linux gfx1100. Concurrent controls and output variability are documented in the evidence. The skip assumes finite attention arithmetic; overflowing inputs and future asynchronous HIP loading require separate consideration.
Reproduction scripts, hashes, raw measurements, profiles, controls, and CI logs: validation artifacts. The primary archive contains paired experiments; the supplement validates the submitted base.
Requirements