Enable relative positional embedding in flash attention · Issue #7997 · Project-MONAI/MONAI · GitHub
Skip to content

Enable relative positional embedding in flash attention #7997

Open

Description

@KumoLiu

From reading this thread:
pytorch/pytorch#96099 (comment)
It seems to me that the relative positional embedding can be integrated with scaled_dot_product_attention 's attn_mask argument. However, it can be slow as it's not taking the "fast path".

Do you think we can keep this option open for users who wants to use flash_attention and rel_pos_embedding?

Originally posted by @mingxin-zheng in #7977 (comment)

Activity

  1. vadimkantorov commented on Aug 31, 2024

    @vadimkantorov

    I would think that Dao-AILab/flash-attention#617 needs to be completed for FAv2 support for arbitrary attention bias. And then depending on actual needed relative encoding formula, maybe Dao-AILab/flash-attention#956 could be pushed

    Another way forward is trying PyTorch's flex_attention which can fuse modification of attention matrix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions