Merge current Omni main and retain conditioning regression coverage
Signed-off-by: tzhouam <tzhouam@connect.ust.hk>
This commit is contained in:
commit
6f5f9b97e3
21 files changed
+787
-134
No files matched your search
@@ -73,6 +73,27 @@ logger = init_logger(__name__)
|
||||
_RUNTIME_COMPONENTS_CACHE: dict[str, dict] = {}
|
||||
|
||||
|
||||
def _normalize_request_conditioning(payload: dict) -> dict:
|
||||
"""Unwrap singleton conditioning containers at the per-request boundary.
|
||||
|
||||
A processor/prefix-cache passthrough can retain a one-item tensor list.
|
||||
The code2wav schema consumes one request, so that wrapper carries no
|
||||
batch dimension. A multi-item list here is an unsplit batch and must
|
||||
fail instead of silently choosing another request's voice.
|
||||
"""
|
||||
embed = payload.get("embed")
|
||||
if not isinstance(embed, Mapping):
|
||||
return payload
|
||||
normalized = dict(embed)
|
||||
for key in ("speech_token", "speech_feat", "embedding", "speech_token_len"):
|
||||
value = normalized.get(key)
|
||||
if isinstance(value, (list, tuple)):
|
||||
if len(value) != 1:
|
||||
raise ValueError(f"CosyVoice3 per-request {key} contains an unsplit batch of {len(value)} items")
|
||||
normalized[key] = value[0]
|
||||
return {**payload, "embed": normalized}
|
||||
|
||||
|
||||
def _cosyvoice3_trt_enabled() -> bool:
|
||||
"""COSYVOICE3_TRT env toggle (default on) for the optional TensorRT paths.
|
||||
|
||||
@@ -1500,9 +1521,10 @@ class CosyVoice3Model(
|
||||
# [total_tokens, hidden]
|
||||
hidden_states = self.model.llm(inputs_embeds, positions)
|
||||
|
||||
if getattr(self, "_mrv2_tensor_output", False) or cosyvoice3_packed_inference_enabled():
|
||||
return hidden_states
|
||||
return self.make_omni_output(hidden_states, **kwargs)
|
||||
# Both runners attach the live step's conditioning after replay.
|
||||
# Capturing an OmniOutput here would retain the dummy prefill lists
|
||||
# and re-emit them during decode, replacing the real reference.
|
||||
return hidden_states
|
||||
elif self.model_stage == "cosyvoice3_code2wav":
|
||||
# Lazily swap the flow-decoder estimator to a TensorRT engine on the
|
||||
# first code2wav step (after weights are loaded), gated by the same
|
||||
@@ -1538,7 +1560,7 @@ class CosyVoice3Model(
|
||||
|
||||
for idx, req_ids in enumerate(request_ids_list):
|
||||
raw = runtime_info[idx] if idx < len(runtime_info) and isinstance(runtime_info[idx], dict) else {}
|
||||
payload = to_struct(raw)
|
||||
payload = to_struct(_normalize_request_conditioning(raw))
|
||||
meta = payload.meta
|
||||
embed = payload.embed
|
||||
|
||||
|
||||
@@ -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
|
||||
"""CosyVoice3 pipeline topology (frozen).
|
||||
|
||||
Stage 0: Talker — text prompt → speech tokens (LLM autoregressive).
|
||||
@@ -12,11 +12,17 @@ Stage 1: Code2Wav — flow-matching decoder → acoustic features → waveform.
|
||||
through the shared-memory connector.
|
||||
"""
|
||||
|
||||
import shutil
|
||||
from dataclasses import replace
|
||||
|
||||
from transformers import PretrainedConfig
|
||||
|
||||
from vllm_omni.config.stage_config import (
|
||||
PipelineConfig,
|
||||
StageExecutionType,
|
||||
StagePipelineConfig,
|
||||
)
|
||||
from vllm_omni.transformers_utils.configs.cosyvoice3 import CosyVoice3Config
|
||||
|
||||
_PROC = "vllm_omni.model_executor.stage_input_processors.cosyvoice3"
|
||||
|
||||
@@ -35,8 +41,9 @@ COSYVOICE3_PIPELINE = PipelineConfig(
|
||||
async_chunk_process_next_stage_input_func=(f"{_PROC}.talker2code2wav_async_chunk"),
|
||||
custom_process_next_stage_input_func=f"{_PROC}.text2flow_full_payload",
|
||||
sampling_constraints={
|
||||
# merged speech stop token (logsumexp of all 200 stop logits)
|
||||
"stop_token_ids": [6562],
|
||||
# Standard sampling can emit any of the 200 control tokens.
|
||||
# RAS merges their logits into 6562, which is also in this range.
|
||||
"stop_token_ids": list(range(6561, 6761)),
|
||||
},
|
||||
),
|
||||
StagePipelineConfig(
|
||||
@@ -52,3 +59,28 @@ COSYVOICE3_PIPELINE = PipelineConfig(
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def resolve_cosyvoice3_pipeline(hf_config: PretrainedConfig | None = None) -> PipelineConfig | None:
|
||||
"""Select a streaming default compatible with the device and runtime.
|
||||
|
||||
Query the platform through NVML without initializing CUDA in the parent.
|
||||
Explicit deploy configs still take precedence over this pipeline default.
|
||||
"""
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
if hf_config is not None and not isinstance(hf_config, CosyVoice3Config):
|
||||
return None
|
||||
if current_platform.is_cuda():
|
||||
capability = current_platform.get_device_capability()
|
||||
if (
|
||||
capability is not None
|
||||
and capability.major == 9
|
||||
and current_platform.get_device_total_memory() >= 140 * 1024**3
|
||||
and shutil.which("nvidia-cuda-mps-control") is not None
|
||||
):
|
||||
return replace(
|
||||
COSYVOICE3_PIPELINE,
|
||||
default_deploy_config_name="cosyvoice3_packed_streaming_optimized_standard.yaml",
|
||||
)
|
||||
return COSYVOICE3_PIPELINE
|
||||
Reference in new issue
Block a user