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

Enable Flash Attention #1065

Merged
merged 24 commits into from
Jan 14, 2025
Merged

Enable Flash Attention #1065

merged 24 commits into from
Jan 14, 2025

Conversation

jiqing-feng
Copy link
Collaborator

@jiqing-feng jiqing-feng commented Dec 12, 2024

In CPU torch 2.5 we got flash attention for prefill, it's faster than varlen attention. We also apply SDPA when no past_key_values found.

It also use fused linear on gpt2 model.

Signed-off-by: jiqing-feng <[email protected]>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@jiqing-feng jiqing-feng marked this pull request as ready for review January 13, 2025 08:07
@jiqing-feng jiqing-feng marked this pull request as draft January 13, 2025 08:07
@jiqing-feng jiqing-feng marked this pull request as ready for review January 14, 2025 04:22
@jiqing-feng jiqing-feng changed the title [WIP] Enable Real Varlen Attention Enable Real Varlen Attention Jan 14, 2025
@jiqing-feng jiqing-feng changed the title Enable Real Varlen Attention Enable Flash Attention Jan 14, 2025
@jiqing-feng
Copy link
Collaborator Author

Hi @sywangyi , please review these changes. Thanks!

@jiqing-feng
Copy link
Collaborator Author

Hi @IlyasMoutawwakil. Do you mind reviewing this PR? Thanks!

Signed-off-by: jiqing-feng <[email protected]>
Signed-off-by: jiqing-feng <[email protected]>
Signed-off-by: jiqing-feng <[email protected]>
Copy link
Member

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Choose a reason for hiding this comment

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

LGTM, would love some benchmark numbers.

@IlyasMoutawwakil IlyasMoutawwakil merged commit f28aabc into huggingface:main Jan 14, 2025
22 checks passed
Signed-off-by: jiqing-feng <[email protected]>
Signed-off-by: jiqing-feng <[email protected]>
Signed-off-by: jiqing-feng <[email protected]>
@jiqing-feng
Copy link
Collaborator Author

jiqing-feng commented Jan 15, 2025

It has 20%+ speed-up for 1st token over the patched models.

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.

4 participants