Explainer for
NVIDIA-NeMo/RL #4511
(fix(sft): preserve checkpoint initialization and optimizer resume state).
Permalinks pin the PR head ef033f7, Megatron-Bridge ec83553 and Megatron-LM b4d72b7.
checkpointing.pretrained_checkpoint, and a conversion folder counted as complete if one small config file existed.load_checkpoint,
which reloads both. A Hugging Face model is first converted to Megatron's format once and cached in a folder;
later runs reuse that folder. Dotted words have a short explanation: hover or tap them.The PR makes three separate changes, one per row below:
checkpointing.pretrained_checkpoint set ignored it, with no error, and trained from the
Hugging Face weights instead. The model workers read the setting from the policy config
(setup.py L899),
and SFT v2 never copied it there. The other algorithms already do;
the PR adds the same 3 lines.
PPO and xtoken distillation still lack them (#4768).run_config.yaml existed, even when a
weight file was missing or empty. That can happen with an older conversion that was cut off, or files removed from storage.
The run reused the folder, and the gap only showed up when the weights were read.
megatron_conversion_is_complete
now checks every weight file the checkpoint lists, so such a folder is converted again. New conversions were already safe, because
they are published with one atomic rename. The check runs on every rank at startup; the review asks it to check each file once, not once per tensor.quantize_and_sync_model_params_from_main_params
again anyway. The weights come out the same, so the only effect is a slightly slower resume: one extra blocking all-gather across
data-parallel ranks. The review asks to remove it.Row 3 has no FP8 case because Bridge's own load already runs the same sync when
FP8/FP4 param gather
is on (NeMo-RL turns it on with FP8 params),
so the PR's call repeats it with the same result. And because every Megatron optimizer has the method,
_sync_model_params_from_loaded_optimizer
never walks into child optimizers.
π review comment β setup.py:2714
Where it lands: RL only. No Megatron-Bridge or Megatron-LM change: Bridge already does the resume sync. First hunk is in the PR. Second hunk is proposed in the review, not in the PR.
@@ sft_v2.py L456-L461 Β· setup_sft_v2 (in the PR) """Build the V2 cluster, TQPolicy, placement, and resume state.""" set_seed(master_config.sft.seed) + pretrained_checkpoint = master_config.checkpointing.get("pretrained_checkpoint") + if pretrained_checkpoint is not None: + master_config.policy["pretrained_checkpoint"] = pretrained_checkpoint if master_config.data.get("backend") != "energon": @@ setup.py L2714-L2716 Β· setup_model_and_optimizer (proposed β not in the PR) elif resume_checkpoint_exists and megatron_cfg.checkpoint.load_optim: - if not _force_sync_model_from_optimizer_fp32(optimizer): - _sync_model_params_from_loaded_optimizer(optimizer) + _force_sync_model_from_optimizer_fp32(optimizer) torch.distributed.barrier()
The first hunk is the same three lines that
grpo.py and
sft.py already have.
The second keeps the PR's load_optim check and drops the extra sync. With it,
_sync_model_params_from_loaded_optimizer
and its three tests can be deleted. The review also asks to check each weight file once, not once per tensor, in row 2.
π‘ review comment β community_import.py:87 review comment β test_community_import.py:277