nvidia/skills · Official

nemo-mbridge-mlm-bridge-training

Run Megatron-LM (MLM) and Megatron Bridge training with mock or real data. Covers correlation testing, available recipes, and multi-GPU examples.

All-time #6689 First seen May 29, 2026
8-week activity · all time api

Installation

$ npx skills add nvidia/skills --skill nemo-mbridge-mlm-bridge-training

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from nvidia/skills · top by installs.

npx skills add nvidia/skills

Browse all from nvidia/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 3.2K
License LICENSE-APACHE
Default branch main
Open issues 5
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

LicenseApache-2.0

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 6,296 B
  • docs SUMMARY.md 185 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1,800 installs

SKILL.md

MLM vs Bridge Training

For how they differ, the arg mapping tables, gotchas, and translation script, see:

  • @docs/megatron-lm-to-megatron-bridge.md

First Answer Checklist

For MLM-vs-Bridge correlation questions, always name these items up front:

  1. Bridge recipe: vanillagptpretrain_config.
  2. Bridge entry point: scripts/training/run_recipe.py.
  3. MLM entry point: 3rdparty/Megatron-LM/pretrain_gpt.py.
  4. Launch wrapper for both: uv run python -m torch.distributed.run.
  5. Fresh-run cleanup: rm -rf nemo_experiments before the Bridge run.

Also state that MLM needs PYTHONPATH=3rdparty/Megatron-LM:$PYTHONPATH, matched Bridge and MLM losses should agree within BF16 rounding, and files under 3rdparty/Megatron-LM/ should not be modified from this repo.

Correlation Testing

Use vanillagptpretrainconfig for loss-correlation testing. This recipe uses bare GPTModelProvider defaults (LayerNorm, GeLU, learnedabsolute position embeddings, vocabsize inherited from tokenizer) — matching MLM pretraingpt.py defaults with no args.

MLM Correlation Run (2L/256H, 1 GPU)

PYTHONPATH=3rdparty/Megatron-LM:$PYTHONPATH \
uv run python -m torch.distributed.run --nproc_per_node=1 \
  3rdparty/Megatron-LM/pretrain_gpt.py \
  --num-layers 2 --hidden-size 256 --num-attention-heads 4 \
  --ffn-hidden-size 1024 --seq-length 512 --max-position-embeddings 512 \
  --micro-batch-size 4 --global-batch-size 32 \
  --train-iters 10 --eval-iters 2 --eval-interval 10 \
  --mock-data --bf16 --use-mcore-models \
  --tokenizer-type NullTokenizer --vocab-size 32000 \
  --lr 3e-4 --min-lr 3e-5 --seed 1234 --log-interval 1

Bridge Correlation Run (same config, 1 GPU)

rm -rf nemo_experiments && \
uv run python -m torch.distributed.run --nproc_per_node=1 \
  scripts/training/run_recipe.py \
  --recipe vanilla_gpt_pretrain_config \
  model.num_layers=2 model.hidden_size=256 \
  model.num_attention_heads=4 model.ffn_hidden_size=1024 \
  model.seq_length=512 dataset.seq_length=512 \
  train.train_iters=10 train.global_batch_size=32 train.micro_batch_size=4 \
  validation.eval_interval=10 validation.eval_iters=2 \
  optimizer.lr=3e-4 optimizer.min_lr=3e-5 \
  scheduler.lr_warmup_iters=1 scheduler.lr_decay_iters=10 \
  rng.seed=1234 logger.log_interval=1

Verification

With matched parameters the LM losses should be nearly identical at each iteration. Compare lm loss values from both logs — they should agree to within BF16 rounding.

Multi-GPU Examples

MLM 2-GPU with TP=2

PYTHONPATH=3rdparty/Megatron-LM:$PYTHONPATH \
uv run python -m torch.distributed.run --nproc_per_node=2 \
  3rdparty/Megatron-LM/pretrain_gpt.py \
  --tensor-model-parallel-size 2 --sequence-parallel \
  --num-layers 4 --hidden-size 256 --num-attention-heads 4 \
  --seq-length 1024 --max-position-embeddings 1024 \
  --micro-batch-size 2 --global-batch-size 16 \
  --train-iters 10 --eval-iters 2 --eval-interval 10 \
  --mock-data --bf16 --use-mcore-models \
  --tokenizer-type NullTokenizer --vocab-size 1024 \
  --lr 1e-4 --log-interval 1

Bridge 2-GPU with TP=2

rm -rf nemo_experiments && \
uv run python -m torch.distributed.run --nproc_per_node=2 \
  scripts/training/run_recipe.py \
  --recipe vanilla_gpt_pretrain_config \
  model.tensor_model_parallel_size=2 model.sequence_parallel=true \
  model.num_layers=4 model.hidden_size=256 \
  model.num_attention_heads=4 model.ffn_hidden_size=1024 \
  model.seq_length=1024 dataset.seq_length=1024 \
  train.train_iters=10 train.global_batch_size=16 train.micro_batch_size=2 \
  validation.eval_interval=10 validation.eval_iters=2 \
  scheduler.lr_warmup_iters=2 scheduler.lr_decay_iters=10 \
  logger.log_interval=1

Available Recipes

Common recipes (use with --recipe):

  • vanillagptpretrain_config — Minimal GPT (bare GPTModelProvider defaults,

ideal for correlation testing and custom configs)

  • llama321bpretrain_config — Llama 3.2 1B (16L, 2048H, GBS=512, seq=8192)
  • llama38bpretrain_config — Llama 3 8B
  • qwen38bpretrain_config — Qwen3 8B
  • deepseekv2litepretrainconfig — DeepSeek-V2-Lite 16B MoE

SFT/PEFT variants use sftconfig / peftconfig suffix.

Megatron-Core Submodule

For what the submodule is and why two versions exist, see @docs/megatron-lm-to-megatron-bridge.md.

Check current version

./scripts/switch_mcore.sh status

Switch to dev for testing newer MCore features

./scripts/switch_mcore.sh dev

# uv sync (without --locked) since lockfile is for main
uv sync

Switch back to main

./scripts/switch_mcore.sh main

After pulling latest main

When you pull the latest Bridge main branch, the submodule pointer may have been updated. Re-sync the submodule:

git submodule update --init 3rdparty/Megatron-LM

Pitfalls

  1. Always rm -rf nemo_experiments before a fresh correlation run. Bridge

auto-resumes from stale checkpoints silently.

  1. uv run required: Always use uv run python -m torch.distributed.run

(not bare torchrun or python).

  1. MLM PYTHONPATH: Must include 3rdparty/Megatron-LM so gpt_builders.py

is importable.

  1. Scheduler overrides: When overriding train.train_iters to a small

value, also set scheduler.lrwarmupiters and scheduler.lrdecayiters or you get an assertion error.

  1. Use dataset.seq_length in CLI overrides for both pretraining and fine-tuning datasets.
  1. MoE OOM: Large MoE models require full activation recomputation and

typically multi-node EP. TP does NOT reduce per-GPU expert memory.

  1. uv sync --locked fails after switching to dev: The lockfile is generated

against the main MCore commit. Use uv sync (without --locked) when on dev.