-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[ESM] Add flash-attention-2 backend for ESM-2 #38023
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
[ESM] Add flash-attention-2 backend for ESM-2 #38023
Conversation
Signed-off-by: Peter St. John <pstjohn@nvidia.com>
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
Tagging @ArthurZucker and @ydshieh for review. Thanks! |
Signed-off-by: Peter St. John <pstjohn@nvidia.com>
@Rocketknight1, @ArthurZucker; gentle ping for review. Thanks! |
Sorry for the delay! The changes look good, but can you add an equivalence test like |
Signed-off-by: Peter St. John <pstjohn@nvidia.com>
Added! Thanks! |
Unfortunately, those are Meta's checkpoints! We generally don't intervene in user or organization repos unless it's absolutely critical, but you can try pinging them there? |
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.
PR looks good to me now, though, so merging!
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. |
Right, that's fair. The original authors don't work there anymore though, so I expect those are abandoned 😀. I only asked because I noticed you merged similar PRs for the smaller models sizes |
What does this PR do?
Implements the flash-attention-2 attention backend for ESM-2.
ESM-2 is a BERT-based protein language model from facebook research. While the model is undoubtedly a bit old at this point - there are now ESM-3 and ESM-C models available, they remain very popular on the huggingface hub with ESM-2 3B having nearly 6M downloads last month. Despite this, there are no efficient attention backends for ESM-2 available via huggingface. There have been various drop-in replacements for ESM-2 that have been created to fill this need (FastESM, FAPLM), but a native transformers implementation should speed up a lot of workflows that currently rely on the native pytorch attention.
Addresses #26350
Related to this PR; it would be great if we could merge some of the remaining automated
safetensor
conversions for the ESM models on huggingface hub, I noticed @Rocketknight1 merged some for the other model scales previously.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.