Skip to content
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

[feat] add flash attention #1762

Merged
merged 9 commits into from
Oct 26, 2022
Merged

[feat] add flash attention #1762

merged 9 commits into from
Oct 26, 2022

Conversation

oahzxl
Copy link
Contributor

@oahzxl oahzxl commented Oct 26, 2022

add cuda and triton flash attention

@oahzxl
Copy link
Contributor Author

oahzxl commented Oct 26, 2022

image

@oahzxl oahzxl changed the title Add flash attention [feat] add flash attention Oct 26, 2022
tests/test_utils/test_flash_attention.py Outdated Show resolved Hide resolved
tests/test_utils/test_flash_attention.py Outdated Show resolved Hide resolved
tests/test_utils/test_flash_attention.py Outdated Show resolved Hide resolved
tests/test_utils/test_flash_attention.py Show resolved Hide resolved
@triton.jit
def _fwd_kernel(
Q, K, V, sm_scale,
TMP, L, M, # NOTE: TMP is a scratchpad buffer to workaround a compiler bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add type hints for each parameter?
for example
TMP : torch.Tensor, L : int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about some param. Will update it with alphafold version flash attention

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@feifeibear feifeibear merged commit 25952b6 into hpcaitech:main Oct 26, 2022
@oahzxl oahzxl deleted the flashatt branch November 7, 2022 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants