-
Notifications
You must be signed in to change notification settings - Fork 810
[Common/PyTorch] Grouped weighted-SwiGLU MXFP8 kernel #3315
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
Merged
Oleg-Goncharov
merged 20 commits into
NVIDIA:main
from
cael-ling:feature/mxfp8-group-swiglu-recompute
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5ae2ae8
[Common/PyTorch] Grouped weighted-SwiGLU MXFP8 kernel
cael-ling 2979881
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e092890
[PyTorch] Require contiguous, colocated operands in group_swiglu_quan…
cael-ling 5bfd791
[PyTorch] Require grouped metadata tensors on the current CUDA device
cael-ling 8572e3a
[PyTorch] Scope the grouped metadata device check to group_swiglu_qua…
cael-ling a5f6859
[Common/PyTorch] Rename to group_scaled_swiglu and speed up the kernel
cael-ling 0b94fcb
[PyTorch] Add a benchmark for group_scaled_swiglu
cael-ling 947761e
[Common/PyTorch] Halve the silu MUFU cost and add clamped scaled SwiGLU
cael-ling 5f1452e
[Common] Cut the clamped scaled SwiGLU ALU cost
cael-ling 8ff9917
[PyTorch] Benchmark the clamped kernel against a clamped baseline
cael-ling f0d1610
Merge branch 'main' into feature/mxfp8-group-swiglu-recompute
vthumbe1503 dc56317
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 08866bc
Update transformer_engine/pytorch/csrc/extensions/cast.cpp
vthumbe1503 ed28bf0
[Common][PyTorch] Promote the approximate SwiGLU operators to math.h
cael-ling e95cf87
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5eab1f3
Merge branch 'main' into feature/mxfp8-group-swiglu-recompute
vthumbe1503 66aa446
[PyTorch] Check the grouped scaled SwiGLU against TE's SwiGLU reference
cael-ling 37fd277
Merge branch 'main' into feature/mxfp8-group-swiglu-recompute
Oleg-Goncharov a585043
Merge branch 'main' into feature/mxfp8-group-swiglu-recompute
Oleg-Goncharov 58d0b2e
Merge branch 'main' into feature/mxfp8-group-swiglu-recompute
Oleg-Goncharov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
518 changes: 518 additions & 0 deletions
518
tests/cpp/operator/test_cast_mxfp8_grouped_scaled_swiglu.cu
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace this test with verify the exact correctness of group_scaled_swiglu and group_scaled_clamped_swiglu against a more thorough pytorch based reference implementation. Pytorch reference outputs can then be quantized and compared against the grouped_scaled_* outputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cael-ling I have updated the branch as well. Since there was a recent fix in the pytorch reference implementation of clamped swiglu present in test_fusible_ops.py. You can reuse that reference implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test_group_scaled_swiglu_matches_reference, parametrized over clamped x optimize_for_gemm. Reference is the test_fusible_ops.py one character for character, including your torch.where form from #3424, so the grouped kernel is pinned to the canonical ScaledSwiGLU / ScaledClampedQGeGLU. Each expert's reference comes from that expert's own rows and is quantized with the same quantizer instance the kernel used.