Skip to content

Direct support for megatron bridge checkpoints #2054

Description

@ananthsub

Support Pretrained Megatron Checkpoints for Policy Worker Initialization

Motivation:

Today, the Megatron policy worker always requires a HuggingFace model ID or path as its starting point. On first launch, the worker converts the HF checkpoint into Megatron format using Megatron Bridge. This conversion is cached so subsequent launches skip it, but it still requires an initial on-the-fly conversion. If users already have a Megatron-Bridge format checkpoint (either from a training run or offline conversion), this one-time HF -> Megatron conversion is inefficient. Currently there is no way to skip this. The only entry point is a HuggingFace path, and the system derives all Megatron checkpoint paths internally.

Goals:

  1. Allow users to point directly at an existing Megatron checkpoint iteration directory (e.g., /path/to/checkpoints/iter_0001000/) and skip the HF-to-Megatron conversion entirely
  2. Retain model_name (HF model ID) in the config since it is still needed for the tokenizer and for the AutoBridge HF refit/export
  3. Keep the default behavior unchanged: if no Megatron checkpoint is provided, the existing HF conversion flow runs as before
  4. Cleanly separate from the training-checkpoint-resume path (weights_path), which is an orthogonal mechanism

Existing flow:

  1. Derives pretrained_path (a parent directory like ~/.cache/huggingface/nemo_rl/Qwen/Qwen2.5-1.5B) from config["model_name"]. Checks if iter_0000000/ exists there.
  2. handle_model_import() -- If checkpoint doesn't exist, runs import_model_from_hf_name() to convert HF -> Megatron and save to pretrained_path/iter_0000000/
  3. setup_model_config() -- Reads pretrained_path/iter_0000000/run_config.yaml (hardcoded) to get the TransformerConfig for model construction.
  4. _create_checkpoint_config(pretrained_path, weights_path) -- Creates Bridge's CheckpointConfig with pretrained_checkpoint=pretrained_path and load=weights_path.

Proposal:

  1. the current megatron bridge load_checkpoint API currently expects pretrained_checkpoint to be a parent directory containing tracker files like latest_train_state.pt that tell bridge which checkpoint to load from. This means its not yet supported for users to point to a specific iteration to load from without re-arranging the directory structure. We will refactor megatron bridge to also support loading from a specific checkpoint iteration directory: [checkpoint] Support pretrained_checkpoint being a path to a specific iteration directory Megatron-Bridge#2624

  2. Add pretrained_megatron_checkpoint to the MegatronConfig as an optional field
    Semantics: path to a specific Megatron checkpoint iteration directory (e.g., /mnt/checkpoints/iter_1234567/). The directory must contain run_config.yaml for Bridge's serialized model config

  3. Update validate_model_paths to read the user-provided pretrained checkpoint, if available

  4. Update setup_model_config to not use the hardcoded iteration path, and instead pass along the user-provided pretrained checkpoint

Related: #671

Activity

  1. self-assigned this
    on Mar 3, 2026
  2. added theissue type on Mar 3, 2026
  3. added
    enhancement
    on Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions