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

Key pad mask support for flash attention #500

Closed
MathematicalMagus opened this issue Oct 31, 2022 · 3 comments
Closed

Key pad mask support for flash attention #500

MathematicalMagus opened this issue Oct 31, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@MathematicalMagus
Copy link

❓ Questions and Help

Hello!
I noticed that FlashAttention forward supports the key_padding_mask argument, while your implementation allows only for the Causal mask. Can the key_padding_mask also (easily) be implemented in xformers?

@danthe3rd
Copy link
Contributor

Hi,

Yes it's something we plan on adding. As you mentioned, the kernels already support it, so it's more a matter of figuring out the right API for this - we're looking into pytorch's nested tensors to see if it's the right abstraction

@danthe3rd danthe3rd added the enhancement New feature or request label Nov 15, 2022
@danthe3rd
Copy link
Contributor

We just merged this support - through a special attention bias.
You can learn more on the doc website.
Note that the backward is only supported by Flash, and hence won't work on V100 or older devices or even fp32.

@zen-d
Copy link

zen-d commented Mar 6, 2023

@danthe3rd But I think it means attn_mask in https://pytorch.org/docs/stable/generated/torch.nn.MultiheadAttention.html#torch.nn.MultiheadAttention, not corresponding to key_padding_mask? correct me if I miss something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants