Keval MorabiaandClaude Opus 5 9c1cf80f1b test(megatron_bridge): cover context parallelism in the VLM QAD test (#2592)
### What does this PR do?

Type of change: new tests

Runs the VLM case of `test_qad` under context parallelism, so QAD on a
Qwen3-VL model is covered on the path that until now could not run at
all.

`Qwen3VLMultimodalRotaryEmbedding` CP-shards its own embedding, so the
batch has to hand it full-length `position_ids`. Megatron-Bridge's
`get_batch` was sharding them too, leaving the rotary embedding at `seq
/ cp**2` against hidden states at `seq / cp`. The fix is upstream in
[NVIDIA-NeMo/Megatron-Bridge#6243](https://github.com/NVIDIA-NeMo/Megatron-Bridge/pull/6243);
this PR is the coverage that would have caught it.

The VLM case moves from tensor to context parallelism and the PTQ step
is sized to the same TP, so QAD still loads a matching checkpoint. The
LLM case is unchanged (`tp_size=num_gpus, cp_size=1`), and
`test_distill_vlm` still covers TP for a VLM, so nothing loses coverage.

### Usage

```bash
# Unchanged: --cp_size is already a distill.py flag. On a container carrying Megatron-Bridge#6243
# it now works for VLMs, where it previously died in the rotary embedding.
python examples/megatron_bridge/distill.py --cp_size 2 --tp_size 1 ...
```

### Testing

On 2x RTX 6000 Ada, in `nemo:26.08` with Megatron-Bridge#6243 on
`PYTHONPATH`:

- `test_qad[qwen3_5_moe_vl]` at `--tp_size 1 --cp_size 2` — FP8 PTQ, QAD
across 2 CP ranks, export; quantizers survive and the vision tower is
byte-identical. **1 passed (183 s).** Without the upstream fix the same
run dies with `AttributeError: 'NoneType' object has no attribute
'ndim'` in `rope.py:175`.
- `test_qad[qwen3]`, the unchanged LLM path — **1 passed (194 s).**
- Gate check: on today's `nemo:26.08` (no #6243) the probe resolves
`False` and the VLM case stays at `cp_size=1`, byte-identical to current
CI; with #6243 it resolves `True` and runs at `cp_size=num_gpus`. On a
1-GPU runner it degenerates to today's config either way.
- `pre-commit run --files ...` clean (ruff check, ruff format, mypy,
bandit, markdownlint).

### Before your PR is "*Ready for review*"

- Is this change backward compatible?: ✅
- 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?: ✅ — existing tests extended
rather than new ones added.
- Did you update
[Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?:
N/A — test coverage and one doc line; no feature, break, deprecation, or
fix for a released bug.
- Did you get Claude approval on this PR?: ❌ — not yet run.

### Additional Information

- Depends on
[NVIDIA-NeMo/Megatron-Bridge#6243](https://github.com/NVIDIA-NeMo/Megatron-Bridge/pull/6243).
Safe to merge before it lands: the gate keeps the VLM case at
`cp_size=1` until a container ships the fix, at which point the coverage
switches on by itself.


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

* **Documentation**
* Updated the Qwen3.6 QAD instructions to keep tensor and pipeline
parallelism set to 1, while allowing context parallelism to increase for
longer sequences with the `nemo:26.10` container.
* **Tests**
* QAD validation now selects parallelism settings based on whether the
Megatron-Bridge context-parallel fix is available, and reports when
multi-GPU VLM coverage is reduced.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-01 23:05:55 +05:30
2026-09-10 17:30:37 +00:00
2026-09-10 17:30:37 +00:00

Banner image

NVIDIA Model Optimizer

Documentation version license

Documentation | Roadmap | Announcement Blogs


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

Previous News

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>-py3
  • nvcr.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

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

Contributors

Happy optimizing!

S
Description
GitHub Trending: NVIDIA/Model-Optimizer
Readme Multiple Licenses
1.2 GiB
Languages
Python 97.3%
Shell 1.3%
Cuda 0.8%
Jinja 0.3%
C++ 0.2%