Skip to content

How did flash-attn compute attention for cu_seqlens #850

Closed
@zigzagcai

Description

@zigzagcai

Hi,

We know that cu_seqlens is for the compute efficiency when we do training over multiple variable-length samples. And the attention mask can be calculated through cu_seqlens. We can cut the original cumulative sequence into a batch sequence and pad the empty positions with zeros. But this approach will waste training efficiency, since computing resources are consumed for meaningless padding tokens.

I am not quite familiar with the implementation details of flash-attn. So, I am just curious about where can I find the implementation or mechanism that how did flash-attn compute attention directly over cumulative sequence and get the separate results?

Thanks!

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