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

Add nd-tensor support for triton softmax #210

Merged
merged 3 commits into from
Feb 7, 2022
Merged

Conversation

fmassa
Copy link
Contributor

@fmassa fmassa commented Feb 7, 2022

What does this PR do?

This PR generalizes xformers.triton.softmax to support tensors of more than 3 dimensions.
It does it by flattening the input so that it is 3d.

A similar patch was already added in the past so that it supports 2d tensors, so this is follows in a similar way.

I can add more tests if needed

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 7, 2022
@blefaudeux
Copy link
Contributor

blefaudeux commented Feb 7, 2022

LGTM, but could you just add one more shape here ? https://github.com/facebookresearch/xformers/blob/main/tests/test_triton_softmax.py#L24 This would cover this case, better safe than sorry :)

Copy link
Contributor

@blefaudeux blefaudeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a one liner addition, please test this case just to make sure we don't break it in the future (and forget about it)

@@ -28,6 +28,8 @@
(1, 2048, 2048),
(1, 3136, 3136),
(1, 4096, 4096),
(2, 2, 384, 384),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks !

Copy link
Contributor

@blefaudeux blefaudeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM again, happy to land it anytime

@blefaudeux blefaudeux merged commit aa6c77f into main Feb 7, 2022
@fmassa fmassa deleted the nd-triton-softmax branch February 8, 2022 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants