Skip to content

example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3.5-Lightning-30B-A3B - #2142

Merged
yueshen2016 merged 6 commits into
mainfrom
feat/mbridge-qad-launcher-example
Aug 13, 2026
Merged

example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3.5-Lightning-30B-A3B#2142
yueshen2016 merged 6 commits into
mainfrom
feat/mbridge-qad-launcher-example

Conversation

@yueshen2016

@yueshen2016 yueshen2016 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds mbridge_qad.yaml, a launcher example running NVFP4 quantization-aware
distillation for Nemotron-3.5-Lightning-30B-A3B through the Megatron-Bridge
scripts in examples/megatron_bridge/, alongside the existing
mbridge_prune.yaml / mbridge_quantize.yaml.

megatron_lm_qad.yaml (#2146) runs the same recipe and the same data through
Megatron-LM. This is the Megatron-Bridge counterpart: the same
huggingface/models/nvidia/Nemotron-3.5-Lightning-30B-A3B-BF16/ptq/w4a16_nvfp4_4o6
recipe and the same nvidia/Nemotron-Post-Training-Dataset-v2 chat data, with the
training hyperparameters from our public-data QAD run.

Four tasks: tokenize the training data, PTQ the student, distill it against the
frozen BF16 teacher, export to unified HF.

Why the extra tokenize task

Megatron-LM's finetune path reads an HF parquet shard directly. Megatron-Bridge
trains from pre-tokenized data, so distill.py consumes Megatron .bin/.idx
via --data_paths. The chat split is therefore tokenized once with
modelopt.torch.utils.plugins.megatron_preprocess_data. --hf_streaming avoids
the Arrow cast errors this dataset's nested tool-call fields trigger in
non-streaming mode, and --append_eod is omitted because chat rows already
terminate each conversation via the chat template.

Details

  • Training topology 8 nodes x 4 GPUs, TP=1 PP=1 CP=4 EP=16 -> DP=8; gbs 64 at
    mbs 1 is 8 gradient-accumulation microbatches. 200 iters x 64 x 32768 = 419M
    training tokens.
  • PTQ runs TP=EP=PP=1 across 4 ranks (pure DP), so each rank calibrates on its own
    shard. --calib_dataset_name is left unset, selecting the default public
    cnn_nemotron_v2_mix (cnn_dailymail + Nemotron-Post-Training-Dataset-v2).
  • Export uses TP=1 (the HF writer does not gather TP shards) and PP=4, splitting
    52 layers 13/stage.
  • Pins nvcr.io/nvidia/nemo:26.06 like the other mbridge_* examples.

Dependencies

Based on main; the PTQ recipe ships in #2146 (merged). No other PR required.

Nemotron-3.5-Lightning has tie_word_embeddings: false, so a correct quantized
lm_head in the exported checkpoint also depends on #2112.

Testing

The PTQ -> export -> QAD flow and these hyperparameters were run end to end on
Nemotron-3.5-Lightning (main + #2112 + #2113):

  • PTQ completed, 6660 quantizers, MTP heads retained (mtp_num_layers: 1) with
    all 278 mtp.* quantizers disabled by the recipe.
  • Export produced a unified-HF checkpoint (18487 keys, including 270 MTP tensors).
  • QAD trained with 900 quantizers through a validation pass at iteration 50.

The YAML itself is validated against the launcher's conventions
(ntasks_per_node == gpus_per_node on Slurm, single-line inline, no args
alongside inline, all <<global_vars.X>> resolve, output prefix matches
megatron_preprocess_data's naming) and by the repo's validate launcher YAML references pre-commit hook. Topology arithmetic checked: EP divides
world/(TPPP), gbs divisible by DPmbs.

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅ (new example file only)
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: N/A

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an example workflow for NVFP4 quantization-aware distillation of NVIDIA Nemotron 3.5 Lightning 30B-A3B.
    • Supports dataset tokenization, post-training quantization, teacher-student distillation, and export of a unified Hugging Face checkpoint.
    • Includes configurable model, dataset, and checkpoint paths, distributed execution settings, and support for local or Slurm-based workflows.

@yueshen2016
yueshen2016 requested a review from a team as a code owner August 11, 2026 11:15
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8a54e454-b122-4fc3-aeeb-b910473239f8

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8d0e5 and 7f838c4.

📒 Files selected for processing (1)
  • tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml

📝 Walkthrough

Walkthrough

Adds a Megatron-Bridge launcher pipeline for NVIDIA Nemotron 3.5 Lightning 30B-A3B. The pipeline preprocesses data, applies NVFP4 PTQ, performs 200-step QAD distillation, and exports a unified Hugging Face checkpoint.

Changes

Nemotron QAD pipeline

Layer / File(s) Summary
Data preparation and NVFP4 quantization
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml
Defines shared paths and launcher settings. Streams and tokenizes the gated chat dataset into Megatron .bin/.idx files. Runs four-GPU NVFP4 PTQ.
QAD distillation
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml
Runs distributed distillation from the BF16 teacher to the NVFP4 student with pre-tokenized data, parallelism settings, evaluation, logging, and checkpoint retention.
Checkpoint export
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml
Converts the distilled Megatron checkpoint to a unified Hugging Face checkpoint.

Estimated code review effort: 2 (Simple) | ~15 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PostTrainingDataset
  participant PreprocessingTask
  participant NVFP4PTQTask
  participant QADDistillationTask
  participant HuggingFaceExportTask
  PostTrainingDataset->>PreprocessingTask: chat messages
  PreprocessingTask->>NVFP4PTQTask: tokenized Megatron data
  NVFP4PTQTask->>QADDistillationTask: NVFP4 student checkpoint
  QADDistillationTask->>HuggingFaceExportTask: distilled Megatron checkpoint
  HuggingFaceExportTask->>HuggingFaceExportTask: write unified Hugging Face checkpoint
Loading

Possibly related PRs

Suggested reviewers: chenhanyu, jenchen13, shengliangxu

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the new Megatron-Bridge NVFP4 QAD launcher example and the target Nemotron model.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed The PR adds only YAML. Existing Megatron-Bridge scripts expose --trust_remote_code with argparse store_true defaults (false); no prohibited Python pattern, # nosec, or dependency was added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mbridge-qad-launcher-example

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.73%. Comparing base (a21173a) to head (cc3a8c0).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2142      +/-   ##
==========================================
- Coverage   78.74%   77.73%   -1.02%     
==========================================
  Files         522      522              
  Lines       60368    61469    +1101     
==========================================
+ Hits        47538    47781     +243     
- Misses      12830    13688     +858     
Flag Coverage Δ
regression 14.90% <ø> (+0.07%) ⬆️
unit 55.30% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yueshen2016
yueshen2016 force-pushed the feat/mbridge-qad-launcher-example branch from dc3fbba to cbb4453 Compare August 11, 2026 12:34
@yueshen2016
yueshen2016 requested a review from a team as a code owner August 11, 2026 12:34
@yueshen2016
yueshen2016 requested review from shengliangxu and removed request for a team August 11, 2026 12:34
@copy-pr-bot

copy-pr-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yueshen2016
yueshen2016 changed the base branch from feat/mbridge-sft-distillation to main August 11, 2026 12:34
@yueshen2016
yueshen2016 force-pushed the feat/mbridge-qad-launcher-example branch from cbb4453 to 98fb149 Compare August 11, 2026 12:41
# CPU-bound and long-running; it needs no GPU beyond the allocation minimum.
task_0:
inline: >-
python -m modelopt.torch.utils.plugins.megatron_preprocess_data

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxinO added a Nemotron-Cascade-2-SFT datablend yaml for QAD in #2010
Should we use that in the example here? We can pass that data blend YAML here

But if your goal is to make this quick and run in nmm-sandbox then perhaps the pt-v2 chat data you have here may be fine too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an example that will be posted on tech blog as the M-Bridge counterpart of #2146. The settings will stay the same as the megatron_lm_qad.

<<: *sc
nodes: 8

# 4) Export the distilled (still quantized) checkpoint to a deployable unified-HF checkpoint.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a lm_eval_hf.py MMLU check as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as prior response, will keep the same as megatron_lm_qad.

@yueshen2016 yueshen2016 changed the title example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3-Nano-30B-A3B example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3.5-Lightning-30B-A3B Aug 12, 2026
Adds mbridge_qad.yaml next to the existing mbridge_prune / mbridge_quantize
examples: tokenize the Nemotron-Post-Training-Dataset-v2 chat split, PTQ to
NVFP4, distill against the BF16 teacher, then export to unified HF.

Mirrors megatron_lm_qad.yaml's recipe and data through the Megatron-Bridge
scripts instead of Megatron-LM. Megatron-LM's finetune path reads an HF parquet
shard directly; Megatron-Bridge trains from pre-tokenized data, so the split is
tokenized once with megatron_preprocess_data and passed via --data_paths.

Signed-off-by: James Shen <yueshen@nvidia.com>
…ng-30B-A3B

Adds mbridge_qad.yaml: tokenize the Nemotron-Post-Training-Dataset-v2 chat
split, PTQ to NVFP4, distill against the BF16 teacher, then export to unified
HF. The Megatron-LM counterpart is megatron_lm_qad.yaml.

Megatron-LM's finetune path reads an HF parquet shard directly; Megatron-Bridge
trains from pre-tokenized data, so the split is tokenized once with
megatron_preprocess_data and passed via --data_paths.

PTQ uses the same recipe as the Megatron-LM example,
huggingface/models/nvidia/Nemotron-3.5-Lightning-30B-A3B-BF16/ptq/w4a16_nvfp4_4o6.

Signed-off-by: James Shen <yueshen@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml (1)

87-89: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Configure the multi-node torchrun rendezvous.

task_2 runs the inline command on all 32 Slurm tasks. Each task starts four torchrun workers, producing 128 workers instead of 32. Pass --nnodes, a Slurm-derived --node_rank, and a shared rendezvous endpoint. Set ntasks_per_node: 1 so one torchrun process manages the four GPUs on each node.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml`
around lines 87 - 89, Update the task_2 launcher configuration around
LAUNCH_SCRIPT to set ntasks_per_node to 1 and configure torchrun for multi-node
execution with --nnodes, a Slurm-derived --node_rank, and a shared rendezvous
endpoint; ensure one torchrun process manages all four GPUs on each node.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml`:
- Around line 87-89: Update the task_2 launcher configuration around
LAUNCH_SCRIPT to set ntasks_per_node to 1 and configure torchrun for multi-node
execution with --nnodes, a Slurm-derived --node_rank, and a shared rendezvous
endpoint; ensure one torchrun process manages all four GPUs on each node.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 71ac454b-bb87-4d6f-b7d0-212cfe5e000f

📥 Commits

Reviewing files that changed from the base of the PR and between 98fb149 and ba7f364.

📒 Files selected for processing (1)
  • tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml

@yueshen2016
yueshen2016 force-pushed the feat/mbridge-qad-launcher-example branch from ba7f364 to 031682b Compare August 12, 2026 08:04
GlobalVariables is a fixed dataclass (hf_model, hf_data, hf_local, output_dir,
draft_model), so data_dir / data_prefix / ptq_ckpt / qad_dir / export_dir were
rejected at launch with 'No parameter named ...'. Keep hf_model and output_dir
and inline the rest.

Found by running the pipeline: the validate-launcher-YAML hook checks recipe and
template paths, not global_vars names.

Signed-off-by: James Shen <yueshen@nvidia.com>
The tokenize task requested time: 08:00:00, which sbatch rejects on clusters
whose batch partition caps at 4h ('Requested time limit is invalid'). Use
04:00:00, matching the launcher's slurm_factory default.

Signed-off-by: James Shen <yueshen@nvidia.com>
A 1-GPU request is rejected on clusters that enforce a minimum GPU count per
job (QOSMinGRES -> 'Job violates accounting/QOS policy'). Ask for a full node
while keeping ntasks_per_node: 1, since the tokenizer is a single process and
multiple tasks would race writing the same output directory.

Signed-off-by: James Shen <yueshen@nvidia.com>
task_2 is the only multi-node task (8 nodes, 32 ranks). The launcher defaults
TRITON_CACHE_DIR under the shared /{title} mount, which is on Lustre; ranks race
to write and mmap the same compiled kernels there, and a stalled rank leaves the
other 31 waiting at the next expert-parallel allgather until the 600s NCCL
watchdog aborts the job ~17 minutes in, before iteration 1. Observed as
OSError: [Errno 14] Bad address on /cicd/triton-cache. With a node-local cache
the same run completes all 200 iterations.

Signed-off-by: James Shen <yueshen@nvidia.com>
@yueshen2016
yueshen2016 force-pushed the feat/mbridge-qad-launcher-example branch from c4cf4b6 to cc3a8c0 Compare August 13, 2026 00:05
@yueshen2016
yueshen2016 enabled auto-merge (squash) August 13, 2026 00:06
@yueshen2016
yueshen2016 merged commit 71b3d88 into main Aug 13, 2026
41 checks passed
@yueshen2016
yueshen2016 deleted the feat/mbridge-qad-launcher-example branch August 13, 2026 00:27
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-13 00:28 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants