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

Small performance improvement to pallas MHA #22923

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

Rifur13
Copy link
Collaborator

@Rifur13 Rifur13 commented Aug 7, 2024

Small performance increase (and simpler code) of FlashAttention by reducing non-matmul FLOPs and data movement.

There are 2 changes:

  • Combining the softmax residuals using a logsumexp.
  • Keeping an unscaled version of the output during the forward pass.

See section 3.1.1 of the FlashAttention-2 paper for more details https://arxiv.org/pdf/2307.08691.

@Rifur13 Rifur13 requested a review from sharadmv August 7, 2024 23:28
Copy link
Collaborator

@sharadmv sharadmv left a comment

Choose a reason for hiding this comment

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

Awesome!

@google-ml-butler google-ml-butler bot added kokoro:force-run pull ready Ready for copybara import and testing labels Aug 8, 2024
@copybara-service copybara-service bot merged commit 9fbc51b into jax-ml:main Aug 8, 2024
16 checks passed
@Rifur13 Rifur13 deleted the faster branch August 28, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants