[PyTorch] Enable NVFP4 row-scaled (per-token) backward for GroupedLinear - #3324
Open
cael-ling wants to merge 3 commits into
Open
[PyTorch] Enable NVFP4 row-scaled (per-token) backward for GroupedLinear#3324cael-ling wants to merge 3 commits into
cael-ling wants to merge 3 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 SummaryThe PR enables row-scaled NVFP4 GroupedLinear backward by routing affected grouped GEMMs through dense per-expert operations and adding the required columnwise amax allocation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant GL as GroupedLinear
participant Q as NVFP4 quantization
participant GG as general_grouped_gemm
participant DG as general_gemm
participant K as CUDA kernels
GL->>Q: Quantize per-expert activations and gradients
Q->>Q: Allocate rowwise and columnwise amax metadata
GL->>GG: Submit grouped forward/dgrad/wgrad
loop Each expert
GG->>DG: Invoke dense row-scaled GEMM
DG->>K: Quantize, transpose, and multiply
K-->>DG: Expert output
end
GG-->>GL: Combined outputs and gradients
Reviews (2): Last reviewed commit: "Remove unhelpful comments" | Re-trigger Greptile |
timmoon10
reviewed
Aug 11, 2026
Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
Member
|
/te-ci |
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: