[PyTorch] Enable NVFP4 row-scaled (per-token) backward for GroupedLinear - #3324
Open
cael-ling wants to merge 2 commits into
Open
[PyTorch] Enable NVFP4 row-scaled (per-token) backward for GroupedLinear#3324cael-ling wants to merge 2 commits into
cael-ling wants to merge 2 commits into
Conversation
Extend the row-scaled NVFP4 support added for dense Linear to the MoE GroupedLinear module, so the wgrad is computed in NVFP4 instead of falling back to high precision. Signed-off-by: Cael Ling <caell@nvidia.com>
for more information, see https://pre-commit.ci
Contributor
Greptile SummaryThis PR enables row-scaled NVFP4 backward computation for PyTorch
Confidence Score: 5/5The PR appears safe to merge with no concrete blocking or non-blocking defects identified in the reviewed changes. The grouped path consistently delegates row-scaled operands to existing dense kernels, while the cast allocation changes provide the corresponding per-column amax shape and the tests compare all resulting outputs and gradients bit-for-bit. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[GroupedLinear backward] --> B[Row-scaled NVFP4 activation]
B --> C{Grouped GEMM wrapper}
C --> D[Per-expert general_gemm loop]
D --> E[Columnwise amax and transpose]
E --> F[NVFP4 weight-gradient GEMM]
F --> G[Per-expert weight gradients]
Reviews (1): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
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
Extend the row-scaled NVFP4 support added for dense Linear (originally #2931 and #3206) to the MoE GroupedLinear module, so the wgrad is computed in NVFP4 instead of falling back to high precision.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: