Skip to content

Conversation

karthickai
Copy link
Contributor

@karthickai karthickai commented Oct 1, 2025

Stacked PRs:


Add backward pass for softmax kernel

karthickai added a commit that referenced this pull request Oct 1, 2025
stack-info: PR: #744, branch: karthickai/stack/4
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 1, 2025
@karthickai karthickai requested a review from yf225 October 1, 2025 18:41
m, n = grad_output.size()
grad_input = torch.empty_like(grad_output)

block_size_m = hl.register_block_size(m)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it is not need, I followed the implementation from softmax two pass, now I've updated the code.

karthickai added a commit that referenced this pull request Oct 1, 2025
stack-info: PR: #744, branch: karthickai/stack/4
x: torch.Tensor,
) -> torch.Tensor:
"""Softmax with forward + backward support."""
return SoftmaxFunction.apply(x) # type: ignore[no-any-return]
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you like to also add integration in benchmarks/run.py (similar to rms_norm-bwd), and test accuracy via tritonbench --metrics accuracy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

backward pass for softmax is disabled in tritonbench. I enabled it in this PR meta-pytorch/tritonbench#528 and added softmax-bwd in benchmarks/run.py

Copy link
Contributor Author

@karthickai karthickai Oct 8, 2025

Choose a reason for hiding this comment

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

HELION_USE_DEFAULT_CONFIG=1 python benchmarks/run.py --op softmax-bwd --num-inputs 3 --metrics accuracy

     (M, N)    triton_softmax-accuracy    quack-accuracy    torch_compile_softmax-accuracy    helion_softmax_tritonbench-accuracy
-----------  -------------------------  ----------------  --------------------------------  -------------------------------------
(4096, 256)                          1                 1                                 1                                      1
(4096, 384)                          1                 1                                 1                                      1
(4096, 512)                          1                 1                                 1                                      1
    average                          1                 1                                 1                                      1
HELION_USE_DEFAULT_CONFIG=1 python benchmarks/run.py --op softmax --num-inputs 3 --metrics accuracy

     (M, N)    triton_softmax-accuracy    quack-accuracy    torch_compile_softmax-accuracy    helion_softmax_tritonbench-accuracy
-----------  -------------------------  ----------------  --------------------------------  -------------------------------------
(4096, 256)                          1                 1                                 1                                      1
(4096, 384)                          1                 1                                 1                                      1
(4096, 512)                          1                 1                                 1                                      1
    average                          1                 1                                 1                                      1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update: tirtonbench softmax-bwd is landed meta-pytorch/tritonbench#528

karthickai added a commit that referenced this pull request Oct 8, 2025
stack-info: PR: #744, branch: karthickai/stack/4
stack-info: PR: #744, branch: karthickai/stack/4
@karthickai karthickai requested a review from yf225 October 10, 2025 15:41
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 Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants