Skip to content

example: Nemotron-3-Nano-30B-A3B-BF16 Megatron-LM PTQ launcher example#1964

Closed
ChenhanYu wants to merge 1 commit into
mainfrom
chenhany/nano-30b-a3b-ptq-example
Closed

example: Nemotron-3-Nano-30B-A3B-BF16 Megatron-LM PTQ launcher example#1964
ChenhanYu wants to merge 1 commit into
mainfrom
chenhany/nano-30b-a3b-ptq-example

Conversation

@ChenhanYu

@ChenhanYu ChenhanYu commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a Megatron-LM PTQ launcher example for NVIDIA-Nemotron-3-Nano-30B-A3B-BF16, the smallest NemotronH-class hybrid Mamba-Transformer MoE we ship an example for. Modeled on the existing NVIDIA-Nemotron-3-Super-120B-A12B-BF16/megatron_lm_ptq.yaml.

Pipeline (1 node × 4 GPUs throughout):

task stage parallelism
task_0 quantize (NVFP4) + MMLU gate TP1 PP1 EP4 ETP1
task_1 export → HF NVFP4 TP1 PP4 EP1 ETP1
task_2 vLLM smoke (8 GPQA-style Q) TP4

Notes

  • Uses the named NVFP4_DEFAULT_CFG — there is no dedicated Nano-30B recipe (only Nano-4B / Super-120B / Ultra-550B).
  • Sets modelopt_install_path to the nemo-container venv (/opt/venv/.../site-packages/modelopt) so the mounted modelopt overrides the container's copy — the container's active interpreter is a venv whose site-packages precede /usr/local on sys.path, so the default dist-packages mount is otherwise ignored. Matches the Super-120B example's convention.
  • Passes tools/launcher/tests/test_examples_resolve.py (CPU-only parse/resolve gate).

Test plan

  • test_examples_resolve.py green (CI)
  • End-to-end run on a 4×H200 / B200 node (quantize + MMLU + export + vLLM smoke)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a complete Slurm workflow for quantizing the NVIDIA Nemotron 3 Nano model with NVFP4.
    • Added automated MMLU regression checks for the quantized checkpoint.
    • Added pipeline-parallel export to an HF-compatible NVFP4 checkpoint.
    • Added a vLLM smoke test with sample GPQA-style queries for the exported model.

Adds a quantize + MMLU-gate (EP=4) -> export (PP=4) -> vLLM smoke pipeline for
the smallest NemotronH-class MoE, modeled on the Super-120B-A12B megatron_lm_ptq
example. The quantize and MMLU stages run on the MoE expert-parallel (EP=4)
collective; export uses PP=4 for the hybrid layer stack.

Uses NVFP4_DEFAULT_CFG (no Nano-30B recipe exists) and sets
modelopt_install_path to the nemo-container venv so the mounted modelopt
overrides the container's copy.

Signed-off-by: Chenhan Yu <chenhany@nvidia.com>
@ChenhanYu ChenhanYu requested a review from a team as a code owner July 11, 2026 23:54
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 43288e59-93ba-47ae-a2bb-efe580b11b36

📥 Commits

Reviewing files that changed from the base of the PR and between 7ed19b2 and acb33a1.

📒 Files selected for processing (1)
  • tools/launcher/examples/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/megatron_lm_ptq.yaml

📝 Walkthrough

Walkthrough

Adds a Slurm configuration for NVIDIA Nemotron-3-Nano PTQ using NVFP4, including quantization with an MMLU gate, pipeline-parallel checkpoint export, and vLLM smoke testing of the exported checkpoint.

Changes

Nemotron-3 Nano PTQ workflow

Layer / File(s) Summary
Pipeline documentation and controls
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/megatron_lm_ptq.yaml
Documents the workflow and defines its job identity and top-level execution controls.
Quantization and MMLU gate
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/megatron_lm_ptq.yaml
Runs NVFP4 quantization with calibration settings, enables the MMLU regression gate, and configures EP=4 Slurm execution.
Checkpoint export and vLLM smoke test
tools/launcher/examples/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/megatron_lm_ptq.yaml
Exports the quantized checkpoint with PP=4 and queries the exported NVFP4 checkpoint with vLLM using TP=4.

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

Sequence Diagram(s)

