fix(ckpt): reduce distributed optimizer resume memory - #4936
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
Light review — LGTM The
Minor observation (non-blocking): Test coverage is thorough: dtype/master-weight/state-dtype variants, incompatible distributed modes, chained optimizers, LayerWise children, TE-unavailable no-op, and rollback on exceptions during both setup and loading. Suggested test cases
|
What does this PR do ?
Prevents a transient CUDA OOM while resuming standard FP32 distributed-Adam training checkpoints by reusing Megatron-Core's already-correct optimizer-state scaffold instead of asking Transformer Engine FusedAdam to allocate a second copy.
The defect is pre-existing shared checkpoint behavior, not a regression introduced by Nemotron Omni PR #4776. That PR's near-full Omni configuration made the duplicate-state peak reproducible.
Changelog
exp_avg/exp_avg_sqstate.Root cause and measured result
During distributed checkpoint resume, MCore creates FP32 Adam moment tensors for the sharded-state scaffold. TE FusedAdam's loader allocates optimizer-owned tensors and copies those same moments, so both sets coexist before checkpoint payload I/O. In the reproducer, the unfixed process OOMed there at a 80,997 MiB whole-device peak.
The fixed run loaded the same complete 415.69 GB model/optimizer/RNG checkpoint and completed the first resumed optimizer step:
nvidia-smi, 200 ms)nvidia-smi, 200 ms)This shows the change removes the transient restore duplicate without retaining extra state into training.
Validation
14115430: 8xH100, TP8/EP8, 48/52 trainable language layers, seq4096, full nativetorch_distoptimizer/RNG resume; checkpoint load and resumed step 2 completed (0:0).14115632: 22 focused tests passed; genuine TE CUDA smoke verified incoming momentdata_ptrreuse, no measurable replacement allocation, value correctness, and loader restoration; targeted strict mypy passed (0:0).14116185: post-review validation; 25 focused tests passed, genuine TE CUDA smoke passed, and targeted strict mypy passed (0:0).uv run --active --no-sync pre-commit run --all-filesgit diff --check origin/main...HEADRuntime image: final NeMo 26.06, manifest
sha256:64fcec59b0eeee2853761d16767c603e03e0aa4ba03becc9a7793bb0c46545e7, squashfs SHA-2560dbe69a640877451d19a576628295082cc4892f405db290f4d425588f629f41a.GitHub Actions CI
This is a shared checkpoint-load path, so L1 checkpoint/training coverage is recommended. No broad CI tier was manually triggered while the PR is draft.
Before your PR is "Ready for review"
Pre checks:
Additional Information