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

Fix a small bug in the attention bias calculation when flash attention is not available #398

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tbuthfer
Copy link

Fix a small bug in the attention bias calculation when flash attention is not available.

att = F.softmax(att, dim=-1)
att = self.attn_dropout(att)
att = self.attn_dropout(att) if self.training else att
Copy link

Choose a reason for hiding this comment

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

I believe this shouldn't be necessary since nn.Dropout will not apply dropout if self.training = True.

Dropout source: https://pytorch.org/docs/stable/_modules/torch/nn/modules/dropout.html#Dropout

Which calls F.dropout:

https://pytorch.org/docs/stable/generated/torch.nn.functional.dropout.html

Notice it takes a training arg which comes from nn.Dropout's self.training state.

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