sequenceDiagram
  participant Slurm
  participant quantize.sh
  participant export.sh
  participant vLLM
  Slurm->>quantize.sh: Quantize checkpoint and run MMLU gate
  quantize.sh-->>export.sh: Provide quantized checkpoint
  export.sh->>export.sh: Export NVFP4 checkpoint with PP=4
  export.sh-->>vLLM: Provide exported checkpoint
  vLLM->>vLLM: Run GPQA sample queries with TP=4
Loading
🚥 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 matches the main change: adding a Megatron-LM PTQ launcher example for Nemotron-3-Nano-30B-A3B-BF16.
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 Only a new YAML example changed; no torch.load/numpy.load/eval/exec/nosec/dependency changes, and the trust-remote-code flag matches existing documented vLLM examples.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chenhany/nano-30b-a3b-ptq-example

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

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.95%. Comparing base (7ed19b2) to head (acb33a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1964      +/-   ##
==========================================
+ Coverage   77.92%   77.95%   +0.03%     
==========================================
  Files         519      519              
  Lines       58217    58217              
==========================================
+ Hits        45366    45385      +19     
+ Misses      12851    12832      -19     
Flag Coverage Δ
regression 15.00% <ø> (+0.14%) ⬆️
unit 55.46% <ø> (ø)

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.

@ChenhanYu

Copy link
Copy Markdown
Collaborator Author

Superseded by #1967, which combines the launcher example with the MMLU expert-DP sharding fix (the example is the fix's end-to-end test, so they ship together).

@ChenhanYu ChenhanYu closed this Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-12 01:35 UTC

@kevalmorabia97 kevalmorabia97 deleted the chenhany/nano-30b-a3b-ptq-example branch July 13, 2026 07:47
ChenhanYu added a commit that referenced this pull request Jul 14, 2026
#1967)

Combines the NemotronH MoE PTQ launcher example with the MMLU
expert-parallel sharding fix it exercises. The example is the end-to-end
test for the fix — quantize + **MMLU EP=4** + export + vLLM smoke on
Nano-30B-A3B — so they ship together.

## Fix — `megatron_mmlu.py` shards over the expert-DP group for MoE
models

`megatron_mmlu` shards whole batches across the **dense data-parallel
group** and runs `megatron_prefill` per-rank on a disjoint subset.
Correct for dense models, but for MoE with **EP>1** the prefill forward
runs an **expert all-to-all across the EP group**. When EP overlaps the
dense-DP group (e.g. `EP=4,TP=1,PP=1` on 4 GPUs), each rank is on a
different batch, so the all-to-alls desync (uneven batch counts +
differing padded seq-lengths) → trailing ranks block at NCCL
communicator creation until the c10d store times out (600 s). Reproduced
on Nano-30B-A3B at `EP=4`: ranks 2 & 3 wait on rank 0's `ncclUniqueId`.

The fix shards over the **expert-data-parallel** group when `EP>1`, so
EP peers evaluate every batch in lockstep and only true expert-DP
replicas take disjoint batches. Dense models (`EP==1`) are byte-for-byte
unchanged.

## Example —
`examples/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16/megatron_lm_ptq.yaml`

Quantize (EP=4) + MMLU gate (EP=4) → export (PP=4) → vLLM smoke, modeled
on the Super-120B example. Uses `NVFP4_DEFAULT_CFG` (no Nano-30B recipe)
and sets `modelopt_install_path` to the nemo-container venv so the
mounted modelopt overrides the container copy. Passes
`test_examples_resolve.py`.

## Test plan

- [x] MoE MMLU (`EP>1`) completes instead of hanging — validated
end-to-end via this example on Nano-30B-A3B `EP=4` (nmm-sandbox CI).
- [x] `test_examples_resolve.py` green (example parses/resolves).
- [ ] Dense MMLU sharding unchanged (`EP==1` path identical).

Supersedes #1964 (example) and #1966 (fix).

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Improved MMLU evaluation for expert-parallel MoE models by aligning
batch sharding with expert-parallel execution for more consistent
results.
* **Bug Fixes**
* Dense (non-MoE) models retain standard data-parallel batch sharding,
while MoE handling is corrected.
* **Documentation**
* Updated the Nemotron-3-Nano BF16 PTQ example to clarify the quantize →
MMLU gate → export flow and why the vLLM smoke is intentionally omitted.
* Adjusted the Llama-3.2-1B-Instruct PTQ/MMLU gate lower-bound threshold
(0.40 → 0.36).
* **Tests**
* Marked the homogeneous compressed sharded state-dict test to skip on
Blackwell to avoid a known flaky issue.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Chenhan Yu <chenhany@nvidia.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant