Skip to content

Commit ba75994

Browse files
authored
Merge branch 'main' into yuya/add-minimax-m25-m27-support
Signed-off-by: Yu Yao <54727607+yaoyu-33@users.noreply.github.com>
2 parents 78c9c65 + 4409992 commit ba75994

67 files changed

Lines changed: 4602 additions & 945 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.main.commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d30c3ae5469fe3f6a64d4fd2e63b6e7f7844ea81
1+
cc4cb01198875453c40cf6e3453ee3a9f88adeff

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
- [04/12/2026] [**MiniMax-M2.5 / M2.7**](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/examples/models/minimax_m2) are now supported! Both models share the same architecture as MiniMax-M2 and work with the existing bridge out of the box — checkpoint conversion and inference verified on real FP8 checkpoints.
1616

17+
- [04/10/2026] [**Qwen3-ASR**](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/examples/models/audio_lm/qwen3_asr) is now supported! Checkpoint conversion and inference for [Qwen3's ASR model](https://github.com/QwenLM/Qwen3-ASR) are available on **main**.
18+
1719
- [04/09/2026] [**Bailing MoE V2**](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/examples/models/bailing) is now supported! Checkpoint conversion and inference for the Bailing MoE V2 model are available on **main**. Thank you to [@ccclyu](https://github.com/ccclyu) for the community contribution!
1820

1921
- [04/07/2026] Megatron Bridge’s PEFT support was featured at [PyTorch Conference Europe 2026 Talk](https://pytorchconferenceeu2026.sched.com/event/2Juce/optimizing-reinforcement-learning-at-trillion-parameter-scale-songlin-jiang-aalto-university-mind-lab).
@@ -203,6 +205,7 @@ Megatron Bridge provides out-of-the-box bridges and training recipes for a wide
203205

204206
- [Qwen2 Audio](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/src/megatron/bridge/models/qwen_audio)
205207
- [Qwen2.5-Omni](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/src/megatron/bridge/models/qwen_omni)
208+
- [Qwen3-ASR](https://github.com/NVIDIA-NeMo/Megatron-Bridge/tree/main/src/megatron/bridge/models/qwen3_asr)
206209

207210
#### Launching Recipes
208211

examples/conversion/hf_megatron_roundtrip_multi_gpu.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
from megatron.bridge import AutoBridge
5454
from megatron.bridge.models.decorators import torchrun_main
5555
from megatron.bridge.models.hf_pretrained.utils import is_safe_repo
56-
from megatron.bridge.utils.common_utils import fix_gpt_oss_export_transpose, get_hf_model_type
5756

5857

5958
HF_MODEL_ID = "meta-llama/Llama-3.2-1B"
@@ -189,11 +188,7 @@ def main(
189188
all_match = True
190189
fp8_skip_count = 0
191190
fp8_skip_samples: list[str] = []
192-
# TODO: Remove fix_gpt_oss_export_transpose once GPT-OSS bridge export is fixed.
193-
weight_iter = bridge.export_hf_weights(megatron_model, show_progress=False)
194-
if get_hf_model_type(bridge) == "gpt_oss":
195-
weight_iter = fix_gpt_oss_export_transpose(weight_iter)
196-
for name, param in weight_iter:
191+
for name, param in bridge.export_hf_weights(megatron_model, show_progress=False):
197192
if is_rank_0:
198193
original_param = bridge.hf_pretrained.state[name]
199194
compare_param = param

examples/conversion/hf_to_megatron_generate_nemotron_vlm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def vlm_forward_step(data_iterator, model, **kwargs) -> torch.Tensor:
114114
def loss_func(x, **kwargs):
115115
return x
116116

117-
return model(**forward_args), loss_func
117+
output = model(**forward_args)
118+
if isinstance(output, tuple):
119+
output = output[0]
120+
return output, loss_func
118121

119122

120123
def load_image(image_path: str) -> Image.Image:
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# ==============================================================================
17+
# Qwen2-Audio 7B SFT (Supervised Fine-Tuning) Script
18+
#
19+
# Usage:
20+
# bash sft.sh
21+
#
22+
# Environment variables:
23+
# WORKSPACE — root dir for models/results (default: /workspace)
24+
# NPROC — number of GPUs per node (default: 8)
25+
# HF_MODEL — HuggingFace model path (default: Qwen/Qwen2-Audio-7B)
26+
# ==============================================================================
27+
# WORKSPACE — root dir for models/results (default: /workspace/Megatron-Bridge/examples/models/audio_lm/qwen2_audio)
28+
LOG_FILE=./qwen2_audio_7b_asr.log
29+
exec > >(tee "${LOG_FILE}") 2>&1
30+
31+
export TORCHDYNAMO_DISABLE=1
32+
33+
set -euo pipefail
34+
35+
# Workspace directory for checkpoints and results
36+
WORKSPACE=${WORKSPACE:-/workspace/Megatron-Bridge/examples/models/audio_lm/qwen2_audio}
37+
NPROC=${NPROC:-8}
38+
HF_MODEL=${HF_MODEL:-Qwen/Qwen2-Audio-7B}
39+
40+
# Before training, make sure to set WANDB_API_KEY or disable wandb logging
41+
# export WANDB_API_KEY=<your_wandb_api_key>
42+
# export WANDB_MODE=disabled
43+
44+
# Common configurations
45+
MODEL_NAME=qwen2_audio_7b
46+
MEGATRON_CKPT_DIR=${WORKSPACE}/megatron_ckpts/${MODEL_NAME}
47+
48+
# Convert HF checkpoint to Megatron format if not already done
49+
if [ ! -d "${MEGATRON_CKPT_DIR}/iter_0000000" ]; then
50+
echo "Converting HF model to Megatron format..."
51+
uv run --no-sync python examples/conversion/convert_checkpoints.py import \
52+
--hf-model ${HF_MODEL} \
53+
--megatron-path ${MEGATRON_CKPT_DIR}
54+
fi
55+
PRETRAINED_CHECKPOINT=${PRETRAINED_CHECKPOINT:-${MEGATRON_CKPT_DIR}}
56+
WANDB_PROJECT=megatron-bridge-${MODEL_NAME}
57+
58+
# Training hyperparameters
59+
SEQ_LENGTH=16384
60+
TRAIN_ITERS=11250
61+
GLOBAL_BATCH_SIZE=32
62+
MICRO_BATCH_SIZE=4
63+
EVAL_INTERVAL=1000
64+
EVAL_ITERS=10
65+
LR=2e-5
66+
MIN_LR=2e-6
67+
LR_WARMUP_ITERS=5
68+
SAVE_INTERVAL=1000
69+
LOG_INTERVAL=1
70+
71+
# TP/PP combinations: "TP,PP"
72+
PARALLELISM_CONFIGS=("1,1")
73+
74+
for par_config in "${PARALLELISM_CONFIGS[@]}"; do
75+
IFS=',' read -r TP PP <<< "$par_config"
76+
echo "============================================================"
77+
echo " run_recipe.py | TP=${TP}, PP=${PP}"
78+
echo "============================================================"
79+
uv run --no-sync python -m torch.distributed.run --nproc_per_node=${NPROC} scripts/training/run_recipe.py \
80+
--recipe qwen2_audio_7b_finetune_config \
81+
--step_func audio_lm_step \
82+
--hf_path ${HF_MODEL} \
83+
checkpoint.pretrained_checkpoint=$PRETRAINED_CHECKPOINT \
84+
checkpoint.save=${WORKSPACE}/exp/${MODEL_NAME}_sft_tp${TP}_pp${PP} \
85+
checkpoint.save_interval=$SAVE_INTERVAL \
86+
checkpoint.save_optim=False \
87+
model.seq_length=$SEQ_LENGTH \
88+
model.tensor_model_parallel_size=$TP \
89+
model.pipeline_model_parallel_size=$PP \
90+
model.freeze_language_model=false \
91+
model.freeze_audio_model=false \
92+
model.freeze_audio_projection=false \
93+
train.train_iters=$TRAIN_ITERS \
94+
train.global_batch_size=$GLOBAL_BATCH_SIZE \
95+
train.micro_batch_size=$MICRO_BATCH_SIZE \
96+
validation.eval_interval=$EVAL_INTERVAL \
97+
validation.eval_iters=$EVAL_ITERS \
98+
optimizer.lr=$LR \
99+
optimizer.min_lr=$MIN_LR \
100+
scheduler.lr_warmup_iters=$LR_WARMUP_ITERS \
101+
logger.log_interval=$LOG_INTERVAL \
102+
logger.wandb_project=$WANDB_PROJECT \
103+
logger.wandb_exp_name=${MODEL_NAME}_asr_tp${TP}_pp${PP} \
104+
dataset.maker_name=make_default_audio_dataset \
105+
"dataset.maker_kwargs.path_or_dataset=yuekai/aishell" \
106+
"dataset.maker_kwargs.subset=train" \
107+
"dataset.maker_kwargs.split=test" \
108+
"+dataset.maker_kwargs.prompt='Detect the language and recognize the speech: <|zh|>'" \
109+
"dataset.val_maker_kwargs.subset=dev" \
110+
"dataset.val_maker_kwargs.split=test" \
111+
dataset.skip_test=true \
112+
dataset.pack_sequences_in_batch=true \
113+
rng.seed=42 \
114+
ddp.grad_reduce_in_fp32=false
115+
done

scripts/performance/configs/qwen_vl/qwen3_vl_pretrain.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def set_qwen3_vl_common_configs(cfg: ConfigContainer) -> None:
7777
cfg.comm_overlap.overlap_grad_reduce = False
7878

7979

80-
def qwen3_vl_235b_a22b_pretrain_mock_config_gb300(
80+
def qwen3_vl_235b_a22b_pretrain_config_gb300(
8181
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
8282
) -> ConfigContainer:
8383
"""GB300, baseline config."""
@@ -102,7 +102,7 @@ def qwen3_vl_235b_a22b_pretrain_mock_config_gb300(
102102
return cfg
103103

104104

105-
def qwen3_vl_235b_a22b_pretrain_mock_config_gb200(
105+
def qwen3_vl_235b_a22b_pretrain_config_gb200(
106106
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
107107
) -> ConfigContainer:
108108
"""GB200, baseline config."""
@@ -127,7 +127,7 @@ def qwen3_vl_235b_a22b_pretrain_mock_config_gb200(
127127
return cfg
128128

129129

130-
def qwen3_vl_235b_a22b_pretrain_mock_config_b200(
130+
def qwen3_vl_235b_a22b_pretrain_config_b200(
131131
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
132132
) -> ConfigContainer:
133133
"""B200, baseline config."""
@@ -157,7 +157,7 @@ def qwen3_vl_235b_a22b_pretrain_mock_config_b200(
157157
return cfg
158158

159159

160-
def qwen3_vl_235b_a22b_pretrain_mock_config_h100(
160+
def qwen3_vl_235b_a22b_pretrain_config_h100(
161161
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
162162
) -> ConfigContainer:
163163
"""H100, baseline config."""
@@ -180,7 +180,7 @@ def qwen3_vl_235b_a22b_pretrain_mock_config_h100(
180180
return cfg
181181

182182

183-
def qwen3_vl_30b_a3b_pretrain_mock_config_gb300(
183+
def qwen3_vl_30b_a3b_pretrain_config_gb300(
184184
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
185185
) -> ConfigContainer:
186186
"""GB300, baseline config."""
@@ -205,7 +205,7 @@ def qwen3_vl_30b_a3b_pretrain_mock_config_gb300(
205205
return cfg
206206

207207

208-
def qwen3_vl_30b_a3b_pretrain_mock_config_gb200(
208+
def qwen3_vl_30b_a3b_pretrain_config_gb200(
209209
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
210210
) -> ConfigContainer:
211211
"""GB200, baseline config."""
@@ -230,7 +230,7 @@ def qwen3_vl_30b_a3b_pretrain_mock_config_gb200(
230230
return cfg
231231

232232

233-
def qwen3_vl_30b_a3b_pretrain_mock_config_b200(
233+
def qwen3_vl_30b_a3b_pretrain_config_b200(
234234
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
235235
) -> ConfigContainer:
236236
"""B200, baseline config."""
@@ -255,7 +255,7 @@ def qwen3_vl_30b_a3b_pretrain_mock_config_b200(
255255
return cfg
256256

257257

258-
def qwen3_vl_30b_a3b_pretrain_mock_config_h100(
258+
def qwen3_vl_30b_a3b_pretrain_config_h100(
259259
precision: str = "bf16", mock: bool = True, config_variant: str = "v1"
260260
) -> ConfigContainer:
261261
"""H100, baseline config."""

scripts/training/run_recipe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
apply_dataset_override,
119119
infer_mode_from_dataset,
120120
)
121+
from megatron.bridge.training.audio_lm_step import forward_step as audio_lm_forward_step
121122
from megatron.bridge.training.config import ConfigContainer
122123
from megatron.bridge.training.finetune import finetune
123124
from megatron.bridge.training.gpt_step import forward_step as gpt_forward_step
@@ -128,6 +129,7 @@
128129

129130

130131
STEP_FUNCTIONS: dict[str, Callable] = {
132+
"audio_lm_step": audio_lm_forward_step,
131133
"gpt_step": gpt_forward_step,
132134
"vlm_step": vlm_forward_step,
133135
"qwen3_vl_step": qwen3_vl_forward_step,

0 commit comments

Comments
 (0)