-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support causal masking in FlashAttention #1947
Draft
jopperm
wants to merge
2
commits into
perf_attn
Choose a base branch
from
jopperm/causal_attn
base: perf_attn
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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
Signed-off-by: Julian Oppermann <[email protected]>
jopperm
requested review from
whitneywhtsang,
etiotto,
Dewei-Wang-sh and
a team
August 22, 2024 15:03
etiotto
reviewed
Aug 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed please post a PR against the llvm-target branch for this feature.
This was referenced Aug 27, 2024
whitneywhtsang
pushed a commit
that referenced
this pull request
Aug 30, 2024
Add support for distributing `tt.make_range` ops according to the desired warp size. This is a PoC which assumes that multiple warps are only needed along one dimension. See #1947 for more context / the complete PoC. --------- Signed-off-by: Julian Oppermann <[email protected]>
whitneywhtsang
pushed a commit
that referenced
this pull request
Sep 4, 2024
…#2013) Detect and handle flash attention with causal masking in `-convert-triton-to-tritongpu-warp` by supporting `tt.make_range` and *two* dependent attention-`for`-loops. See #1947 for more context / the complete PoC. --------- Signed-off-by: Julian Oppermann <[email protected]>
whitneywhtsang
pushed a commit
that referenced
this pull request
Sep 4, 2024
…2043) Splits `make_range` into SG-sized subranges, and handles row-vector broadcasts (e.g. `1x64 -> 16x64`) in `MatchTargetSize`. See #1947 for more context / the complete PoC. --------- Signed-off-by: Julian Oppermann <[email protected]>
Dewei-Wang-sh
pushed a commit
that referenced
this pull request
Sep 9, 2024
Support canonicalization of dependent `scf.for` loops by re-gluing individual results after the loop. See #1947 for more context / the complete PoC. --------- Signed-off-by: Julian Oppermann <[email protected]>
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.
PoC extension of the advance path to handle causal masking in FlashAttention-2.
Summary of changes:
tt.make_range
throughout all passes of the advance path.TritonToTritonGPUWarp
andMatchTargetSize
to support two dependent attention-for
-loops.tt.broadcast
of row vectors: Here, we need to select and splat a single value per thread. To that end, I needed to introduce an op for querying the lane ID in TritonGEN.The generated code passes result verification against PyTorch (both
causal=True
andcausal=False
).Remaining issues: