Repository navigation
fix(ckpt): initialize model parallel for builder loads - #5942
Conversation
Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
@yaoyu-33, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test dd4f9cd |
|
Light review - LGTM Minimal, well-scoped fix. The builder branch now initializes MCore model-parallel state when the caller owns only the default PyTorch process group before use_mpu_process_groups() consumes those groups. It mirrors the sibling ModelProviderMixin.initialize_model_parallel (model_provider.py:323-330), including the or-1 None-handling for CP/EP. The isinstance(model_cfg, ModelConfig) guard makes the direct TP/PP/VPP/CP/EP/expert-TP attribute access safe. Observations (non-blocking):
Test coverage is good: the new test exercises the default-PG-only scenario with a real gloo group, asserts MPU gets initialized, and cleans up in a finally block. Suggested test cases:
No perf tests impacted. |
|
/ok to test a27a605 |
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
|
/ok to test 1b5cb0b |
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
|
/ok to test 3dc48f6 |
What changed
Initialize and acquire MCore model-parallel process groups at the shared Bridge model-construction boundary in
build_and_load_model().Both supported native checkpoint paths now use the same
ProcessGroupCollection:ModelProviderMixinreceives it throughprovide_distributed_model(pg_collection=...)ModelConfig/ builder receives it throughbuild_distributed_models(...)Supported trigger and impact
A collective caller can initialize
torch.distributedand then call the documentedAutoBridge.load_megatron_model()API on a builder-backed checkpoint. Muse Glimmer makes this path supported after #5479. The load path previously treated the default process group as proof that MCore groups also existed, thenProcessGroupCollection.use_mpu_process_groups()raised before model construction or checkpoint I/O.This blocks native checkpoint load/refit/export for builder-backed models embedded in framework-owned distributed processes unless callers perform undocumented MCore initialization.
Root cause and fix
AutoBridge.load_megatron_model()skips its temporary distributed context whentorch.distributedis initialized. The builder path consumed MCore process groups directly, while the legacy provider path had its own fallback initialization.The shared helper now initializes missing MPU state from the already-normalized TP, PP, VPP, CP, EP, and expert-TP configuration, initializes the model-parallel CUDA RNG tracker when CUDA is available, and returns the MPU-backed collection. Model construction then branches only after this common setup.
Regression evidence
The tests cover:
Validation:
uv run --no-sync python -m pytest tests/unit_tests/training/test_model_load_save.py -qResult:
64 passed.uv run --no-sync pre-commit run --all-filesResult: all hooks passed.
Scope
No public API, checkpoint format, dependency, workflow, or upstream MCore changes. The standalone temporary-context path and already-initialized MPU behavior remain intact. No GPU, convergence, performance, or full-suite claims are made.