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

[Pallas] Allow setting FlashAttention's causal mask #6792

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

alanwaketan
Copy link
Collaborator

Summary:
This pull request channels the causal mask to our wrapper.

Test Plan:
PJRT_DEVICE=TPU python test/test_pallas.py -v -k test_flash_attention_wrapper_causal

v = torch.randn(3, 2, 128, 4).to("xla")

# The causal mask is turned on by default in the wrapper.
# It masks out the top right triangle of the attention matrix, therefore it speeds up the compute but also changes the output.
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you mean by also changes the output?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The output will be different from the eager attention output, which is reflected in the test.

@alanwaketan
Copy link
Collaborator Author

Thanks Jack for approving.

@alanwaketan alanwaketan merged commit de42834 into master Mar 21, 2024
18 checks passed
@alanwaketan alanwaketan deleted the alanwaketan/flash_attention_4 branch March 21, 2024 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants