Skip to content

[Dev] Fix single grouped weight when enabling MXFP8 primary weight #4621

Draft
zhongbozhu wants to merge 1 commit into
NVIDIA:devfrom
zhongbozhu:dev_fix_single_weight_primary_weight_mxfp8
Draft

[Dev] Fix single grouped weight when enabling MXFP8 primary weight #4621
zhongbozhu wants to merge 1 commit into
NVIDIA:devfrom
zhongbozhu:dev_fix_single_weight_primary_weight_mxfp8

Conversation

@zhongbozhu

Copy link
Copy Markdown
Contributor

What does this PR do ?

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact the @mcore-oncall.

Issue tracking

For PRs from open-source community contributors:

  • New features: a linked issue is required. Please open a feature request and reference it here before submitting the PR.
  • Small updates (bug fixes, minor improvements): a linked issue is recommended and will accelerate the PR review process.

Linked issue:

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

Feel free to message or comment the @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"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
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, the Final Review label 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 Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

For MRs into `dev` branch The proposed review process for `dev` branch is under active discussion.

MRs are mergable after one approval by either eharper@nvidia.com or zijiey@nvidia.com.

@copy-pr-bot

copy-pr-bot Bot commented May 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

return quantized_members


def modify_grouped_tensor_underlying_storage(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is to support the following combinations

  1. single grouped weight + mxfp8 recipe + turned off fp8 param gather & reuse grad buffer
  2. single grouped weight + bf16 recipe

@zhongbozhu zhongbozhu force-pushed the dev_fix_single_weight_primary_weight_mxfp8 branch 2 times, most recently from 9623fbd to 9f6354a Compare May 8, 2026 00:59
Signed-off-by: Zhongbo Zhu <zhongboz@nvidia.com>
Connor-XY added a commit to Connor-XY/Megatron-LM that referenced this pull request May 13, 2026
Upstream dev PR NVIDIA#4621 ("Fix single grouped weight
when enabling MXFP8 primary weight") fixes a numerical bug in the
dist-optimizer's quantized-param shard path on the single-grouped-
weight storage. That fix is still on dev and overlaps with code this
PR already touches.

The buggy combo isn't exercised by this PR's tests (bf16, no fp8), so
this PR can ship without the fix — but users who set
moe_single_grouped_weight=True outside the mxfp8 recipe would silently
train on a broken numerical path. Add a __post_init__ guard that
raises early with a clear pointer to NVIDIA#4621.

Scoped to moe_single_grouped_weight only, not moe_single_grouped_bias:
the fix in NVIDIA#4621 touches only the quantized-tensor code paths in
distrib_optimizer.py and param_and_grad_buffer.py, and biases don't
enter those paths (they aren't quantized in mxfp8 training). Upstream
NVIDIA#4621's validation gates both for safety; ours is tighter because the
actual bug is weight-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant