-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Apply the attention mask in all decoding steps (LM inference) #2532
Merged
Conversation
This file contains 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
l-k-11235
changed the title
provide a fix for attention mask
Apply the attention mask in all decoding steps
Dec 5, 2023
… 1 - works for 'classical attention'
…ze > 1 thanks to map_state
l-k-11235
changed the title
Apply the attention mask in all decoding steps
Apply the attention mask in all decoding steps (LM inference)
Dec 14, 2023
l-k-11235
force-pushed
the
masked_attn_test
branch
from
December 15, 2023 10:21
cbee77a
to
dc34150
Compare
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.
I noticed that LLM outputs were degraded when batch_size is greater than 1 and the batch is heterogeneous in terms of example size. I think this highlights the fact that the attention mask for padding tokens needs to be applied in all decoding steps, not just the first step (at least with the left padding recently implemented).
The fix works for "classical attention", not for flash2 attention SDPA.
The quantization in the attention layer must be deactivated with batch_size > 1