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

Use Expand for Attention mask broadcasting instead of Concat #18159

Closed

Conversation

PatriceVignola
Copy link
Contributor

Concatenating the same tensors many times with itself doesn't scale as well as simply broadcasting it using Expand. At least for DirectML, using Expand instead of Concat improves the perf quite a bite, but I can't imagine Concat being faster than Expand in any implementation since Expand can make more assumptions (e.g. it knows it has to deal with a single tensor).

It doesn't affect the GQA path since that path completely gets rid of the mask anyway.

@PatriceVignola PatriceVignola deleted the user/pavignol/improve-attention-mask-broadcasting branch October 30, 2023 10:35
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