Skip to content

[Model]Add Qwen3-Omni quantization Ascend NPU adaptation and optimization#6828

Merged
wangxiyuan merged 40 commits intovllm-project:mainfrom
tanhaoan333:Qwen3Omni
Mar 2, 2026
Merged

[Model]Add Qwen3-Omni quantization Ascend NPU adaptation and optimization#6828
wangxiyuan merged 40 commits intovllm-project:mainfrom
tanhaoan333:Qwen3Omni

Conversation

@tanhaoan333
Copy link
Copy Markdown
Collaborator

@tanhaoan333 tanhaoan333 commented Feb 26, 2026

What this PR does / why we need it?

This pull request is for quantization adaptation of Qwen3Omni, and it achieves operator-level optimization and AUT (Auto-Quantization Tuning) component optimization through patch-based modifications.

Does this PR introduce any user-facing change?

How was this patch tested?

Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @tanhaoan333, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the support for the Qwen3Omni model on NPU (Neural Processing Unit) platforms. It introduces specialized NPU-optimized implementations for the model's audio attention and encoder layers, alongside crucial adjustments to the dynamic quantization pipeline. These changes aim to improve both the performance and accuracy of Qwen3Omni when running with quantization on NPU hardware, and ensure robust handling of quantization configurations.

Highlights

  • NPU Optimization for Qwen3Omni: Implemented NPU-specific optimizations for Qwen3OmniMoE audio attention and encoder components, leveraging torch_npu for improved performance and efficiency on NPU hardware.
  • Dynamic Quantization Adaptation: Adapted the dynamic quantization method (W8A8_DYNAMIC) to correctly handle tensor dimensions for pertoken_scale during NPU matrix multiplication, preventing shape mismatches.
  • Quantization Configuration Refinement: Refined the quantization configuration logic to accurately determine the quantization type and identify layers that should be skipped for models with mixed precision, improving the flexibility and correctness of auto-quantization tuning.
  • Type Consistency in MoE MLP: Ensured type consistency in Mixture-of-Experts (MoE) MLP operations by explicitly casting tensor types to torch.int32 for cumsum operations, which can be crucial for NPU compatibility and performance.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • vllm_ascend/ops/fused_moe/moe_mlp.py
    • Casted group_list and group_list[:, 1] to torch.int32 before cumsum operations.
    • Added a blank line at the end of the file.
  • vllm_ascend/patch/worker/init.py
    • Added an import for patch_qwen3_omni_moe_thinker.
  • vllm_ascend/patch/worker/patch_qwen3_omni_moe_thinker.py
    • Added a new file containing NPU-optimized Qwen3OmniMoeAudioAttention, Qwen3OmniMoeAudioEncoder, and Qwen3OmniMoeAudioEncoderLayer classes.
    • Implemented patching logic to replace original transformers and vllm components with their NPU-optimized counterparts when NPU is available.
    • Defined WeightsMapper and packed_modules_mapping for Qwen3OmniMoeThinkerForConditionalGeneration.
  • vllm_ascend/quantization/methods/w8a8_dynamic.py
    • Added logic to squeeze quantized_x and pertoken_scale if pertoken_scale has 2 dimensions before npu_quant_matmul.
    • Added logic to unsqueeze the output after npu_quant_matmul if the input was squeezed.
  • vllm_ascend/quantization/modelslim_config.py
    • Modified get_linear_quant_type to check if any weight within a prefix is 'FLOAT' to determine the quantization type, defaulting to 'W8A8_DYNAMIC'.
    • Updated is_layer_skipped_ascend to check if any weight within a prefix is 'FLOAT' to determine if a layer should be skipped.
Activity
  • No activity (comments, reviews, etc.) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces quantization support for the Qwen3Omni model on Ascend NPUs. This is achieved by adding NPU-specific patches for the model's audio encoder and attention mechanisms, leveraging fused kernels for performance optimization. The changes also include fixes and improvements for quantization logic, particularly for handling fused layers and varied tensor shapes from quantization operations. My review found a critical issue related to a missing import in the new patch file, which would cause a runtime error.

