[dev] Add chunked optimizer-state and master-weight offload - #6244
Conversation
|
/claude strict-review |
Strict Review SummaryFindings: CRITICAL: 0 · IMPORTANT: 1 · SUGGESTION: 1 ScopeThis PR replaces the previous AssessmentThe implementation is careful and well-documented. I traced the areas most prone to silent-corruption bugs and found them sound:
Notable points (non-blocking)
Risk level: Low-Moderate. Large surface area, but confined to an opt-in feature path (no behavior change when the flags are off), with strong test coverage and defensive validation. |
|
/ok to test a215785 |
|
/ok to test 2c6276a |
b9f7b6b to
bcc46a5
Compare
Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com>
|
/ok to test 8bfbea0 |
Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com>
|
/ok to test 2de7461 |
What does this PR do?
The existing optimizer-state offload path restores the complete optimizer state to GPU for every optimizer step, so it does not reduce peak optimizer-update memory.
This PR replaces that implementation with chunked GPU optimizer execution backed by pinned CPU canonical storage. Selected optimizer tensor states and master weights remain on CPU between updates. Tensor states are restored, updated, and offloaded in bounded chunks, while selected master weights use one full restore window.
External optimizers remain unaware of offloading; no Transformer Engine or Emerging Optimizers changes are required.
Acknowledgements and related work
This work benefited from our collaboration with @yanring (Zijie Yan) at Periodic Labs, including design discussions and his implementation with chunked optimizer-state and master-weight offloading.
See #6544, for a complementary implementation that chunks both optimizer states and master weights.
Supported configurations
DistributedOptimizerLayerWiseDistributedOptimizerUser interface
The new options are:
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
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.