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 triton based Softmax and unit tests #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lessw2020
Copy link
Contributor

Summary:
This PR is to add a Triton based softmax, which supports both fwd and bwd as well as multi-dim inputs.
This kernel outperforms the PT native softmax in the fwd pass and thus might be favored esp. for inference situations.
fused_softmax_triton1
It's also a first opportunity to consider expanding the TorchMM offerings to include triton kernels.
Thus, I have listed this under a separate Triton directory in order to separate it from the rest of the codebase which is PyTorch base.

Test plan:
Tested it in end to end training (short run).
Added a number of unit tests which compare it directly with the torch.softmax and tests both forward and backward passes, as well as 2d and multi-dim inputs and fp32 and bf16 dtypes.

@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 Sep 26, 2023
Copy link
Contributor

@rohan-varma rohan-varma left a comment

Choose a reason for hiding this comment

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

Curious, when would users have to author this sort of performant triton-based softmax, versus getting these perf wins ootb with torch.compile?

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