Skip to content
Machine Learning
Skill

/modelopt-qad

Run explicitly requested ModelOpt Quantization-Aware Distillation (QAD) through Megatron Bridge (recommended) or Hugging Face Transformers to recover a measured BF16-to-PTQ accuracy gap. Use only when the user explicitly asks for QAD, including its topology, data preparation,

From plugin
modelopt
5.6k31 skills6 agents

Claude Code

$ npx -y skills add nvidia/model-optimizer --skill modelopt-qad --agent claude-code

SKILL.md

modelopt-qad.SKILL.md
name: modelopt-qad
description: >-
  Run explicitly requested ModelOpt Quantization-Aware Distillation (QAD) through
  Megatron Bridge (recommended) or Hugging Face Transformers to
  recover a measured BF16-to-PTQ accuracy gap.
  Use only when the user explicitly asks for QAD, including its topology, data
  preparation, launch, resume, checkpoint export, or recovery decisions.

ModelOpt Quantization-Aware Distillation

QAD is expensive. Run it only when the user explicitly authorizes QAD for the target model or run, with a loop or GPU-hour budget; ask for the budget when it is missing. A Day-0, PTQ, evaluation, comparison, or recipe-search request alone is not authorization to start QAD. The authorization covers new recipes from a recipe search only when the user says so.

Confirm the gap

For both frameworks, reuse only validated, comparable BF16/PTQ results and the exact benchmark configuration from preceding evaluation or recipe search; run missing, invalid, or non-comparable baselines. Confirm the target benchmarks and their context-length needs. Stop if the PTQ gap to BF16 is already below 1%.

Follow the supported workflow

Read `docs/source/guides/quantization_aware_training_and_distillation.rst` for QAD background and framework selection. Recommend Megatron Bridge for scalable training and its model-specific tutorials. Choose the applicable tutorial from `examples/megatron_bridge/tutorials/README.md`. Honor an explicit HF choice.

Use the common skill's `environment-setup.md` and `workspace-management.md`; for Slurm, also read `slurm-setup.md` and, when remote, `remote-execution.md`.

Treat the example README and `--help` output as authoritative for mutable flags, commands, containers, and checkpoint formats. Both frameworks can run on local GPUs or Slurm; use the user's requested environment.

Megatron Bridge execution and training policy

For Megatron Bridge, before constructing commands, read:

  • `examples/megatron_bridge/README.md`, especially PTQ, data preparation, QAD,

export, and Slurm usage

  • `examples/megatron_bridge/{quantize.py,distill.py}` via `--help`

Execute in this order

1. **Reproduce PTQ and verify compatibility.** In the target runtime, require `AutoBridge.can_handle()` for the target model and PTQ through `quantize.py` to succeed while preserving the exact preceding PTQ config or recipe: format, layer selection, calibration data/count, sequence length, and seed. A changed quantization setting is a new PTQ candidate and must be evaluated before QAD. In the master-rank `.quant_summary.txt`, require finite positive `amax` for enabled static quantizers; accept `dynamic`/format-defined `None` only when the recipe intends it. Treat the summary as rank-local under model parallelism. 2. **Choose topology explicitly.** Derive the smallest fitting node count and TP/PP/CP/EP from student and teacher architecture, the chosen sequence length, and available GPU memory. Prefer CP before TP for small long-context models; keep EP=1 for dense models and ETP=1 because the current `distill.py` workflow does not support expert tensor parallelism. For MoE require:

  • `DP = world_size / (TP * PP * CP)`
  • `EDP = world_size / (EP * PP)`
  • integral DP/EDP, `num_experts % EP == 0`, and

`GBS % (MBS * DP) == 0`

Static-block NVFP4 recipes require TP=1; use PP for memory. With PP, balance stages with `--num_layers_in_{first,last}_pipeline_stage` (the first and last stages also hold the embedding and output layer) and recompute only where memory needs it (`--recompute_num_layers_per_stage`). In the first job's allocation, time a few iterations of each candidate layout with short launches before the run starts, and keep the fastest. Give each timing launch a scratch `--output_dir`: `distill.py` resumes from `<output_dir>/checkpoints`, so a timing checkpoint there would become the run's starting point.

3. **Prepare the full capped dataset once.** Use suitable user-provided data, or copy `examples/megatron_bridge/data/nemotron-cascade-2-blend.yaml` as the default. Set the target tokenizer and workspace path, then materialize the randomly sampled subset before training. Pack the chosen sequence length; Megatron's `99,1,0` split creates the 1% validation holdout from the same data. Keep every source mixed across training, never ordered as a curriculum, so early stops see the whole blend. 4. **Run and monitor QAD.** Run one training job at a time per QAD run; separate runs may train in parallel. Fold startup validation into the first job; do not submit separate GPU preflight jobs or split at recovery iterations. Let training continue while evaluating saved checkpoints, and cancel it when a stop condition below is met.

Default training policy

| Setting | Default | | --- | --- | | Sequence length | 32768; adjust for target benchmarks | | Peak / minimum LR | `1e-5` / `1e-6` | | LR schedule | cosine | | LR horizon (`train_iters`) | 1000 iterations | | Global batch size | 512 | | Dataset | `nvidia/Nemotron-Cascade-2-SFT-Data` by default | | Materialized token budget | 17.3B at 32K; cover `train_iters` at the chosen length | | Training validation | every 25 iterations; deterministic 1% holdout; 2 batches | | Checkpoint interval | 50 iterations | | Loss logging | every 10 iterations | | Recovery benchmark | from the KD-loss knee, then every checkpoint | | Slurm duration exit | 220 minutes for a 4-hour allocation |

Run policy

  • `train_iters` sets the cosine LR horizon and is a loop knob: with 1000, the

LR stays near its peak through iteration 150. `distill.py` also stops training there, with or without `exit_interval`. Stop runs by the decisions below and leave `exit_interval` unset. A run that reaches `train_iters` while the decision is still to continue ends as a Miss from under-recovery.

  • On Slurm, use initial step timing to submit only enough seque
Read more
@nvidia
Ships withmodelopt

Documentation | Roadmap | NVIDIA Model Optimizer (referred to as Model Optimizer, or ModelOpt) is a library comprising state-of-the-art model optimization techniques including quantization, pruning, Neural Architecture Search (NAS), distillation, speculative

5.6k31 skills6 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
5.6k
Star history of nvidia/model-optimizer on GitHub, a chart by star-history.com

Other skills on modelopt.

accessing-mlflow

accessing-mlflow

Compatibility name for modelopt-accessing-mlflow. Browse ModelOpt evaluation runs and artifacts in MLflow.

@nvidia@nvidiaInstall Skill
benchmark-model-kernels

benchmark-model-kernel…

Compatibility name for modelopt-benchmark-model-kernels. Inspect model shapes and benchmark GEMM or fused-MoE kernels.

@nvidia@nvidiaInstall Skill
common

common

Shared ModelOpt support files. Use only when another ModelOpt skill directs you here.

@nvidia@nvidiaInstall Skill
compare-results

compare-results

Compatibility name for modelopt-compare-results. Compare baseline and quantized evaluation results.

@nvidia@nvidiaInstall Skill
day0-release

day0-release

Compatibility name for modelopt-day0-release. Run the full ModelOpt day-0 quantization and validation workflow.

@nvidia@nvidiaInstall Skill
debug

debug

Compatibility name for modelopt-debug. Run commands through the remote Docker debugger relay.

@nvidia@nvidiaInstall Skill

More skills from other plugins.

analyze-ci

analyze-ci

Analyze failed GitHub Action jobs. Takes one or more GitHub URLs (job, workflow-run, or PR) and summarizes each failure with root…

mlflow4d29k
@mlflow@mlflowInstall Skill
hf-cli

hf-cli

Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and…

skills2w11k
@huggingface@huggingfaceInstall Skill
feast-architecture

feast-architecture

Internals of the Feast codebase — how each component works, where the key abstractions live, and the data flow through the…

feast8d7.4k
@feast-dev@feast-devInstall Skill
add-ecosystem

add-ecosystem

Add a new ecosystem and base model to basemodel.constants.ts. Use when onboarding a new model family from providers like Baidu,…

civitai5d7.3k
@civitai@civitaiInstall Skill

Questions about modelopt-qad.

Which coding agents can use modelopt-qad?
modelopt-qad installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.