-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Vulkan Flash Attention Coopmat1 Refactor #19075
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e85961a
vulkan: use coopmat for flash attention p*v matrix multiplication
0cc4m 7c46dbf
fix P loading issue
0cc4m b58acd0
fix barrier position
0cc4m 379608f
remove reduction that is no longer needed
0cc4m 4cfc48d
move max thread reduction into loop
0cc4m b4e96f5
remove osh padding
0cc4m 1ed1f35
add bounds checks and padding
0cc4m 0bbee6d
remove unused code
0cc4m f435f34
fix shmem sizes, loop duration and accesses
0cc4m 3503133
don't overwrite Qf, add new shared psh buffer instead
0cc4m 1226ba0
add missing bounds checks
0cc4m 44cd07a
use subgroup reductions
0cc4m 3037c75
optimize
0cc4m 4b3b6a6
move bounds check, reduce barriers
0cc4m 1c40f9e
support other Bc values and other subgroup sizes
0cc4m 61745fd
remove D_split
0cc4m 74d3246
replace Of register array with shared memory Ofsh array
0cc4m e0c414d
parallelize HSV across the rowgroups
0cc4m ed11a95
go back to Of in registers, not shmem
0cc4m 9384172
vectorize sfsh
0cc4m a875cc2
don't store entire K tile in shmem
0cc4m 7d75bea
fixes
0cc4m a0c9f40
load large k tiles to shmem on Nvidia
0cc4m 1e576ba
adapt shared memory host check function to shader changes
0cc4m ef86d3a
remove Bc 32 case
0cc4m fcd3a26
remove unused variable
0cc4m 80a4ac0
fix missing mask reduction tmspsh barrier
0cc4m 92051ec
fix mask bounds check
0cc4m 32465b8
fix rowmax f16 under/overflow to inf
0cc4m 7056c66
fix flash_attn_cm2 BLOCK_SIZE preprocessor directives
0cc4m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
In #19081 I saw that the coopmat1 path is disabled due to using too much shared memory. We should set k_load_shmem to false for large enough head size (I'm not sure what the exact threshold is).
Even after that, I still see some performance dropoffs I don't understand:
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.
Good idea. I could also look into reducing Bc to 32 (and row_split to 2) again, but that is not currently working. We can look at that in a follow-up PR.