embed_dim = config.d_model
self.num_mel_bins = config.num_mel_bins
self.max_source_positions = config.max_source_positions
self.embed_scale = math.sqrt(embed_dim) if config.scale_embedding else 1.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

math.sqrt is used here, but the math module is not imported in this file. This will cause a NameError at runtime. Please add import math at the top of the file.

Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
@tanhaoan333 tanhaoan333 changed the title Qwen3Omni Quantization Feature Adaptation and Performance Optimization [feat]Qwen3Omni Quantization Feature Adaptation and Performance Optimization Mar 2, 2026
@tanhaoan333 tanhaoan333 changed the title [feat]Qwen3Omni Quantization Feature Adaptation and Performance Optimization [Model]Add Qwen3-Omni Ascend NPU adaptation and optimization Mar 2, 2026
@tanhaoan333 tanhaoan333 changed the title [Model]Add Qwen3-Omni Ascend NPU adaptation and optimization [Model]Add Qwen3-Omni quantization Ascend NPU adaptation and optimization Mar 2, 2026
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
@linfeng-yuan linfeng-yuan added ready read for review ready-for-test start test by label for PR labels Mar 2, 2026
@wangxiyuan wangxiyuan merged commit 15f6564 into vllm-project:main Mar 2, 2026
59 of 60 checks passed
845473182 pushed a commit to 845473182/vllm-ascend that referenced this pull request Mar 5, 2026
…to qwen3next_graph

* 'main' of https://github.com/vllm-project/vllm-ascend: (40 commits)
  [Feature] Add docs of batch invariance and make some extra operators patch (vllm-project#6910)
  [bugfix]Qwen2.5VL accurate question (vllm-project#6975)
  [CI] Add DeepSeek-V3.2 large EP nightly ci (vllm-project#6378)
  [Ops][BugFix] Fix RoPE shape mismatch for mtp models with flashcomm v1 enabled (vllm-project#6939)
  [bugfix]fix file not found error in nightly of single-node (vllm-project#6976)
  [Bugfix] Fix the acceptance rates dorp issue when applying eagle3 to QuaRot model (vllm-project#6914)
  [CI] Enable auto upgrade e2e estimated time for auto-partition suites (vllm-project#6840)
  [Doc][Misc] Fix msprobe_guide.md documentation issues (vllm-project#6965)
  [Nightly][Refactor]Migrate nightly single-node model tests from `.py` to `.yaml` (vllm-project#6503)
  [BugFix] Improve GDN layer detection for multimodal models (vllm-project#6941)
  [feat]ds3.2 pcp support mtp and chunkprefill (vllm-project#6917)
  [CPU binding] Implement global CPU slicing and improve IRQ binding for Ascend NPUs (vllm-project#6945)
  [Triton] Centralize Ascend extension op dispatch in triton_utils (vllm-project#6937)
  [csrc][bugfix] Add compile-time Ascend950/910_95 compatibility for custom ops between CANN8.5 and 9.0 (vllm-project#6936)
  [300I][Bugfix] fix unquant model weight nd2nz error (vllm-project#6851)
  [doc] fix supported_models (vllm-project#6930)
  [CI] nightly test timeout (vllm-project#6912)
  [CI] Upgrade CANN to 8.5.1 (vllm-project#6897)
  [Model]Add Qwen3-Omni quantization Ascend NPU adaptation and optimization (vllm-project#6828)
  [P/D][v0.16.0]Adapt to RecomputeScheduler in vLLM 0.16.0 (vllm-project#6898)
  ...
LCAIZJ pushed a commit to LCAIZJ/vllm-ascend that referenced this pull request Mar 7, 2026
…tion (vllm-project#6828)

### What this PR does / why we need it?
This pull request is for quantization adaptation of Qwen3Omni, and it
achieves operator-level optimization and AUT (Auto-Quantization Tuning)
component optimization through patch-based modifications.
### Does this PR introduce _any_ user-facing change?

### How was this patch tested?

- vLLM version: v0.15.0
- vLLM main:
vllm-project/vllm@83b47f6

---------

Signed-off-by: tanhaoan333 <tanhaoan@huawei.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ops module:quantization ready read for review ready-for-test start test by label for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants