Skip to content

[6914448] Keep Qwen vision blocks in high precision for vLLM - #2822

Merged
ajrasane merged 3 commits into
mainfrom
ajrasane/fix-qwen-vision-fp8-vllm
Oct 16, 2026
Merged

ajrasane merged 3 commits into
mainfrom
ajrasane/fix-qwen-vision-fp8-vllm

Conversation

@ajrasane

@ajrasane ajrasane commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: Bug fix

The Qwen3-VL and Qwen3.5 FP8 vision recipes previously quantized vision-block Linears whose 3D attention inputs are flattened by vLLM's FlashInfer FP8 GEMM, causing vision encoder initialization to fail. Narrow the shared visual quantizer rules to primary and deepstack merger Linears, whose inputs are 2D. Update both recipe descriptions, the recipe guide, the 0.48.0 changelog entry, and the quantizer-selection and checkpoint-export tests. This changes existing recipe output: vision blocks now remain in high precision and affected checkpoints must be regenerated.

Usage

from modelopt.recipe import load_recipe

recipe = load_recipe("model_type/qwen3_5/ptq/fp8_vision-kv_none")
quant_cfg = recipe.quantize.model_dump()

Testing

  • Verified the four Qwen3-VL/Qwen3.5 recipe-selection cases fail with the previous quantizer rules and pass with this change (4 passed).
  • Ran the four GPU calibration and unified-HF-export cases for vision-only and joint FP8 recipes (4 passed).
  • Exported a Qwen3.5 vision-language checkpoint after four image-calibration samples on a GB300. The export marks vision blocks as excluded and retains FP8 merger scales. Unmodified vLLM 0.31.0 started successfully, returned HTTP 200 from /health, and answered an image prompt correctly.
  • Ran all applicable pre-commit hooks on the changed files, including recipe validation.

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ❌ — rerunning either existing recipe now leaves vision blocks in high precision; previously exported checkpoints are unchanged.
  • 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?: ✅

Additional Information

This avoids the failing 3D FP8 path by reducing vision quantization coverage. It does not change vLLM's FP8 kernel or repair already exported checkpoints. End-to-end serving used four calibration images; a full-size calibration run with the changed recipe was not repeated.

Summary by CodeRabbit

  • Bug Fixes
    • Updated Qwen3-VL and Qwen3.5 FP8 vision recipes to quantize primary and deepstack vision-merger layers while keeping vision blocks and patch embeddings in high precision for vLLM compatibility.
    • Recipes that also enable language-model FP8 quantization retain that option while keeping vision blocks and patch embeddings in high precision.
    • Calibration checks now account for vision-merger input quantizers.
    • Re-quantize affected checkpoints before deployment to apply the updated settings.
  • Documentation
    • Clarified which model components are quantized by the FP8 vision recipes.

@copy-pr-bot

copy-pr-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: e75c9fd1-be1a-48c9-aaa6-002208eaef93
📥 Commits

Reviewing files that changed from the base of the PR and between 60716cf and 2efb835.

📒 Files selected for processing: 1
  • CHANGELOG.rst
🚧 Files skipped from review as they are similar to previous changes: 1
  • CHANGELOG.rst

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📝 Walkthrough

Qwen3-VL and Qwen3.5 FP8 vision quantization now targets vision-merger Linears. Vision blocks remain high precision. Recipe descriptions, calibration validation, tests, and the changelog reflect the updated scope.

Changes: Qwen vision FP8 recipes

Layer / File(s) Summary
Restrict visual FP8 quantizers
modelopt_recipes/model_type/qwen3_vl/ptq/vision_fp8.quant_cfg.yaml, examples/hf_ptq/hf_ptq.py, tests/unit/recipe/test_qwen_vision_recipe.py, tests/gpu/torch/export/test_qwen_vision_recipe_export.py
FP8 rules target visual merger Linears. Calibration validation matches visual merger input quantizers. Unit and export tests check the enabled quantizers and verify that vision-block scales are absent.
Align recipe descriptions
modelopt_recipes/model_type/qwen3_vl/ptq/fp8_vision*.yaml, modelopt_recipes/model_type/qwen3_5/ptq/fp8_vision*.yaml, modelopt_recipes/ptq.md, CHANGELOG.rst
Recipe descriptions and documentation specify vision-merger FP8 quantization and high-precision vision blocks. The changelog advises re-quantizing affected checkpoints before deployment.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2efb8

No actionable issue is established for this change; it is mergeable after normal checks.

Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: keeping Qwen vision blocks in high precision for vLLM.
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 PASS. The only changed example Python logic updates recipe quantizer-name matching; it adds no torch.load(..., weights_only=False), numpy.load(..., allow_pickle=True), hardcoded `trust_remote_code…
Full details: Security Anti-Patterns

Explanation

PASS. The only changed example Python logic updates recipe quantizer-name matching; it adds no torch.load(..., weights_only=False), numpy.load(..., allow_pickle=True), hardcoded trust_remote_code=True, external-input eval/exec, or # nosec. No modelopt package Python files or dependency manifests changed, and no new dependency was added.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@ajrasane
ajrasane marked this pull request as ready for review October 15, 2026 19:03
@ajrasane
ajrasane requested review from a team as code owners October 15, 2026 19:03
@ajrasane
ajrasane requested a review from meenchen October 15, 2026 19:03

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot review (gpt-6.1-sol) — DM the bot to share feedback.

LGTM: the narrowed rules preserve merger FP8 coverage and disable vision blocks; the justified existing-test updates require human sign-off.

Needs action:

  • Confirm the behavior-aligned assertion changes in tests/unit/recipe/test_qwen_vision_recipe.py and tests/gpu/torch/export/test_qwen_vision_recipe_export.py, then give final approval.

No action needed:

  • Design review: this avoids incompatible 3D vision-attention inputs using existing shared recipe rules, rather than Python quantizer overrides or new OmegaConf/Pydantic configuration plumbing. The PR explains why it narrows coverage instead of repairing vLLM kernels.
  • Test edits are justified: exact merger-only selection replaces broader enablement assertions, and export now checks that block scales are absent. Language-model and KV-cache checks remain intact.
  • Recipe ordering keeps blocks and patch embeddings disabled in both vision-only and joint recipes. Documentation explicitly requires checkpoint regeneration.
  • Tests were inspected, not executed during this review.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.78%. Comparing base (200011e) to head (2efb835).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2822      +/-   ##
==========================================
+ Coverage   69.68%   78.78%   +9.10%     
==========================================
  Files         657      657              
  Lines       73283    73283              
==========================================
+ Hits        51065    57735    +6670     
+ Misses      22218    15548    -6670     
Flag Coverage Δ
examples-diffusers 20.11% <ø> (-0.05%) ⬇️
examples-gpt-oss 13.51% <ø> (-0.04%) ⬇️
examples-hf_ptq 23.26% <ø> (-0.06%) ⬇️
examples-llm_distill 13.59% <ø> (-0.04%) ⬇️
examples-llm_eval 17.27% <ø> (-0.04%) ⬇️
examples-llm_qat 17.52% <ø> (-0.03%) ⬇️
examples-llm_sparsity 15.79% <ø> (-0.06%) ⬇️
examples-megatron_bridge 26.52% <ø> (-0.25%) ⬇️
examples-specdec_bench 13.29% <ø> (-0.04%) ⬇️
examples-speculative_decoding 17.51% <ø> (-0.09%) ⬇️
examples-torch_onnx 21.48% <ø> (-0.08%) ⬇️
examples-torch_trt 15.25% <ø> (-0.04%) ⬇️
examples-vllm_serve 15.00% <ø> (-0.04%) ⬇️
gpu 59.34% <ø> (+37.41%) ⬆️
unit 60.19% <ø> (ø)

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.

@ajrasane
ajrasane force-pushed the ajrasane/fix-qwen-vision-fp8-vllm branch from 79c89cd to 7402fef Compare October 15, 2026 20:16
@ajrasane
ajrasane requested a review from a team as a code owner October 16, 2026 13:18
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
@ajrasane
ajrasane force-pushed the ajrasane/fix-qwen-vision-fp8-vllm branch from 60716cf to 2efb835 Compare October 16, 2026 16:53
@ajrasane
ajrasane enabled auto-merge (squash) October 16, 2026 17:47
@ajrasane
ajrasane merged commit f6f3bf8 into main Oct 16, 2026
56 checks passed
@ajrasane
ajrasane deleted the ajrasane/fix-qwen-vision-fp8-vllm branch October 16, 2026 18:47
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-16 18:48 UTC

@rohansjoshi rohansjoshi added the cherry-pick-done Added by bot once PR is cherry-picked to the release branch label Oct 16, 2026
rohansjoshi added a commit that referenced this pull request Oct 17, 2026
#2769 #2770 #2719 #2796 #2801 #2794 #2787 #2682 #2793 #2791 #2792 #2766 #2823 #2777 #2773 #2813 #2832 #2795 #2684 #2822 #2838 #2807 #2772 #2837 #2820 (#2843)

## Cherry-picked PRs

- #2647
- #2700
- #2718
- #2578
- #2580
- #2711
- #2731
- #2726
- #2697
- #2769
- #2770
- #2719
- #2796
- #2801
- #2794
- #2787
- #2682
- #2793
- #2791
- #2792
- #2766
- #2823
- #2777
- #2773
- #2813
- #2832
- #2795
- #2684
- #2822
- #2838
- #2807
- #2772
- #2837
- #2820

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

## Summary by CodeRabbit

* **New Features**
* Expanded quantized model export support for MXFP4, MXFP8, FP8, and
additional block-quantization formats.
* Added quantization support for GPT-OSS and Step-family models, plus
export support for native FP8 experts.
* Added chat JSONL data preparation for Megatron workflows and an option
to freeze the student MTP head during distillation.
* Added model recipes for Kimi, Gemma, DiffusionGemma, and GLM variants.
* **Bug Fixes**
* Improved ONNX quantization and export compatibility, distributed
calibration consistency, and handling of packed attention caches.
  * Improved safe model loading and low-precision quantization accuracy.
* **Documentation**
* Updated the 0.48.0 changelog and guidance for data preparation and
quantization recipes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Also includes a partial backport of #2656 (only the
`_validate_fold_weight` hook and the `mtq.fold_weight` pre-check), which
#2820 depends on.

---------

Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
Signed-off-by: Rohan Joshi <rohjoshi@nvidia.com>
Signed-off-by: Juhi Mittal <juhim@nvidia.com>
Signed-off-by: Fridah-nv <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
Signed-off-by: yingguo-trt <244492186+yingguo-trt@users.noreply.github.com>
Signed-off-by: weimingc <17592131+meenchen@users.noreply.github.com>
Signed-off-by: Yue <yueshen@nvidia.com>
Signed-off-by: joe-nv <222375587+joe-nv@users.noreply.github.com>
Signed-off-by: ajrasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: Ajinkya Rasane <131806219+ajrasane@users.noreply.github.com>
Signed-off-by: ColinM-sys <cmcdonough@50words.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Signed-off-by: Meng Xin <164952785+mxinO@users.noreply.github.com>
Signed-off-by: gcunhase <4861122+gcunhase@users.noreply.github.com>
Signed-off-by: Chad Voegele <cvoegele@nvidia.com>
Co-authored-by: Shengliang Xu <106840466+shengliangxu@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Juhi Mittal <39641197+juhi10071998@users.noreply.github.com>
Co-authored-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Co-authored-by: Chenjie Luo <108829653+cjluo-nv@users.noreply.github.com>
Co-authored-by: yingguo-trt <244492186+yingguo-trt@users.noreply.github.com>
Co-authored-by: Wei-Ming Chen <17592131+meenchen@users.noreply.github.com>
Co-authored-by: yueshen2016 <39203804+yueshen2016@users.noreply.github.com>
Co-authored-by: joe <222375587+joe-nv@users.noreply.github.com>
Co-authored-by: Ajinkya Rasane <131806219+ajrasane@users.noreply.github.com>
Co-authored-by: Colin McDonough <cmcdonough@50words.com>
Co-authored-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Co-authored-by: mxinO <164952785+mxinO@users.noreply.github.com>
Co-authored-by: Gwena Cunha <4861122+gcunhase@users.noreply.github.com>
Co-authored-by: Chad Voegele <chadvoegele@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-0.48.0 cherry-pick-done Added by bot once PR is cherry-picked to the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants