@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / bb24592d13
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 11, 00:00 UTC

[Qwen3-Omni] fixed _get_feat_extract_output_lengths function (#31007)

Signed-off-by: Xiong Wang <wangxiongts@163.com> Signed-off-by: Roger Wang <hey@rogerw.io> Co-authored-by: Roger Wang <hey@rogerw.io>

Xiong Wang committed Dec 24, 2025 at 13:33 UTC bb24592d139b48f036d46a4649a2a867fea67f3a
1 file changed +8 -12
vllm/model_executor/models/qwen3_omni_moe_thinker.py
+8 -12
@@ -118,7 +118,7 @@ def _get_feat_extract_output_lengths(input_lengths: torch.Tensor):
118 output_lengths = (
119 ((feat_lengths - 1) // 2 + 1 - 1) // 2 + 1 + (input_lengths // 100) * 13
120 )
121 - return feat_lengths, output_lengths
121 + return output_lengths
122
123
124 class Qwen3_VisionPatchEmbed(nn.Module):
@@ -921,13 +921,11 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
921 if audio_feature_lengths is None and feature_attention_mask is None:
922 audio_output_lengths = []
923 elif audio_feature_lengths is not None:
924 - _, audio_output_lens = _get_feat_extract_output_lengths(
925 - audio_feature_lengths
926 - )
924 + audio_output_lens = _get_feat_extract_output_lengths(audio_feature_lengths)
925 audio_output_lengths = audio_output_lens.tolist()
926 elif feature_attention_mask is not None:
927 assert isinstance(feature_attention_mask, torch.Tensor)
930 - _, audio_output_lens = _get_feat_extract_output_lengths(
928 + audio_output_lens = _get_feat_extract_output_lengths(
929 feature_attention_mask.sum(-1)
930 )
931 audio_output_lengths = audio_output_lens.tolist()
@@ -1111,18 +1109,16 @@ class Qwen3OmniMoeConditionalGenerationMixin(Qwen2_5OmniConditionalGenerationMix
1109 audio_input: Qwen2_5OmniAudioFeatureInputs,
1110 audio_hashes: list[str] | None = None,
1111 cached_audio_features: torch.Tensor | None = None,
1114 - ) -> torch.Tensor:
1112 + ) -> tuple[torch.Tensor, ...]:
1113 input_features = audio_input["input_features"]
1114 audio_feature_lengths = audio_input["audio_feature_lengths"]
1115
1118 - audio_feat_lengths, audio_output_lengths = _get_feat_extract_output_lengths(
1119 - audio_feature_lengths
1120 - )
1116 + audio_output_lengths = _get_feat_extract_output_lengths(audio_feature_lengths)
1117
1118 audio_outputs = self.audio_tower(
1119 input_features.to(self.audio_tower.dtype),
1120 feature_lens=audio_feature_lengths,
1125 - aftercnn_lens=audio_feat_lengths,
1121 + aftercnn_lens=audio_output_lengths,
1122 )
1123 audio_features = audio_outputs.last_hidden_state
1124 return audio_features.split(audio_output_lengths.tolist())
@@ -1579,7 +1575,7 @@ class Qwen3OmniMoeThinkerForConditionalGeneration(
1575 + st_idx
1576 )
1577 st_idx = llm_pos_ids_list[-1].max() + 1 if llm_pos_ids_list else 0
1582 - _, audio_len = _get_feat_extract_output_lengths(
1578 + audio_len = _get_feat_extract_output_lengths(
1579 audio_feature_lengths[audio_idx]
1580 )
1581 llm_pos_ids = (
@@ -1700,7 +1696,7 @@ class Qwen3OmniMoeThinkerForConditionalGeneration(
1696 llm_pos_ids_list.append(bos_block)
1697 llm_pos_ids_list.append(bos_block)
1698 st_idx = llm_pos_ids_list[-1].max() + 1 if llm_pos_ids_list else 0
1703 - _, audio_len = _get_feat_extract_output_lengths(
1699 + audio_len = _get_feat_extract_output_lengths(
1700 audio_feature_lengths[audio_idx]
1701 )
1702 audio_llm_pos_ids = (