### What does this PR do? Type of change: Bug fix A DFlash-family drafter's label alignment belongs to its algorithm. DSpark and Domino train block position `k` on the token at `anchor + k + 1`: next-token, so the anchor is itself a prediction. DFlash, DFlash2 and LiLiCorr train it on `anchor + k`: each masked position predicts itself. Since #2757 the class constant `_label_shift` drives the training targets, but on `main` the same fact is still written in four more places, and the exports read it from the user's config: - `DSparkModule.shift_label`, hard-coded `True`. - `DominoModule.shift_label`, read from the config. - A `NotImplementedError` in `HFDominoModel.modify`. - The exporters' `getattr(draft_config, "shift_label", True)`, plus a literal `sample_from_anchor: True` in the vanilla DSpark export. Three bugs follow: 1. **`shift_label` in the config is ignored or contradicted.** - DSpark with `shift_label: false` trains next-token alignment anyway and exports `shift_label: false`, so a loader that honors the field reads every drafted position one token off. - Domino refuses it, but only after building the draft. - DFlash, DFlash2 and LiLiCorr accept the field and ignore it. 2. **The exporters re-read head fields from the raw config.** - `DSparkModule` casts `markov_rank` to int, so a rank written as `64.0` trains a rank-64 head and exports `64.0`. - The vanilla export copies that value to the top level, where vLLM's `Qwen3DSparkModel` sizes its Markov table. - `use_confidence_head` and Domino's `pure_draft_prefix_len` are re-read with defaults of their own. 3. **Domino's HF AR validation drafts one position off, without its head.** `HFDominoModel` inherits DFlash's `pseudo_speculative_generate`, which decodes block positions `1..bs-1` with the backbone alone, so every draft is scored against the wrong target. Shipped training is unaffected: `domino.yaml` keeps AR validation off. The fixes: - **The alignment comes from `projector_type` alone.** - `shift_label` is deprecated and will be removed in 0.50. Before converting the model, `convert_to_dflash_model` compares it with the wrapper class's `_label_shift`: - A matching value is dropped with a `FutureWarning`. Configs copied from the old Domino recipe (`shift_label: true`) keep working through the migration window in the README's deprecation policy. - A contradicting value raises, because it never took effect. - Why the check does not warn and override, as `HFDFlashModel.modify` does for RoPE: on `main` a contradicting value was already ignored or refused. DFlash, DFlash2 and LiLiCorr ignored it, DSpark trained next-token anyway, and Domino refused `false`. Overriding it with a warning would let a run go on that does not train what its config says. - Why it is not a `DFlashConfig` validator: the alignment lives on the plugin's wrapper class, which the config layer does not import. A validator would also run on restore, where old checkpoints carry contradicting values. - `restore_dflash_model` drops the key unchecked before replaying convert, so checkpoints that carry it still load. DSpark ones saved with `shift_label: false` now re-export `true`. - Both halves read one table, `_DEPRECATED_ARCHITECTURE_KEYS` in `dflash/conversion.py`. It pairs each key with the model attribute that now fixes its value, and the reason, so the check and the restore filter cannot drift apart. - The exports write `shift_label`, and DSpark's `sample_from_anchor` (vLLM's name for the same alignment), from `_label_shift`. - The modules' `shift_label` attributes and Domino's own check are gone. The Domino recipe, the skill sheets and the test configs no longer set the key. - **The exporters read the built head** for `markov_rank`, `markov_head_type`, `use_confidence_head`, `pure_draft_prefix_len`, `gru_hidden_dim` and `emb_dim`, as `LiLiCorrExporter` already does. - **Domino's `pseudo_speculative_generate` raises `NotImplementedError`.** - HF AR validation is being deprecated (#3107), so Domino gets no decode of its own. - Domino acceptance cannot be measured anywhere yet: - The inherited decode drafts with the backbone alone, one block position off. - The export declares `DFlashDraftModel`, so vLLM would serve it the same way. - `examples/specdec_bench` has no Domino route. The error, the changelog and the skill sheet now say so, matching the launcher example's note. - The eval-time warning that called acceptance rates "backbone-only" is removed. The `forward` docstring and the skill sheet now note that eval loss and accuracy exclude the correction head; the recipe sets `do_eval: false`. - During training, the AR callback already catches the error and logs `AR validation not available.` - **Changelog (0.49.0):** a Deprecations entry for `shift_label`, and a Bug Fixes entry for the exports and Domino's AR validation. ### Usage Remove `shift_label` from DFlash-family configs, since `projector_type` fixes the alignment. Until 0.50 a value that matches the variant only warns: ```yaml dflash: dflash_architecture_config: projector_type: domino # shift_label: true # deprecated: warns until 0.50; false raises ``` ### Testing - New and changed tests: - `test_deprecated_shift_label[dflash|dspark|domino x true|false]` restores a modelopt_state that carries `shift_label`, then converts with it. A matching value warns, converts, and is not saved in the new modelopt_state. A contradicting one raises and leaves the model unconverted. - All 6 cases fail on `main` (09a14b9ae8). - With the previous revision's refusal (39ffc25218), the 3 matching cases fail. - Without the restore filter, the 3 contradicting cases fail at restore. - `test_export_config_has_dspark_fields` converts with `markov_rank` given as a float and expects an int at both config levels. All 8 cases fail without the exporter change. - `TestDominoForward::test_ar_validation_is_refused` fails without the override, because the inherited decode then runs. - Rebased onto `main` (ef893e7708) asbd19e2d81b. `git range-diff` shows the same changes commit for commit; only the skill sheets' new location under `skills/modelopt-speculative-decoding/` and CHANGELOG context differ. - Atbd19e2d81b, Python 3.12, transformers 5.18.0, torch 2.13: `test_hf_{dflash,dflash2,dspark,domino,lilicorr}.py`, `tests/unit/recipe`, `tests/unit/torch/export/test_hf_spec_rope_export.py`, `tests/unit/examples/test_deepseek_v4_recipe.py` and `tools/launcher/tests/test_examples_resolve.py`: 987 passed. - Before the rebase, ata944d85bb7, Python 3.12, transformers 5.18.0, torch 2.10: `test_hf_{dflash,dflash2,dspark,domino,lilicorr}.py`, 318 passed. - At39ffc25218, which differs from the head only in the `shift_label` check, Domino's error text and docs: - Those five files plus `tests/unit/recipe/test_loader.py`, `tests/unit/torch/export/test_hf_spec_rope_export.py` and `tests/unit/examples/test_deepseek_v4_recipe.py`: 834 passed. - `tools/launcher/tests/test_examples_resolve.py`: 75 passed. - `tests/gpu/torch/speculative/plugins/test_hf_dflash.py` on 2 GPUs (torch 2.13): 16 passed. - Not run: - transformers 5.5 and 5.12, which CI's multi-version job covers. An earlier revision passed 792 of these tests on 5.5.4, 5.12.1 and 5.18.0. - A bitwise A/B, because no training code changes. ### Before your PR is "*Ready for review*" Make sure you read and follow [Contributor guidelines](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md) and your commits are signed (`git commit -s -S`). Make sure you read and follow the [Security Best Practices](https://github.com/NVIDIA/Model-Optimizer/blob/main/SECURITY.md#security-coding-practices-for-contributors) (e.g. avoiding hardcoded `trust_remote_code=True`, `torch.load(..., weights_only=False)`, `pickle`, etc.). - Is this change backward compatible?: - ✅ for a `shift_label` that matches the variant, including the shipped Domino recipe's `true`. Such configs convert as before, with a deprecation warning. - ❌ for a contradicting `shift_label`, which now raises at convert: it never took effect. That is DFlash, DFlash2 or LiLiCorr with `true`, and DSpark or Domino with `false`. - Existing checkpoints still load. - Domino with `shift_label: false` raises `ValueError` instead of `NotImplementedError`. - Domino's HF AR validation raises instead of returning misaligned drafts. - If you copied code from any other sources or added a new PIP dependency, did you follow guidance in `CONTRIBUTING.md`: N/A - Did you write any new necessary tests?: ✅ - Did you update [Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?: ✅ 0.49.0: a Deprecations entry for `shift_label`, and a Bug Fixes entry, since DSpark and Domino have shipped since 0.46.0. - Did you get Claude approval on this PR?: ✅ Approved at39ffc25218. Its one suggestion is addressed at the head. ### Additional Information Follow-up to #2757, now merged. The shared-forward PRs, #2989 [1/2] and then #2990 [2/2], build on this branch and will be restacked onto it. Found while testing and not fixed here; it fails the same way on `main`: with `DFlashModule` as its own FSDP2 unit, DSpark and Domino training fails with `got mixed torch.Tensor and DTensor`, because their heads run outside `DFlashModule.forward`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected DSpark and Domino export settings to reflect the built model configuration. * Fixed a validation error in Domino’s Hugging Face autoregressive validation; this validation is not supported for Domino. * **Deprecations** * `shift_label` is deprecated and planned for removal in version 0.50. Matching values are ignored with a warning; conflicting values cause an error. Existing checkpoints containing the setting can still be loaded. * **Documentation** * Updated speculative decoding guidance to reflect the deprecation and Domino’s evaluation limitations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: h-guo18 <67671475+h-guo18@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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 decoding and sparsity to accelerate models.
[Input] Model Optimizer currently supports inputs of a Hugging Face, PyTorch or ONNX model.
[Optimize] Model Optimizer provides Python APIs for users to easily compose the above model optimization techniques and export an optimized quantized checkpoint. Model Optimizer is also integrated with NVIDIA Megatron-Bridge, Megatron-LM and Hugging Face Accelerate for training required inference optimization techniques.
[Export for deployment] Seamlessly integrated within the NVIDIA AI software ecosystem, the quantized checkpoint generated from Model Optimizer is ready for deployment in downstream inference frameworks like SGLang, TensorRT-LLM, TensorRT, or vLLM. The unified Hugging Face export API now supports both transformers and diffusers models.
Latest News
- [2026/10/28] BLOG: GLM-5.3-Flash at 2-3 Bits per Expert Weight: IQ2_S PTQ Recipes and QAD: IQ2_S experts with NVFP4 down projections match the FP8 checkpoint without training, at less than half its size; QAD recovers long-context accuracy on the all-IQ2_S model.
- [2026/10/15] NVIDIA Nemotron 3.5 Super VL 120B-A12B NVFP4 checkpoint: Quantized with Model Optimizer using post-training quantization (PTQ) and quantization-aware distillation (QAD). For details, see the Quantization section (Section 4) of the technical report.
- [2026/10/08] BLOG: AutoQuant KV: Automatic Mixed-Precision KV Cache Quantization: Per-layer KV format search, GEMM composition, and a Qwen3-8B accuracy case study.
- [2026/09/16] BLOG: Scale Learning: Training NVFP4 Block Scales to Recover Accuracy
- [2026/09/16] End-to-end W4A4 NVFP4 + QAD tutorial for Qwen3.6-35B-A3B: NVFP4 W4A4 PTQ plus quantization-aware distillation, reaching up to 1.30x vLLM throughput over BF16 and 3.1x smaller checkpoints while recovering the accuracy W4A4 costs.
- [2026/09/09] BLOG: Improving NVFP4 Accuracy with Local-Hessian Weight Scales
- [2026/08/24] BLOG: AutoQuantize: A Fast Automatic Mixed-Precision Assignment
- [2026/08/17] BLOG: Developing Nemotron 3.5 Lightning NVFP4 with QAD Using NVIDIA Model Optimizer: Learn how quantization-aware distillation recovers accuracy from aggressive NVFP4 quantization while reducing model size and increasing throughput.
- [2026/06/26] BLOG: Creating the NVIDIA Nemotron 3 Ultra NVFP4 Checkpoint with NVIDIA Model Optimizer: How we quantized Nemotron 3 Ultra (550B) to NVFP4 with Model Optimizer — up to 5.9× higher decode-heavy inference throughput than GLM-5.1 754B FP4 while matching BF16 accuracy. NVFP4 Checkpoint on Hugging Face.
- [2026/05/27] End-to-end Optimization tutorial for Nemotron-3-Nano-30B-A3B: Pruning + two-phase distillation + FP8 quantization achieving 2.6× vLLM throughput and 2.6× memory reduction.
- [2026/05/13] Puzzletron: A new algorithm for heterogeneous pruning & NAS of LLM and VLM models.
- [2026/04/15] Customer story: Domyn compresses Colosseum-355B → 260B using ModelOpt's Minitron pruning + distillation
- [2026/03/17] Customer story: Bielik.AI builds Bielik Minitron 7B (33% smaller, 50% faster, 90% quality retained) using ModelOpt's Minitron pruning + distillation
- [2026/03/11] Model Optimizer quantized Nemotron-3-Super checkpoints are available on Hugging Face for download: FP8, NVFP4. Learn more in the Nemotron 3 Super release blog. Check out how to quantize Nemotron 3 models for deployment acceleration here
- [2026/03/11] NeMo Megatron Bridge now supports Nemotron-3-Super quantization (PTQ and QAT) and export workflows using the Model Optimizer library. See the Quantization (PTQ and QAT) guide for FP8/NVFP4 quantization and HF export instructions.
- [2025/12/11] BLOG: Top 5 AI Model Optimization Techniques for Faster, Smarter Inference
- [2025/12/08] NVIDIA TensorRT Model Optimizer is now officially rebranded as NVIDIA Model Optimizer.
- [2025/10/07] BLOG: Pruning and Distilling LLMs Using NVIDIA Model Optimizer
- [2025/09/17] BLOG: An Introduction to Speculative Decoding for Reducing Latency in AI Inference
- [2025/09/11] BLOG: How Quantization Aware Training Enables Low-Precision Accuracy Recovery
- [2025/08/29] BLOG: Fine-Tuning gpt-oss for Accuracy and Performance with Quantization Aware Training
- [2025/08/01] BLOG: Optimizing LLMs for Performance and Accuracy with Post-Training Quantization
- [2025/06/24] BLOG: Introducing NVFP4 for Efficient and Accurate Low-Precision Inference
- [2025/05/14] NVIDIA TensorRT Unlocks FP4 Image Generation for NVIDIA Blackwell GeForce RTX 50 Series GPUs
- [2025/04/21] Adobe optimized deployment using Model-Optimizer + TensorRT leading to a 60% reduction in diffusion latency, a 40% reduction in total cost of ownership
- [2025/04/05] NVIDIA Accelerates Inference on Meta Llama 4 Scout and Maverick. Check out how to quantize Llama4 for deployment acceleration here
- [2025/03/18] World's Fastest DeepSeek-R1 Inference with Blackwell FP4 & Increasing Image Generation Efficiency on Blackwell
- [2025/02/25] Model Optimizer quantized NVFP4 models available on Hugging Face for download: DeepSeek-R1-FP4, Llama-3.3-70B-Instruct-FP4, Llama-3.1-405B-Instruct-FP4
- [2025/01/28] Model Optimizer has added support for NVFP4. Check out an example of NVFP4 PTQ here.
- [2025/01/28] Model Optimizer is now open source!
Previous News
- [2024/10/23] Model Optimizer quantized FP8 Llama-3.1 Instruct models available on Hugging Face for download: 8B, 70B, 405B.
- [2024/09/10] Post-Training Quantization of LLMs with NVIDIA NeMo and Model Optimizer.
- [2024/08/28] Boosting Llama 3.1 405B Performance up to 44% with Model Optimizer on NVIDIA H200 GPUs
- [2024/08/28] Up to 1.9X Higher Llama 3.1 Performance with Medusa
- [2024/08/15] New features in recent releases: Cache Diffusion, QLoRA workflow with NVIDIA NeMo, and more. Check out our blog for details.
- [2024/06/03] Model Optimizer now has an experimental feature to deploy to vLLM as part of our effort to support popular deployment frameworks. Check out the workflow here
- [2024/05/08] Announcement: Model Optimizer Now Formally Available to Further Accelerate GenAI Inference Performance
- [2024/03/27] Model Optimizer supercharges TensorRT-LLM to set MLPerf LLM inference records
- [2024/03/18] GTC Session: Optimize Generative AI Inference with Quantization in TensorRT-LLM and TensorRT
- [2024/03/07] Model Optimizer's 8-bit Post-Training Quantization enables TensorRT to accelerate Stable Diffusion to nearly 2x faster
- [2024/02/01] Speed up inference with Model Optimizer quantization techniques in TRT-LLM
Install
To install stable release packages for Model Optimizer with pip from PyPI:
pip install -U nvidia-modelopt[all]
Model Optimizer will download and install additional third-party open source software projects. Review the license terms of these open source projects before use.
To install from source in editable mode with all development dependencies or to use the latest features, run:
# Clone the Model Optimizer repository
git clone git@github.com:NVIDIA/Model-Optimizer.git
cd Model-Optimizer
pip install -e .[dev]
You can also directly use NVIDIA container images, which have Model Optimizer pre-installed:
nvcr.io/nvidia/pytorch:<version>-py3nvcr.io/nvidia/nemo:<version>nvcr.io/nvidia/tensorrt-llm/release:<version>
Before pulling and using the container images, please review their respective license terms. Make sure to upgrade Model Optimizer to the latest version as described above. Visit our installation guide for more fine-grained control on installed dependencies or for alternative docker images and environment variables to setup.
Techniques
| Technique | Description | Getting started | Examples |
|---|---|---|---|
| Post Training Quantization | Compress model size by 2x-4x, speeding up inference while preserving model quality! | [Start here] | [HF LLMs / VLMs] [Megatron-Bridge LLMs / VLMs] [Diffusers] [ONNX] [Windows] |
| Quantization Aware Training / Distillation | Refine accuracy of quantized models even further with a few training steps! | [Start here] | [Hugging Face] [Megatron-Bridge] |
| Pruning | Reduce your model parameters or memory footprint and accelerate inference by removing unnecessary weights! | [Start here] | [General] [Megatron-Bridge] |
| Distillation | Reduce deployment model size by teaching small models to behave like larger models! | [Start here] | [Hugging Face] [Megatron-Bridge] [Megatron-LM] |
| Speculative Decoding | Train draft modules to predict extra tokens during inference! | [Start here] | [Hugging Face] [Megatron-LM] |
| Sparsity | Efficiently compress your model by storing only its non-zero parameter values and their locations | [Start here] | [Hugging Face] |
Pre-Quantized Checkpoints
- Ready-to-deploy checkpoints [🤗 Hugging Face - Nvidia Model Optimizer Collection]
- Deployable on TensorRT-LLM, vLLM and SGLang
- More models coming soon!
Resources
Model Support Matrix
| Model Type | Support Matrix |
|---|---|
| LLM / VLM Quantization | View Support Matrix |
| Diffusers Quantization | View Support Matrix |
| ONNX Quantization | View Support Matrix |
| Windows Quantization | View Support Matrix |
| Quantization Aware Training | View Support Matrix |
| Pruning | View Support Matrix |
| Distillation | View Support Matrix |
| Speculative Decoding | View Support Matrix |
Deprecation Policy
Model Optimizer follows a structured approach to managing deprecated features:
- Communication: Deprecation notices are documented in the Changelog. Deprecated items include source code statements indicating deprecation timing, with runtime warnings issued upon use.
- Migration Period: Since Model Optimizer is still pre-1.0, we provide a 1-release (~1-month) migration period after deprecation. During this window, deprecated features continue functioning while issuing warnings.
- Scope: The policy addresses both complete deprecations (entire APIs removed) and partial ones (specific parameters removed while methods remain).
- Removal: Following the migration period, deprecated elements are removed in alignment with semantic versioning standards, potentially including breaking changes in minor version updates while Model Optimizer remains in 0.x.
Citation
If you use NVIDIA Model Optimizer in your research, please cite it as follows:
@misc{nvidia-modelopt,
author = {{NVIDIA Corporation}},
title = {{NVIDIA Model Optimizer}},
howpublished = {\url{https://github.com/NVIDIA/Model-Optimizer}},
year = {2024--2026},
note = {GitHub repository}
}
Contributing
Model Optimizer is now open source! We welcome any feedback, feature requests and PRs. Please read our Contributing guidelines for details on how to contribute to this project.
AI Agents
ModelOpt's agent skills can be installed from this repository and used in any workspace.
Claude Code
claude plugin marketplace add https://github.com/NVIDIA/Model-Optimizer.git
claude plugin install modelopt@modelopt
Codex
codex plugin marketplace add https://github.com/NVIDIA/Model-Optimizer.git
Then open /plugins, select the modelopt marketplace, and install modelopt.
Contributors can also use the skills directly from a checkout. See the
agent tooling notes.
Top Contributors
Happy optimizing!
