Explainer for NVIDIA-NeMo/RL #4481
(related: #2229).
All permalinks pin the PR head ab1d065.
megatron_cfg.distributed_timeout_minutes and applies it to the default group and to every Megatron model-parallel group.NeMo RL creates the default group itself in
setup_distributed,
with no timeout, so it gets 10 minutes. Megatron Bridge then
sees that group already exists
and skips its own setup, which was the only place its timeout setting reached the default group.
It still builds the tensor/pipeline/data-parallel groups, and
passes them
distributed_timeout_minutes, which NeMo RL never set, so they also got
10 minutes.
A small version of the reported failure (it really happened on 128 ranks): 4 ranks save a checkpoint. Rank 2 sits on a slow shared filesystem and needs 13 minutes to write its piece.
Before the PR, ranks 0, 1 and 3 hit the 10-minute watchdog while rank 2 is still writing. The job dies,
the checkpoint folder never gets its .metadata file, and resuming from the previous checkpoint
times out the same way during load. With distributed_timeout_minutes: 30 the same save
finishes at minute 13.
Where the fix lands: RL only, one function changed and one helper added, both in
setup.py,
plus the documented key in
MegatronConfig.
No Megatron Bridge change: Bridge already forwards the field to every model-parallel group.
@@ setup.py L511-L521 ยท new helper _distributed_timeout_minutes +def _distributed_timeout_minutes(config) -> Optional[float]: + """Return ``megatron_cfg.distributed_timeout_minutes``, or None when unset.""" + timeout_minutes = (config.get("megatron_cfg") or {}).get( + "distributed_timeout_minutes" + ) + if timeout_minutes is not None and timeout_minutes <= 0: + raise ValueError( + "policy.megatron_cfg.distributed_timeout_minutes must be positive, " + f"got {timeout_minutes}" + ) + return timeout_minutes @@ setup.py L532-L541 ยท setup_distributed โ the default group destroy_parallel_state() - # Initialize process group - torch.distributed.init_process_group("nccl") + # Initialize process group. Bridge skips its own init_process_group when one + # already exists, so the collective timeout of the default group (used by + # dist-checkpoint save finalize / load) has to be set here. + timeout_minutes = _distributed_timeout_minutes(config) + if timeout_minutes is None: + torch.distributed.init_process_group("nccl") + else: + torch.distributed.init_process_group( + "nccl", timeout=datetime.timedelta(minutes=timeout_minutes) + ) @@ setup.py L2131-L2136 ยท _create_megatron_config โ the model-parallel groups dist_cfg = DistributedInitConfig() + timeout_minutes = _distributed_timeout_minutes(config) + if timeout_minutes is not None: + dist_cfg.distributed_timeout_minutes = timeout_minutes
Each piece, in order:
setup_distributed passes it to the default group. Both the Megatron policy worker and the Megatron value worker go through here._create_megatron_config puts it on Bridge's config. Bridge hands it to Megatron-LM, which turns it into
timedelta(minutes=...) for every TP/PP/DP/CP/EP group. A fraction like 2.5 is fine: that is the only place the number is used.Usage, in the policy's megatron_cfg (in PPO, set it in the value's megatron_cfg too):
policy:
megatron_cfg:
distributed_timeout_minutes: 30 # leave it out to keep the 10-minute default
๐ก review comment โ policy/__init__.py:509