-
Notifications
You must be signed in to change notification settings - Fork 546
example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3.5-Lightning-30B-A3B #2142
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
example(launcher): Megatron-Bridge NVFP4 QAD launcher example for Nemotron-3.5-Lightning-30B-A3B #2142
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49fc88b
example(launcher): Megatron-Bridge NVFP4 QAD for Nemotron-3-Nano-30B-A3B
yueshen2016 031682b
example(launcher): Megatron-Bridge NVFP4 QAD for Nemotron-3.5-Lightni…
yueshen2016 73aedfc
fix(launcher): use only declared global_vars keys in mbridge_qad.yaml
yueshen2016 3e8d0e5
fix(launcher): cap the tokenize task at the 4h partition limit
yueshen2016 7f838c4
fix(launcher): request a full node for the tokenize task
yueshen2016 cc3a8c0
fix(launcher): keep the QAD Triton cache node-local
yueshen2016 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
128 changes: 128 additions & 0 deletions
128
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml
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,128 @@ | ||
| # NVIDIA Nemotron 3.5 Lightning 30B-A3B NVFP4 quantization-aware distillation (QAD) via Megatron-Bridge. | ||
| # | ||
| # Four tasks: tokenize the training data, PTQ the student to NVFP4, distill it against the BF16 | ||
| # teacher, and export a deployable unified-HF checkpoint. | ||
| # | ||
| # Training topology: 8 nodes x 4 GPUs, TP=1, PP=1, CP=4, EP=16. That leaves DP=8, so a | ||
| # global-batch-size of 64 at micro-batch-size 1 is 8 gradient-accumulation microbatches per step. | ||
| # 200 iterations x 64 sequences x 32768 tokens = 419M training tokens. | ||
| # | ||
| # Requirements: | ||
| # - HF_TOKEN can access the gated nvidia/Nemotron-Post-Training-Dataset-v2 dataset. | ||
| # | ||
| # Usage from tools/launcher: | ||
| # source .env-slurm | ||
| # uv run launch.py --yaml examples/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16/mbridge_qad.yaml --yes | ||
|
|
||
| job_name: Nemotron-3.5-Lightning-30B-A3B_mbridge_qad_32k_200iter | ||
| pipeline: | ||
| note: "NVFP4 QAD at 32K for 200 iterations on Nemotron-Post-Training-Dataset-v2 chat (Megatron-Bridge)" | ||
|
|
||
| global_vars: | ||
| hf_model: nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16 | ||
| output_dir: /cicd/megatron-bridge/Nemotron-3.5-Lightning-30B-A3B-NVFP4 | ||
|
|
||
| # 1) Tokenize the QAD training data into Megatron .bin/.idx, which distill.py reads via | ||
| # --data_paths. megatron_lm_qad.yaml points Megatron-LM's finetune path at a single parquet | ||
| # shard instead; Megatron-Bridge trains from pre-tokenized data, so the split is tokenized | ||
| # once here. --hf_streaming avoids the Arrow cast errors that this dataset's nested tool-call | ||
| # fields trigger in non-streaming mode. No --append_eod: these are chat rows ("messages"), | ||
| # whose chat template already terminates each conversation. | ||
| # 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 | ||
| --hf_dataset nvidia/Nemotron-Post-Training-Dataset-v2 | ||
| --hf_name default | ||
| --hf_split chat | ||
| --hf_streaming | ||
| --json_keys messages | ||
| --tokenizer <<global_vars.hf_model>> | ||
| --output_dir /cicd/tokenized/nemotron-post-training-v2 | ||
| --workers 32 | ||
| --max_sequence_length 256_000 | ||
| slurm_config: | ||
| _factory_: "slurm_factory" | ||
| container: nvcr.io/nvidia/nemo:26.06 | ||
| modelopt_install_path: /opt/venv/lib/python3.12/site-packages/modelopt | ||
| nodes: 1 | ||
| # One process (the tokenizer is single-process), but a full node: clusters | ||
| # commonly enforce a minimum GPU count per job (QOSMinGRES). | ||
| ntasks_per_node: 1 | ||
| gpus_per_node: 4 | ||
| time: "04:00:00" | ||
|
|
||
| # 2) NVFP4 PTQ. Produces the quantized Megatron checkpoint that seeds the QAD student. | ||
| # TP=EP=PP=1 leaves pure DP=4, so each rank calibrates on its own shard of the samples. | ||
| # --calib_dataset_name is left unset, which selects the default public text mix. | ||
| task_1: | ||
| environment: | ||
| - LAUNCH_SCRIPT: torchrun --nproc_per_node 4 | ||
| inline: >- | ||
| $LAUNCH_SCRIPT modules/Model-Optimizer/examples/megatron_bridge/quantize.py | ||
| --hf_model_name_or_path <<global_vars.hf_model>> | ||
| --trust_remote_code | ||
| --tp_size 1 | ||
| --pp_size 1 | ||
| --ep_size 1 | ||
| --recipe huggingface/models/nvidia/Nemotron-3.5-Lightning-30B-A3B-BF16/ptq/w4a16_nvfp4_4o6 | ||
| --calib_batch_size 1 | ||
| --calib_num_samples 1000 | ||
| --seq_length 32768 | ||
| --skip_generate | ||
| --export_megatron_path <<global_vars.output_dir>>-ptq | ||
| slurm_config: &sc | ||
| _factory_: "slurm_factory" | ||
| container: nvcr.io/nvidia/nemo:26.06 | ||
| modelopt_install_path: /opt/venv/lib/python3.12/site-packages/modelopt | ||
| nodes: 1 | ||
| ntasks_per_node: 4 | ||
| gpus_per_node: 4 | ||
|
|
||
| # 3) Distill the NVFP4 student from the BF16 teacher on the tokenized chat data. | ||
| task_2: | ||
| environment: | ||
| - LAUNCH_SCRIPT: torchrun --nproc_per_node 4 | ||
| - TRITON_CACHE_DIR: /tmp/triton_cache | ||
| inline: >- | ||
| $LAUNCH_SCRIPT modules/Model-Optimizer/examples/megatron_bridge/distill.py | ||
| --teacher_hf_path <<global_vars.hf_model>> | ||
| --student_hf_path <<global_vars.hf_model>> | ||
| --student_megatron_path <<global_vars.output_dir>>-ptq | ||
| --trust_remote_code | ||
| --tp_size 1 | ||
| --pp_size 1 | ||
| --cp_size 4 | ||
| --ep_size 16 | ||
| --data_paths /cicd/tokenized/nemotron-post-training-v2/nvidia--Nemotron-Post-Training-Dataset-v2_default_chat_messages | ||
| --data_path_to_cache /cicd/tokenized/nemotron-post-training-v2/cache | ||
| --seq_length 32768 | ||
| --mbs 1 | ||
| --gbs 64 | ||
| --lr 2e-5 | ||
| --min_lr 5e-6 | ||
| --lr_warmup_iters 30 | ||
| --train_iters 200 | ||
| --eval_interval 50 | ||
| --eval_iters 8 | ||
| --log_interval 10 | ||
| --checkpoint_keep_last 2 | ||
| --output_dir <<global_vars.output_dir>>-qad | ||
| slurm_config: | ||
| <<: *sc | ||
| nodes: 8 | ||
|
|
||
| # 4) Export the distilled (still quantized) checkpoint to a deployable unified-HF checkpoint. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we add a lm_eval_hf.py MMLU check as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as prior response, will keep the same as megatron_lm_qad. |
||
| # TP must be 1 -- the HF writer does not gather TP shards -- and PP=4 splits 52 layers 13/stage. | ||
| task_3: | ||
| environment: | ||
| - LAUNCH_SCRIPT: torchrun --nproc_per_node 4 | ||
| inline: >- | ||
| $LAUNCH_SCRIPT modules/Model-Optimizer/examples/megatron_bridge/export_quantized_megatron_to_hf.py | ||
| --hf_model_name_or_path <<global_vars.hf_model>> | ||
| --megatron_path <<global_vars.output_dir>>-qad/checkpoints | ||
| --trust_remote_code | ||
| --pp_size 4 | ||
| --export_unified_hf_path <<global_vars.output_dir>>-qad-hf | ||
| slurm_config: | ||
| <<: *sc | ||
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.