[Bugfix] Give exact-shape codec models an unpadded input_ids view (#6775)

Signed-off-by: Inesh Reddy <ineshreddy249@gmail.com>
Signed-off-by: IneshReddy249 <ineshreddy249@gmail.com>
Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
Inesh Reddy ChappidiandGao Han authored and GitHub committed 2026-09-04 15:28:49 -07:00
1 parent 348fd0fc07
commit 66d938100b
8 files changed
+147 -2

No files matched your search

@@ -143,6 +143,7 @@ class MiniCPMO45Code2Wav(nn.Module):
replace_runtime_additional_information = True
requires_raw_input_tokens = True
requires_request_ids = True
requires_exact_input_shape = True
has_preprocess = False
has_postprocess = False
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
# Copyright 2026 OpenMOSS and the vLLM-Omni team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
@@ -226,6 +229,7 @@ class MossTTSCodecDecoder(nn.Module):
has_postprocess: bool = False
enable_update_additional_information: bool = True
requires_raw_input_tokens: bool = True
requires_exact_input_shape: bool = True
_OUTPUT_SAMPLE_RATE: int = 24_000
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
# Copyright 2025 The Qwen team.
"""Inference-only Qwen3-Omni-Moe unified model (thinker + talker + code2wav)."""
@@ -263,6 +263,8 @@ class Qwen3OmniMoeForConditionalGeneration(
)
self.model = self.code2wav
self.requires_raw_input_tokens = True
# torch.split below requires sum(counts) == input_ids.numel() (#6712)
self.requires_exact_input_shape = True
else:
raise ValueError(
f"Invalid model_stage: {self.model_stage}. Must be one of: 'thinker', 'talker', 'code2wav'"
@@ -38,6 +38,7 @@ from vllm_omni.outputs import OmniModelRunnerOutput
from vllm_omni.platforms.npu.worker.npu_ar_model_runner import ExecuteModelState, _ensure_tensor_values
from vllm_omni.platforms.npu.worker.npu_model_runner import OmniNPUModelRunner
from vllm_omni.utils.mm_outputs import partition_payload_list
from vllm_omni.worker.mixins import maybe_unpad_input_ids
from vllm_omni.worker.omni_connector_model_runner_mixin import (
OmniConnectorModelRunnerMixin,
needs_omni_connector,
@@ -336,6 +337,8 @@ class NPUGenerationModelRunner(OmniNPUModelRunner, OmniConnectorModelRunnerMixin
)
# -------------------------------------- Omni-new -------------------------------------------------
# [Omni] Exact-shape models need input_ids at its real token count (#6712).
input_ids = maybe_unpad_input_ids(self.model, input_ids, scheduler_output.total_num_scheduled_tokens)
# [Omni] Pass token counts per request for code2wav output slicing
model_kwargs["seq_token_counts"] = tokens
if getattr(self.model, "requires_request_ids", False):
@@ -42,6 +42,7 @@ from vllm_omni.outputs import OmniModelRunnerOutput
from vllm_omni.utils.mm_outputs import partition_payload_list
from vllm_omni.worker.gpu_ar_model_runner import ExecuteModelState, _ensure_tensor_values
from vllm_omni.worker.gpu_model_runner import OmniGPUModelRunner
from vllm_omni.worker.mixins import maybe_unpad_input_ids
from vllm_omni.worker.omni_connector_model_runner_mixin import (
OmniConnectorModelRunnerMixin,
needs_omni_connector,
@@ -307,6 +308,9 @@ class GPUGenerationModelRunner(OmniGPUModelRunner, OmniConnectorModelRunnerMixin
num_tokens_padded,
intermediate_tensors,
)
# [Omni] Exact-shape models need input_ids at its real token count (#6712).
input_ids = maybe_unpad_input_ids(self.model, input_ids, num_tokens_unpadded)
# [Omni] Pass token counts per request for code2wav output slicing
model_kwargs["seq_token_counts"] = tokens
if getattr(self.model, "requires_request_ids", False):
+11
View File
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
from __future__ import annotations
from typing import Any
@@ -11,3 +14,11 @@ class OmniWorkerMixin:
from vllm_omni.plugins import load_omni_general_plugins
load_omni_general_plugins()
def maybe_unpad_input_ids(model, input_ids, num_tokens_unpadded):
"""Trim cudagraph-bucket padding for models that split a flat ``input_ids``
by per-request ``seq_token_counts``. See #6712."""
if input_ids is not None and getattr(model, "requires_exact_input_shape", False):
return input_ids[:num_tokens_unpadded]
return input_ids