Repository navigation
feat(nemotronh): add Nemotron 3 Ultra recipes and examples #4224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b415a91
feat(nemotronh): add Nemotron 3 Ultra examples
cuichenx 2f74750
docs(nemotronh): remove Ultra day-0 setup
cuichenx 0cdae37
test(nemotronh): cover Ultra pretrain recipe
cuichenx 79094ec
fix(nemotronh): clean up Ultra mainline examples
cuichenx acd0e75
fix(model): update Nemotron Ultra example defaults
cuichenx dcb42c4
docs(model): clarify Ultra checkpoint storage defaults
cuichenx 48cbe91
fix(model): address Nemotron Ultra review feedback
cuichenx 8179720
fix(model): use validated Ultra async checkpoint strategies
cuichenx 274bb1d
Merge branch 'main' into chcui/nemotron-3-ultra-day0
cuichenx 088b9ba
docs(model): drop top-level Ultra README update
cuichenx 821deb2
fix(model): enable HybridEP dispatcher for Ultra recipes
cuichenx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Nemotron 3 Ultra | ||
|
|
||
| [Nemotron 3 Ultra](https://docs.nvidia.com/nemotron/nightly/usage-cookbook/Nemotron-3-Ultra-Base/README.html) | ||
| is a 550B total / A55B active hybrid Mamba-Transformer MoE model. | ||
|
|
||
| Megatron Bridge provides Nemotron 3 Ultra recipes and examples for | ||
| Hugging Face to Megatron conversion, inference, packed OpenMathInstruct-2 | ||
| full SFT, and packed OpenMathInstruct-2 LoRA PEFT. | ||
|
|
||
| Use the main example README for setup and scripts: | ||
| [`examples/models/nemotron/nemotron_3/ultra/README.md`](https://github.com/NVIDIA-NeMo/Megatron-Bridge/blob/main/examples/models/nemotron/nemotron_3/ultra/README.md). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| # Nemotron 3 Ultra Examples | ||
|
|
||
| This directory contains examples for Nemotron 3 Ultra conversion, inference, | ||
| DCLM pretraining, packed OpenMathInstruct-2 full SFT, and packed | ||
| OpenMathInstruct-2 LoRA PEFT. | ||
|
|
||
| Nemotron 3 Ultra is a 550B total / A55B active hybrid Mamba-Transformer MoE | ||
| model. See the | ||
| [Nemotron 3 Ultra Base model guide](https://docs.nvidia.com/nemotron/nightly/usage-cookbook/Nemotron-3-Ultra-Base/README.html) | ||
| for model details. | ||
|
|
||
| ## Workspace Configuration | ||
|
|
||
| The scripts use `WORKSPACE` as the base directory for checkpoints, packed data, | ||
| and results. Defaults: | ||
|
|
||
| ```bash | ||
| export WORKSPACE=/workspace | ||
| export MODEL_HOME=${WORKSPACE}/models/nvidia | ||
| export HF_MODEL_PATH=nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16 | ||
| export MEGATRON_MODEL_PATH=${MODEL_HOME}/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16-megatron | ||
| export PRETRAINED_CHECKPOINT=${MEGATRON_MODEL_PATH} | ||
| ``` | ||
|
|
||
| Use shared filesystems for multi-node jobs: | ||
|
|
||
| ```bash | ||
| export HF_HOME=${WORKSPACE}/cache/hf | ||
| export NEMO_HOME=${WORKSPACE}/cache/nemo | ||
| export UV_CACHE_DIR=${WORKSPACE}/cache/uv | ||
| ``` | ||
|
|
||
| The BF16 Hugging Face cache and imported Megatron checkpoint are each about | ||
| 1.1 TB. Reserve at least 2.5 TB for model storage before starting checkpoint | ||
| conversion, plus additional space for training outputs and logs. Full-model | ||
| training checkpoints can each require several TB, so set `WORKSPACE` to a | ||
| filesystem with enough quota before running SFT or pretraining. | ||
|
|
||
| ## Hardware Starting Points | ||
|
|
||
| The checked-in Slurm scripts default to 8xH100 nodes unless noted below. | ||
| When running on 4xGB200 nodes, update the `#SBATCH --nodes`, | ||
| `#SBATCH --ntasks-per-node`, `#SBATCH --gpus-per-node`, and parallelism | ||
| environment variables to the GB200 values in this table. | ||
|
|
||
| | Workflow | 8xH100 nodes | 4xGB200 nodes | | ||
| | --- | --- | --- | | ||
| | Checkpoint import | 1 node with [conversion.sh](conversion.sh), CPU import path | 6 nodes with [slurm_conversion.sh](slurm_conversion.sh), `TP=1 PP=6 EP=4` | | ||
| | Base inference | 4 nodes, `TP=1 PP=4 EP=8`, `KV_CACHE_BUFFER_SIZE_GB=4` | 3 nodes, `TP=1 PP=3 EP=4` | | ||
| | DCLM pretraining | 48 nodes, `TP=4 PP=12 EP=16`, full uniform recompute with `RECOMPUTE_GRANULARITY=full RECOMPUTE_METHOD=uniform RECOMPUTE_NUM_LAYERS=1 RECOMPUTE_MODULES=""` | 24 nodes, `TP=2 PP=3 EP=32`, selective recompute on `moe+layernorm+core_attn+moe_act+mlp+shared_experts` | | ||
| | OpenMath SFT | 48 nodes, `TP=2 PP=12 EP=16`, full uniform recompute with `RECOMPUTE_GRANULARITY=full RECOMPUTE_METHOD=uniform RECOMPUTE_NUM_LAYERS=1 RECOMPUTE_MODULES=""` | 48 nodes, `TP=2 PP=3 EP=32`, selective recompute on `moe+layernorm+core_attn+moe_act` | | ||
| | OpenMath PEFT | 4 nodes, `TP=2 PP=4 EP=8`, selective recompute on `moe+layernorm+core_attn+moe_act+mlp+shared_experts` | 4 nodes, `TP=2 PP=1 EP=16`, selective recompute on `moe+layernorm+core_attn+moe_act` | | ||
|
|
||
| These are bring-up and convergence starting points, not universal optima. | ||
| Keep `TP` within a node-local NVLink domain and scale with `PP`, `EP`, and | ||
| data parallelism when moving between hardware. For MoE sizing, the minimum GPU | ||
| count is `PP * max(TP * CP, EP * ETP)`, then additional GPUs increase dense | ||
| DP and expert DP. | ||
|
|
||
| ## Checkpoint Conversion | ||
|
|
||
| Use [conversion.sh](conversion.sh) for CPU checkpoint import when the node has | ||
| enough host RAM to materialize Nemotron 3 Ultra, for example an 8xH100 node. | ||
| This is the preferred path when available because it avoids distributed GPU | ||
| memory pressure during import. | ||
|
|
||
| ```bash | ||
| bash conversion.sh | ||
| ``` | ||
|
|
||
| Set these variables for your environment: | ||
|
|
||
| - `WORKSPACE` | ||
| - `HF_HOME` | ||
| - `UV_CACHE_DIR` | ||
| - `HF_MODEL_PATH` | ||
| - `MEGATRON_MODEL_PATH` | ||
|
|
||
| Use [slurm_conversion.sh](slurm_conversion.sh) for distributed GPU checkpoint | ||
| import when host RAM is not large enough, for example a 4xGB200 setup with less | ||
| than 1 TB of host RAM. The checked-in distributed example defaults to 6 | ||
| 8-GPU nodes with `TP=1 PP=6 EP=8`; for 4xGB200, use 6 nodes and set | ||
| `#SBATCH --ntasks-per-node=4`, `#SBATCH --gpus-per-node=4`, and | ||
| `TP=1 PP=6 EP=4`. | ||
|
|
||
| ```bash | ||
| sbatch slurm_conversion.sh | ||
| ``` | ||
|
|
||
| Set these variables for your environment: | ||
|
|
||
| - `CONTAINER_IMAGE` | ||
| - `CONTAINER_MOUNTS` | ||
| - `WORKDIR` | ||
| - `WORKSPACE` | ||
| - `HF_MODEL_PATH` | ||
| - `MEGATRON_MODEL_PATH` | ||
|
|
||
| ## Inference | ||
|
|
||
| Use [slurm_inference.sh](slurm_inference.sh) for 4-node text generation with | ||
| `TP=1 PP=4 EP=8`. The script defaults `KV_CACHE_BUFFER_SIZE_GB=4` to keep | ||
| the inference KV/context buffer within H100 memory for the default prompt | ||
| lengths. On 4xGB200 nodes, use 3 nodes with `TP=1 PP=3 EP=4`. | ||
|
|
||
| ```bash | ||
| sbatch slurm_inference.sh | ||
| ``` | ||
|
|
||
| Set `MEGATRON_MODEL_PATH` to generate from an imported Megatron checkpoint. | ||
| Leave it unset to load from the Hugging Face checkpoint path. | ||
|
|
||
| ## DCLM Pretraining | ||
|
|
||
| Use [slurm_pretrain.sh](slurm_pretrain.sh) for DCLM pretraining with | ||
| `TP=4 PP=12 EP=16` and full uniform recompute on 8xH100 nodes. On | ||
| 4xGB200 nodes, use 24 nodes with `TP=2 PP=3 EP=32`. | ||
|
|
||
| ```bash | ||
| sbatch slurm_pretrain.sh | ||
| ``` | ||
|
|
||
| Set `DCLM_DATA_DIR` to a preprocessed DCLM directory containing | ||
| `*_text_document.bin` / `*_text_document.idx` files. The script defaults to | ||
| matching `dclm_01_*_text_document.bin`. Async checkpoint saving is enabled by | ||
| the recipe; the script defaults `SAVE_INTERVAL=1000` to save one checkpoint for | ||
| the default 1000-iteration starter run. | ||
|
|
||
| ## OpenMath Packed Data | ||
|
|
||
| Pre-pack OpenMath data before training: | ||
|
|
||
| ```bash | ||
| sbatch pack_data_job.sh | ||
| ``` | ||
|
|
||
| Use the same `SEQ_LENGTH`, `HF_MODEL_PATH`, and `NEMO_HOME` for packing and | ||
| training. `NEMO_HOME` must point at a shared filesystem visible on all nodes. | ||
|
|
||
| ## Training | ||
|
|
||
| PEFT: | ||
|
|
||
| ```bash | ||
| sbatch slurm_peft.sh | ||
| ``` | ||
|
|
||
| Full SFT: | ||
|
|
||
| ```bash | ||
| sbatch slurm_sft.sh | ||
| ``` | ||
|
|
||
| The scripts default to OpenMath convergence settings: `TRAIN_ITERS=1000`, | ||
| `GLOBAL_BATCH_SIZE=128`, `SEQ_LENGTH=4096`, and `LR_WARMUP_ITERS=250`. W&B | ||
| logging is disabled by default. SFT and PEFT save at the final training | ||
| iteration by default; the SFT script removes older intermediate `iter_*` | ||
| checkpoints after a successful run to avoid retaining multiple full-model | ||
| checkpoints. | ||
|
|
||
| Current OpenMath starting points are: | ||
|
|
||
| - PEFT: 4 nodes, `TP=2 PP=4 EP=8`, selective recompute on | ||
| `moe+layernorm+core_attn+moe_act+mlp+shared_experts`. | ||
| - Full SFT: 48 nodes, `TP=2 PP=12 EP=16`, full uniform recompute with | ||
| `RECOMPUTE_GRANULARITY=full RECOMPUTE_METHOD=uniform | ||
| RECOMPUTE_NUM_LAYERS=1 RECOMPUTE_MODULES=""`. This is the current H100 | ||
| starting point for 4096-token packed OpenMath SFT. | ||
|
|
||
| For 4xGB200 nodes: | ||
|
|
||
| - PEFT: 4 nodes, `TP=2 PP=1 EP=16`, selective recompute on | ||
| `moe+layernorm+core_attn+moe_act`. | ||
| - Full SFT: 48 nodes, `TP=2 PP=3 EP=32`, selective recompute on | ||
| `moe+layernorm+core_attn+moe_act`. | ||
|
|
||
| Advanced VPP, pipeline-layout, and recompute sweeps are intentionally left out | ||
| of these starter scripts; add those overrides only for targeted performance | ||
| experiments. | ||
|
|
||
| ## W&B | ||
|
|
||
| W&B logging is disabled by default: | ||
|
|
||
| ```bash | ||
| WANDB_ENTITY=nvidia-nemo-fw-public | ||
| WANDB_PROJECT=megatron-bridge-nemotron-ultra | ||
| WANDB_MODE=disabled | ||
| ``` | ||
|
|
||
| To enable online W&B logging, set `WANDB_MODE=online` and make `WANDB_API_KEY` | ||
| visible in the submit environment. | ||
|
|
||
| Run names include model, OpenMath, mode, TP/PP/EP, recompute, and Slurm job ID. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| WORKSPACE=${WORKSPACE:-/workspace} | ||
| MODEL_HOME=${MODEL_HOME:-${WORKSPACE}/models/nvidia} | ||
| HF_MODEL_PATH=${HF_MODEL_PATH:-nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16} | ||
| MEGATRON_MODEL_PATH=${MEGATRON_MODEL_PATH:-${MODEL_HOME}/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16-megatron} | ||
|
|
||
| [ -n "${HF_HOME:-}" ] && export HF_HOME | ||
| [ -n "${UV_CACHE_DIR:-}" ] && export UV_CACHE_DIR | ||
|
|
||
| mkdir -p "$(dirname "$MEGATRON_MODEL_PATH")" | ||
|
|
||
| if [ -e "${MEGATRON_MODEL_PATH}/latest_checkpointed_iteration.txt" ] || [ -e "${MEGATRON_MODEL_PATH}/latest_train_state.pt" ]; then | ||
| echo "ERROR: target already contains a Megatron checkpoint: ${MEGATRON_MODEL_PATH}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Nemotron 3 Ultra CPU import" | ||
| echo "HF_MODEL_PATH=${HF_MODEL_PATH}" | ||
| echo "MEGATRON_MODEL_PATH=${MEGATRON_MODEL_PATH}" | ||
|
|
||
| uv run --no-sync python examples/conversion/convert_checkpoints.py import \ | ||
| --hf-model "$HF_MODEL_PATH" \ | ||
| --megatron-path "$MEGATRON_MODEL_PATH" \ | ||
| --torch-dtype bfloat16 \ | ||
| --device-map cpu |
62 changes: 62 additions & 0 deletions
62
examples/models/nemotron/nemotron_3/ultra/pack_data_job.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| #SBATCH --job-name=nemotron-ultra-pack | ||
| #SBATCH --nodes=1 | ||
| #SBATCH --ntasks-per-node=1 | ||
| #SBATCH --cpus-per-task=16 | ||
| #SBATCH --time=04:00:00 | ||
| #SBATCH --account=<your-account> | ||
| #SBATCH --partition=cpu | ||
| #SBATCH --output=logs/nemotron_ultra_pack_%j.log | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| CONTAINER_IMAGE=${CONTAINER_IMAGE:-} | ||
| CONTAINER_MOUNTS=${CONTAINER_MOUNTS:-} | ||
| WORKDIR=${WORKDIR:-/opt/Megatron-Bridge} | ||
| HF_MODEL_PATH=${HF_MODEL_PATH:-nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16} | ||
| RECIPE_NAME=${RECIPE_NAME:-nemotron_3_ultra_sft_openmathinstruct2_packed_config} | ||
| SEQ_LENGTH=${SEQ_LENGTH:-4096} | ||
|
|
||
| [ -n "${HF_HOME:-}" ] && export HF_HOME | ||
| [ -n "${NEMO_HOME:-}" ] && export NEMO_HOME | ||
| [ -n "${UV_CACHE_DIR:-}" ] && export UV_CACHE_DIR | ||
| export WORKDIR HF_MODEL_PATH RECIPE_NAME SEQ_LENGTH | ||
|
|
||
| if [ -z "$CONTAINER_IMAGE" ]; then | ||
| echo "ERROR: CONTAINER_IMAGE must be set." | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p logs | ||
|
|
||
| SRUN_CMD=(srun --mpi=pmix --container-image="${CONTAINER_IMAGE}" --no-container-mount-home) | ||
| if [ -n "$CONTAINER_MOUNTS" ]; then | ||
| SRUN_CMD+=(--container-mounts="${CONTAINER_MOUNTS}") | ||
| fi | ||
|
|
||
| "${SRUN_CMD[@]}" bash -c ' | ||
| set -euo pipefail | ||
| cd "$WORKDIR" | ||
| export PYTHONPATH="$WORKDIR/src:$WORKDIR/3rdparty/Megatron-LM:${PYTHONPATH:-}" | ||
|
|
||
| uv run --no-sync python scripts/training/pack_sft_data.py \ | ||
| --recipe "$RECIPE_NAME" \ | ||
| --seq-length "$SEQ_LENGTH" \ | ||
| --hf-path "$HF_MODEL_PATH" | ||
| ' | ||
|
|
||
| echo PACK_DATA_DONE |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.