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

Apply the attention mask in all decoding steps (LM inference) #2532

Merged
merged 18 commits into from
Dec 15, 2023

Conversation

l-k-11235
Copy link
Contributor

@l-k-11235 l-k-11235 commented Dec 4, 2023

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

@l-k-11235 l-k-11235 changed the title provide a fix for attention mask Apply the attention mask in all decoding steps Dec 5, 2023
@l-k-11235 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
@vince62s vince62s merged commit f01bea1 into OpenNMT:master Dec 15, 2023
2 checks passed
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.

2 participants