@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 8c851f6d04
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[Bugfix] Fix qwen3-omni audio truncation issue (#26815)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>

Isotr0py committed Oct 15, 2025 at 13:38 UTC 8c851f6d044bf7922122a1735e57aea727e30d45
1 file changed +16 -2
vllm/model_executor/models/qwen3_omni_moe_thinker.py
+16 -2
@@ -30,7 +30,9 @@ import numpy as np
30 import torch
31 import torch.nn as nn
32 import torch.nn.functional as F
33 +from packaging.version import Version
34 from transformers import PretrainedConfig
35 +from transformers import __version__ as TRANSFORMERS_VERSION
36 from transformers.feature_extraction_utils import BatchFeature
37 from transformers.models.qwen3_omni_moe.configuration_qwen3_omni_moe import (
38 Qwen3OmniMoeConfig,
@@ -711,11 +713,12 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
713 return x
714
715 # NOTE: WhisperFeatureExtractor cannot handle empty list of audios
716 + feature_extractor = self.info.get_feature_extractor()
717 + hop_length = feature_extractor.hop_length
718 if audios:
719 # NOTE: Qwen3-Omni processor accept "audio"
720 # To make sure the cache works with padding=True, we pre-padded
721 # the audio to multiple of hop_length.
718 - hop_length = self.info.get_feature_extractor().hop_length
722 mm_data["audio"] = [
723 pad_to_hop_length(audio, hop_length)
724 if isinstance(audio, np.ndarray)
@@ -725,6 +728,14 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
728 mm_kwargs = dict(
729 **mm_kwargs,
730 )
731 + # TODO(Isotr0py): Remove this patch after upstream fix PR
732 + # released and Transformers version update:
733 + # https://github.com/huggingface/transformers/pull/41473
734 + if (
735 + Version(TRANSFORMERS_VERSION) < Version("4.58.0")
736 + and "truncation" not in mm_kwargs
737 + ):
738 + mm_kwargs["truncation"] = False
739
740 hf_inputs = super()._call_hf_processor(
741 prompt=prompt,
@@ -738,7 +749,6 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
749 and "feature_attention_mask" in hf_inputs
750 and (audios := mm_data.get("audio", []))
751 ):
741 - hop_length = self.info.get_feature_extractor().hop_length
752 audio_num_frames = []
753 for _, audio in enumerate(audios):
754 audio_length = len(audio[0]) if isinstance(audio, tuple) else len(audio)
@@ -747,6 +757,10 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
757 if audio_length % hop_length == 0
758 else (audio_length // hop_length - 1)
759 )
760 + if mm_kwargs.get("truncation", False):
761 + num_frame = min(
762 + num_frame, feature_extractor.n_samples // hop_length
763 + )
764 audio_num_frames.append(num_frame)
765 hf_inputs["feature_attention_mask"] = [
766 torch.ones(num_frame) for num_frame in audio_num_frames