Repository navigation
Honor per-module quantization override in the fused GroupedMLP path - #8286
Open
xrennvidia wants to merge 4 commits into
Open
xrennvidia wants to merge 4 commits into
xrennvidia wants to merge 4 commits into
Conversation
svcnvidia-nemo-ci
marked this pull request as draft
October 16, 2026 06:28
Contributor
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
xrennvidia
marked this pull request as ready for review
October 16, 2026 06:28
The TE op-fuser builds its quantizers from the ambient autocast recipe, so a --te-precision-config-file override that keeps the experts quantized but with a different recipe (e.g. MXFP8 MTP experts under a global NVFP4 recipe) was ignored by the fused kernels: forward ran under NVFP4 while the module and its GTP gather were MXFP8, and backward then failed in the NVFP4 amax lookup. Enter the module's own quantization autocast around the fused call, exactly as TEGroupedLinear.forward does on the unfused path. fc1 and fc2 must carry the same override since fusion spans both. A bf16 override still disables fusion. Requires the matching Transformer Engine change that quantizes GTP-gathered BF16 weights inside the fused grouped MLP. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Xiaowei Ren <xren@nvidia.com>
xrennvidia
force-pushed
the
xren/fused_grouped_mlp_quant_override
branch
from
October 16, 2026 06:42
9a1309e to
dfb6d3a
Compare
Single-process (test_grouped_mlp.py):
* An MXFP8 override on the experts under a global NVFP4 autocast keeps
_with_fused_impl True, forms the CuTeDSL fused op, enters the module's
MXFP8 recipe inside the NVFP4 autocast (checked via FP8GlobalStateManager
and the fused op's weight quantizers), and matches a plain global-MXFP8 run
of the same weights bit-exactly in output, input grad and weight grads.
* An override matching only linear_fc2 keeps fusion on but raises at
forward, since fusion spans fc1 and fc2.
4-GPU EGTP_remat (test_moe_egtp.py):
* Quantized counterpart of the bf16-override worker: MXFP8 override on
`*mtp.layers.*`, fused weighted squared-ReLU experts, global NVFP4
autocast, egtp_remat_size 1 (control) and 2 (production repro). Asserts
the fused op formed, that it quantized with MXFP8 rather than the ambient
NVFP4, and that backward reaches main_grad.
Without the experts.py change the single-process tests fail on the missing
context, and the EGTP_remat=2 case fails the quantizer assertion (the fused op
silently inherits NVFP4). The EGTP_remat=2 case additionally needs the
Transformer Engine fix that quantizes re-gathered BF16 shards in the fused
grouped MLP; without it the backward raises AttributeError on _columnwise_data.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Xiaowei Ren <xren@nvidia.com>
…P fix The EGTP_remat=2 case re-gathers BF16 expert shards in the fused grouped MLP backward, which needs Transformer Engine to quantize them with the layer quantizer. Gate it on a capability probe for the helper that fix introduced (ops/fused/grouped_mlp.py _quantize_unquantized_weights) rather than a version check, since the fix is not tied to a TE release yet. The unsharded control and the single-process tests do not depend on it and keep running everywhere. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Xiaowei Ren <xren@nvidia.com>
yaox12
approved these changes
Oct 16, 2026
This branch has not been deployed
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.
The TE op-fuser builds its quantizers from the ambient autocast recipe, so a --te-precision-config-file override that keeps the experts quantized but with a different recipe (e.g. MXFP8 MTP experts under a global NVFP4 recipe) was ignored by the fused kernels: forward ran under NVFP4 while the module and its GTP gather were MXFP8, and backward then failed in the NVFP4 amax lookup.
Enter the module's own quantization autocast around the fused call, exactly as TEGroupedLinear.forward does on the unfused path. fc1 and fc2 must carry the same override since fusion spans both. A bf16 override still disables fusion.
Requires the matching Transformer Engine change that quantizes GTP-gathered BF16 weights inside the fused grouped MLP.
What does this PR do?
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
jit_fuser/torch.compile, CUDA extension, TE or external-library dispatch, or a scatter/index accumulation), I have added or updated its bit-exact determinism test and registered it intests/unit_tests/determinism/kernels/manifest.py(guide)Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.