Add SM100 fused linear SwiGLU - #1340
Open
justinhh4 wants to merge 7 commits into
Open
Conversation
Unify the CuTe DSL elementwise SwiGLU implementation with a grouped-epilogue SM100 fused-linear forward path, including safe fallback dispatch, stream-aware launches, scheduler tuning, tests, and benchmarks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run each memory provider in an isolated process and report total peak PyTorch CUDA allocation, including input, one weight representation, output, and temporaries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port the grouped custom-epilogue path onto the current reusable SM100 GEMM without restoring retired FLCE row-reduction code. Use a four-stage grouped pipeline from 32K tokens upward while preserving the accepted short- and mid-M configurations.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse the helper already present on main after rebasing instead of retaining the stacked PR's duplicate definition.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
justinhh4
force-pushed
the
justinhh4/cutedsl-sm100-swiglu
branch
from
August 14, 2026 16:47
4f3b1dd to
aca58e2
Compare
Extend the existing CuTe DSL SwiGLU suite with only the new fused-linear and stream cases instead of adding a duplicate test file. Rename the specialized forward-only SM100 microbenchmark to distinguish it from the existing full SwiGLU benchmark.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the one-off fused SwiGLU benchmark in favor of the repository's existing unified CuTe DSL benchmark convention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid widening the CuTe DSL package API with fused projection helpers that have no package-level consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a unified CuTe DSL SwiGLU implementation on top of the current
mainSM100 GEMM:
LigerSiLUMulFunction;in one grouped GEMM and applies SwiGLU in the epilogue without materializing
either projection;
for unsupported architectures, dtypes, and K alignment.
This PR is rebased directly onto
main; the former dependency on #1339 hasbeen removed.
Implementation
pack_swiglu_weightsinterleaves gate/up weights in 32-row tiles so pairedaccumulator fragments are local to the same SM100 CTA.
_sm100_gemm.pywithout restoring the retired FLCE row-reduction paths.(10, 0),FP16/BF16 operands, and K divisible by 64.
torch.nn.functional.linearcalls followed by the CuTe DSL elementwisekernel.
guard and on PyTorch's active CUDA stream for both TVM-FFI and DLPack calling
paths.
B200 optimization
NCU at
M=8192, H=4096, N=14336classified the grouped kernel ascompute-bound:
A manual pipeline-stage/swizzle sweep selected:
The large-M specialization raises normalized speedup from
1.015x/0.981xat 32K/64K to
1.053x/1.052x.BF16 benchmarks
NVIDIA B200,
H=4096,N=14336, seven warmups, 21 interleaved samples.Weight packing is excluded from latency. Peak memory is measured in isolated
provider processes and includes input, one weight representation, output, and
temporary PyTorch CUDA allocations.
Correctness
suites: 301 passed, 1 skipped
fused-linear forward
fallback, arbitrary elementwise shapes, multipliers, and PyTorch/Triton parity
make checkstyle: passedValidation environment:
580.105.082.13.0.1+cu1303.7.1nvidia-cutlass-dsl4.6.0apache-tvm-ffi0.1.12Scope
src/liger_kernel/ops/cutedsl/ops/swiglu.pysrc/liger_kernel/ops/cutedsl/ops/_sm100_gemm.pytest/transformers/test_swiglu_cutedsl.py