Skip to content

[Common/PyTorch] Grouped weighted-SwiGLU MXFP8 kernel - #3315

Open
cael-ling wants to merge 5 commits into
NVIDIA:mainfrom
cael-ling:feature/mxfp8-group-swiglu-recompute
Open

[Common/PyTorch] Grouped weighted-SwiGLU MXFP8 kernel#3315
cael-ling wants to merge 5 commits into
NVIDIA:mainfrom
cael-ling:feature/mxfp8-group-swiglu-recompute

Conversation

@cael-ling

Copy link
Copy Markdown
Contributor

Description

Add nvte_group_swiglu_quantize, which fuses the weighted SwiGLU activation with column-wise MXFP8 quantization over grouped (MoE) tensors:

saved FC1 output [T, 2F]  --(weighted SwiGLU)-->  [T, F]  --(colwise MXFP8)-->  FC2 wgrad input

weighted_swiglu(x) = ( silu(x[:, :F]) * x[:, F:] ) * prob[:, None]

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Add nvte_group_swiglu_quantize, which fuses the weighted SwiGLU
activation with columnwise MXFP8 quantization over grouped (MoE)
tensors.

Signed-off-by: Cael Ling <caell@nvidia.com>
@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Aug 4, 2026
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a grouped weighted-SwiGLU operation fused with columnwise MXFP8 quantization for MoE FC2 weight-gradient inputs.

  • Adds the Blackwell CUDA kernel, core dispatch, and public C API.
  • Exposes the operation through the PyTorch extension with input-layout and device validation.
  • Adds C++ numerical coverage and PyTorch binding tests for supported layouts, dtypes, and rejection paths.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported stride, input-device, and metadata-device issues are guarded in the new binding, while the prior current-device metadata rejection no longer exists in the shared validator.

Important Files Changed

Filename Overview
transformer_engine/common/cast/mxfp8/group_swiglu_quantize_mxfp8.cuh Implements the persistent Blackwell CUDA kernel, grouped scheduling, scale layouts, validation, and launch path for weighted SwiGLU MXFP8 quantization.
transformer_engine/pytorch/csrc/extensions/cast.cpp Adds the PyTorch binding with contiguous-storage, operand-device, grouped-metadata-device, shape, dtype, and quantizer checks.
transformer_engine/common/cast/dispatch/quantize.cuh Adds scaling-mode dispatch from the public activation entry point to the MXFP8 implementation.
tests/cpp/operator/test_cast_mxfp8_grouped_swiglu.cu Adds numerical and layout coverage across grouped shapes, input/output dtypes, compact scales, and GEMM-swizzled scales.
tests/pytorch/test_grouped_tensor.py Covers PyTorch output plumbing and rejection of incompatible dtypes and non-contiguous operand views.

Sequence Diagram

sequenceDiagram
  participant Python as PyTorch caller
  participant Binding as group_swiglu_quantize binding
  participant Core as NVTE dispatch
  participant Kernel as MXFP8 CUDA kernel
  Python->>Binding: input_2f, prob, quantizer, metadata
  Binding->>Binding: Validate layout, dtype, and device
  Binding->>Binding: Allocate grouped [T,F] output
  Binding->>Core: nvte_group_swiglu_quantize(...)
  Core->>Kernel: Dispatch weighted SwiGLU + columnwise quantization
  Kernel-->>Python: Grouped columnwise MXFP8 output
Loading

Reviews (4): Last reviewed commit: "[PyTorch] Scope the grouped metadata dev..." | Re-trigger Greptile

Comment thread transformer_engine/pytorch/csrc/extensions/cast.cpp
Comment thread transformer_engine/pytorch/csrc/extensions/cast.cpp Outdated
…tize

Signed-off-by: Cael Ling <caell@nvidia.com>
Comment thread transformer_engine/pytorch/csrc/extensions/cast.cpp
Comment thread transformer_engine/pytorch/csrc/quantizer.cpp Outdated
…ntize

Signed-off-by: Cael Ling <caell@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant