Fix mxfp8 param gather numerical issue when DP overlap is off#4769
Conversation
Signed-off-by: qiyuw <qiyuw@nvidia.com>
Signed-off-by: qiyuw <qiyuw@nvidia.com>
|
I understand the cause of this bug, and I think the fix is correct. However, is there a way we can refactor the code to make it less hacky? For example, if we can pass information via function args rather than using |
Yeah I considered adding defer_param_sync to step_with_ready_grads(), but that method is part of the common MegatronOptimizer interface and is implemented by multiple optimizer wrappers. The flag is only meaningful for DistributedOptimizer’s non-overlap param-gather path. Adding this flag to the method would expand the public optimizer API for a very specific issue which I personally don't like that. |
|
/ok to test d68550d |
|
@WanZzzzzz Could you fix the CI? @Victarry Do you think we can merge this one now? |
|
/ok to test 4dc3559 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/26072551439 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/26083859497 |
What does this PR do ?
main: #4800
With MXFP8 grad-buffer reuse and non-overlap param gather, each DistOpt stages its own updated main-param shards into its param buffers during step. However, param sync is a DDP model-chunk operation: model_chunk.start_param_sync() gathers both dense and expert bucket groups, copies gathered values into model weights, and zeros the shared MXFP8 param/grad buffers. For MoE, dense and expert DistOpts may share the same model chunk, so defer param sync until all chained optimizers have staged their params, then sync each model chunk once. Otherwise the expert DistOpt may copy the zeroes into expert model weights.
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
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"
.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.
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.comorzijiey@nvidia.com.