Skip to content

Conversation

@dabeschte
Copy link

@dabeschte dabeschte commented Jan 29, 2025

The original causal attention mask generation is very slow, especially when the tensor is created on the GPU, because it needs to make 1000s of calls.

I tried to compile it...which works and makes it fast too, but compilation unfortunately also takes a long time when using a long sequence length.

This implementation is ~20-70x faster depending on the sequence lengths and since it is re-created for every SDPA, this accumulates to multiple seconds per step for larger videos

@dabeschte dabeschte changed the title replaced for loop over tensor with pytorch tensor ops [causal attn mask] replaced for loop over tensor with pytorch tensor ops Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant