[ck_tile][fmha] Gate unpadded qr_async_trload fwd instances on seqlen alignment#3747
Open
goldcoderZ wants to merge 2 commits into
Open
[ck_tile][fmha] Gate unpadded qr_async_trload fwd instances on seqlen alignment#3747goldcoderZ wants to merge 2 commits into
goldcoderZ wants to merge 2 commits into
Conversation
Contributor
Author
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.
Problem
On gfx950 the ck_tile FMHA forward dispatcher can select an unpadded
qr_async_trload(transpose-load) instance for tile-unaligned attention shapes: the two unpadded trload variants (spad=f, skpad=f) hadscheck/skcheckreturning"true"unconditionally, so the no-pad transpose-load kernel had no alignment guard. It then issues unpredicated full-tile loads/stores ofround_up(seqlen, tile)rows, over-reading Q/K/V and over-writing O/LSE past the buffer end -> "Memory access fault by GPU node-N ... Reason: Unknown" on page-terminal allocations. The regularqr_asyncpath is already safe (alwaysspad=t, gatesskpadonseqlen_k); onlyqr_async_trloadlacked the guard.Fix
Gate the unpadded
qr_async_trload/qr_async_trload_v3instances on seqlen alignment, mirroringqr_async, so they're only selected for aligned shapes; tile-unaligned shapes fall through to the paddedqr_asyncinstance.Tradeoff
Tile-unaligned shapes use the padded
qr_asynckernel instead of the transpose-load fast path. Affects only unaligned shapes; aligned shapes unchanged.Validation (gfx950 / MI350X)
Regenerated dispatcher diff touches only the unpadded
qr_async_trloadbranches (each gainsseqlen_q % bm0 == 0+seqlen_k % bn0 == 0). An unaligned shape (bf16, b=5 h=2 sq=4 sk=656 d=128, no bias) selects the paddedqr_asynckernel; output matches the reference attention to max_abs_diff ~1e-3 (bf16).