-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: FlashAttention-3 style MLA PageAttention #887
Merged
Merged
Conversation
This file contains 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
4 tasks
MasterJH5574
added a commit
that referenced
this pull request
Feb 23, 2025
This PR fixes the header include, following changes in #887.
yzh119
pushed a commit
that referenced
this pull request
Feb 23, 2025
This PR fixes the header include, following changes in #887.
This was referenced Feb 23, 2025
This was referenced Feb 24, 2025
9 tasks
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.
This PR is the followup of #804 , we implemented a FlashAttention-3 version of warp specialization pattern (splitting on head-dimension) in #804 for faster attention on Hopper GPUs. Compared to the previous version (in FA2 style), this PR did the following changes:
CTA_TILE_KV=64
andPIPE_STAGES=2
, the software pipeline algorithm would block the memory copy for next KV-Tile (both the pipe slots were be occupied), original attention do not have this issue because it has bothpipeline_k
andpipeline_v
, doubling the stages. This PR changesCTA_TILE_KV=32
andPIPE_STAGES=4
to ensure we can compute the current KV-tile while loading the next KV-Tile, when using software pipeline.o_smem
that reuses the KV slots, one KV-slot is not large enough foro_smem
so we use two KV shared memory slot for oneo_smem
, a barrier is required to guarantee the memory order.Pipeline
This figures explains our pipeline design:

Results
Benchmark result on H100 SXM3 (80GB, 3352GB/s).
This PR (fa3 template),
page_size=1
:#804 + #863 (fa2 template),
page_size=1
:The template is designed to use ampere style LDGSTS, which is prioritized for
page_size=1
(but also works for largerpage_size
). Using TMA and multicast could further improve performance forpage_size
larger than 1, we leave them for future work.