Repository navigation
fix(megatron): make the NCCL collective timeout configurable - #4481
Conversation
f78a682 to
4b7fff4
Compare
The Megatron policy and value workers create the default process group with
`torch.distributed.init_process_group("nccl")`, and Megatron Bridge builds the
model-parallel groups with `DistributedInitConfig.distributed_timeout_minutes`
left at its default. Both are 10 minutes, and there is no config knob for either.
Dist-checkpoint save finalize and load run collectives across every rank, so a
single rank that is slow on I/O takes the whole job down. Example: a 128-rank
GRPO job with async checkpointing on a slow shared filesystem; one rank needed
10m19s to write its shard, the save-finalize collective hit the 10-minute NCCL
watchdog, and the checkpoint directory was left without its `.metadata` file.
Resuming from the previous checkpoint then timed out the same way in the load
collective and the job hung.
Add `policy.megatron_cfg.distributed_timeout_minutes` (NotRequired; omitted or
None keeps today's defaults). When set, it is passed to `init_process_group`
in `setup_distributed` (used by both the Megatron policy and value workers) and
to Bridge's `DistributedInitConfig`, which Bridge uses for the model-parallel
groups it creates. Bridge skips its own `init_process_group` because the group
already exists, so the default group's timeout has to be set by NeMo RL.
Non-positive values are rejected.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lin Jia <[email protected]>
4b7fff4 to
ab1d065
Compare
|
/ok to test ab1d065 |
terrykong
left a comment
There was a problem hiding this comment.
Thanks for this! The PR description is clear: it shows the real 128-rank failure, walks the upstream call chain line by line, and the tests cover both groups. The chain holds against the pins: setup_distributed sets the default group, and _create_megatron_config → Bridge initialize_megatron → initialize_model_parallel covers every TP/PP/DP/CP/EP group, gloo included. Fractional minutes are safe too: Megatron only uses the value in timedelta(minutes=...).
No correctness bugs. The inline comments are all small.
Before merge: CI hasn't run on this head yet. The 10 mcore tests need the Megatron unit lane (L0_Unit_Tests_Megatron_*) to be green.
PR description nit (no code change): "the signature default of 30 at L637 never applies" isn't true on the first-run HF→Megatron import. community_import.py#L247 calls Bridge's model_provider.initialize_model_parallel(seed=0), which passes no timeout, so those short-lived groups get 30 min. It only matters for values above 30, but the sentence is worth fixing.
Follow-up (not this PR): the DTensor/Automodel path calls init_process_group(backend=backend) with no timeout, so it can hit the same 10-min watchdog on a slow checkpoint save. Worth a separate issue.
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4481-nccl-timeout.html
Generated by Claude Code
Apply the configured collective timeout to policy and value replica groups. Read the required Megatron config directly and use a worker-neutral error. Document null defaults across exemplars and references, including both PPO worker configs. Decouple distributed-config test helpers and cover explicit None, fractional minutes, missing config, and replica group caching. Signed-off-by: Lin Jia <[email protected]>
|
/ok to test b5baf26 |
…failures-and-redispatch main gained #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670 since the previous merge. #4640 (rubric-mean and fixed-baseline GenRM scoring) rewrote the metric assertions in tests/unit/experience/test_rollouts.py that this branch also edits for nemo_gym_infra_redispatches: the resolution keeps main's per-key assertions and adds the redispatch count beside them, and the expected rollout_metrics dict carries both sides' new keys. test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection Carries the stack root's merge of main (8338530: #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670) forward so this head stays current with main. No conflicts; test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…xandery/gym-rollout-metrics-hook Carries the stack's merge of main (8338530: #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670) forward. #4640 (rubric-mean and fixed-baseline GenRM scoring) reports the shared GenRM fields once per group through _nemo_gym_group_metrics and skips them in both per-agent loops, which this branch had replaced with per_agent_result_metrics: the resolution keeps the helper on both paths and adds the same _SHARED_GENRM_METRICS skip inside it, so the manager no longer imports the constant. test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
Add policy.automodel_cfg.distributed_timeout_minutes (and value.automodel_cfg for PPO), the Automodel-path counterpart of megatron_cfg.distributed_timeout_minutes (NVIDIA-NeMo#4481). setup_distributed passes timeout=datetime.timedelta(minutes=...) to torch.distributed.init_process_group, so the default group and the FSDP2 / expert-parallel groups derived from it use the configured collective timeout instead of torch's 10-minute NCCL default. Unset keeps the default; non-positive values are rejected with the same message pattern as NVIDIA-NeMo#4481. On the Automodel/DTensor path the first training step JIT-compiles kernels (HybridEP / DeepEP, TileLang) and loads large MoE checkpoints; on cold nodes that keeps ranks apart for more than 10 minutes, and until now the only remedy was patching setup.py. Signed-off-by: linmuchuiyang <[email protected]>
What does this PR do?
Adds
megatron_cfg.distributed_timeout_minutesso slow checkpoint I/O can use a longer collective timeout. A reported 128-rank GRPO run spent 10m19s writing one shard; waiting ranks hitTimeout(ms)=600000, leaving the checkpoint without.metadata. Both default and model-parallel groups timed out.The setting reaches the default NCCL group, Bridge's training TP/PP/DP/CP/EP groups, and the policy/value replica groups used for data-plane broadcasts. Positive fractional minutes are supported; zero and negative values fail with a worker-neutral error. Omitted or
nullpreserves the current 10-minute NCCL/Bridge defaults.Set the value in every Megatron worker config. PPO needs both:
Exemplars and matching reference configs now document the
nulldefault. Tests cover default-group and Bridge forwarding, explicitNone, fractional values, invalid values, both replica workers, and cached-group reuse. Shared test helpers are module-level functions.Verified against Bridge
ec835530and LMb4d72b79: Bridge skips an existing default group and explicitly forwards the timeout to training groups; torch 2.13.0new_group(timeout=None)uses the backend default, so replica groups need explicit forwarding too. The temporary groups created during first-run HF→Megatron import still use LM's 30-minute signature default.Validation
--noconftestto bypass Ray session fixtures.The native Megatron unit lane must run the selected tests before merge validation is complete. The separate AutoModel/DTensor timeout follow-up is already tracked in #3624; this PR changes Megatron workers only. Related: #2229 and #2390.