Open
Conversation
Contributor
|
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 |
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
Thanks for opening the PR!
Comment on lines
+347
to
+348
| # Copied from transformers.models.bert.modeling_bert.BertSdpaSelfAttention with Bert->Electra | ||
| class ElectraSdpaSelfAttention(ElectraSelfAttention): |
Collaborator
There was a problem hiding this comment.
hey! Would you mind updating the SDPA and non SDPA to also support flex attention?
You have an example of this in modeling_llama..py with the ATTENTION_INTERFACE!
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
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.
What does this PR do?
Towards #28005 and #37105
Adds SDPA (Scaled Dot-Product Attention) support for Google's Electra 🤗.
Sample benchmarks comparing
sdpaandeagerattention for both thegoogle/electra-base-generatorandgoogle/electra-base-discriminatormodels, under both training and inference, are provided below.Benchmarking scripts (adapted from @fxmarty's SDPA scripts) for the same, for training, inference, and execution of Electra Model on task of MaskedLM were made and are also linked below.
Electra Sdpa Benchmarking Scripts:
Electra: Benchmark Inference ScriptElectra: Benchmark Training ScriptElectra: Execution CommandsReference Sdpa Benchmarking Scripts by @fxmarty :
PS:
Memory Savings %'s remained consistent across the respective runs, butSpeed %'s varied. To ensure reliability, each benchmark (for both training and inference on both models) was run five times, and the reported results are the mean across all runs. The full set of individual run results is linked in this Benchmarking Runs gist.Benchmarks For
google/electra-base-generatorTraining Benchmark
Inference Benchmark
Benchmarks For
google/electra-base-discriminatorTraining Benchmark
Inference Benchmark
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.
@fxmarty @ArthurZucker @amyeroberts @LysandreJik