Repository navigation
[PyTorch] Pass canonical layouts to cuDNN grouped GEMM in fused grouped MLP backward - #2
Merged
hwanseoc merged 2 commits intoOct 13, 2026
Conversation
hwanseoc
force-pushed
the
hwanseoc/canonical-grouped-mlp-backward
branch
from
October 6, 2026 23:02
b0c3d18 to
c5abc96
Compare
hwanseoc
force-pushed
the
hwanseoc/glu-canonical-layout
branch
from
October 13, 2026 00:45
b23028c to
edef648
Compare
…ed MLP backward When the cuDNN frontend dGLU wrapper advertises supports_canonical_layouts, the MXFP8 backward passes 2-D grad output, activation input, and FC1 dgrad operands, 1-D probabilities, packed scale buffers as-is, and the column-wise weights as (num_groups, k, n) with b_major="n". It consumes the 2-D dGLU outputs directly. wgrad passes flat scale buffers when the wgrad wrapper supports them. NVFP4, SReLU, and older frontends keep the existing layouts. Signed-off-by: Hwanseo Choi <hwanseoc@nvidia.com>
…MLP backward Extend the canonical-vs-legacy test to the dGLU and FC1 dgrad calls, and note the backward in the fused op docstring. Signed-off-by: Hwanseo Choi <hwanseoc@nvidia.com>
hwanseoc
force-pushed
the
hwanseoc/canonical-grouped-mlp-backward
branch
from
October 13, 2026 01:52
c5abc96 to
756f427
Compare
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.
Description
The backward counterpart of NVIDIA#3641: pass operands to the cuDNN frontend grouped dGLU, dgrad (quant), and wgrad wrappers in their natural layouts in the fused MXFP8 grouped MLP backward.
It needs a cuDNN frontend with NVIDIA/cudnn-frontend#1422 (merged) and is stacked on NVIDIA#3641. This fork PR targets the NVIDIA#3641 branch, so the diff shows only the backward change.
Type of change
Changes
dGLU: when the dGLU wrapper advertises
supports_canonical_layouts, the MXFP8 backward passes:(num_groups, k, n)withb_major="n".The 2-D dGLU outputs are used directly.
FC1 dgrad: uses the 2-D dGLU outputs, the FC1 column-wise weight with
b_major="n", and a 2-D grad input.wgrad: passes flat scale buffers when the wgrad wrapper supports them.
Unchanged: NVFP4, SReLU, and older frontends keep the existing path.
Test:
test_grouped_mlp_canonical_layouts_match_legacynow also checks the layout of every operand in the dGLU and FC1 dgrad calls, with bitwise-identical results. The fused op docstring notes the backward.Measurements
Forward + backward host p50 per step, in µs, with the cuDNN frontend from NVIDIA/cudnn-frontend#1422:
Setup:
ScaledSwiGLU(glu_interleave_size=32).Testing
tests/pytorch/test_grouped_mlp.pywithNVTE_CUTEDSL_FUSED_GROUPED_MLP=1, rebased onmainat 459dedc: 555 passed, 4463 skipped, 2 failed. Apart from the extended test, this matchesmain. The two failures,test_single_grouped_weight_eval_preserves_columnwise_usageandtest_dprob_is_bit_exact_across_runs[scaled_swiglu-GroupedMLP_CuTeGEMMGLU], also fail onmain; the second needs a newer cuDNN frontend than the one used here.Checklist:
@coderabbitai ignore