[Feature][TTS] Port static chunk ramp to Moss-TTS streaming codec decode (#8124)

Signed-off-by: Wallbreazzz <110282866+Wallbreazzz@users.noreply.github.com>
This commit is contained in:
Wallbreazzz authored and GitHub committed 2026-09-29 02:28:15 +00:00
1 parent 3e62bba3cb
commit 5b3abe2f4d
4 files changed
+264 -4

No files matched your search

@@ -36,6 +36,7 @@ from vllm_omni.model_executor.models.moss_tts.moss_codec_cudagraph import (
MossTTSCUDAGraphCodecWrapper,
)
from vllm_omni.model_executor.models.output_templates import OmniOutput
from vllm_omni.model_executor.stage_input_processors.chunk_size_utils import parse_chunk_ramp
logger = init_logger(__name__)
@@ -225,6 +226,22 @@ class _MossCodecStreamSession:
return out
def _resolve_streaming_graph_frame_sizes(
initial_frames: int,
steady_frames: int,
connector_extra_cfg: dict | None,
) -> list[int]:
"""Streaming-graph frame sizes to pre-capture: ``{initial, steady}`` + ramp ladder.
Ladder parsing is delegated to ``parse_chunk_ramp`` so the codec and the
stage input processor agree on one validated ``codec_chunk_ramp``:
null / malformed / single-entry values disable the ramp on both sides
(warn only) and never raise during codec init.
"""
ramp = parse_chunk_ramp(connector_extra_cfg or {}, steady=steady_frames) or []
return sorted({s for s in (initial_frames, steady_frames, *ramp) if s > 0})
class MossTTSCodecDecoder(nn.Module):
"""Stage-1 decoder for all MOSS-TTS variants.
@@ -283,8 +300,12 @@ class MossTTSCodecDecoder(nn.Module):
self._stream_req_slots: dict[str, int] = {}
self._async_chunk = bool(getattr(self.vllm_config.model_config, "async_chunk", False))
self._streaming_graph_batch_sizes = self._streaming_graph_batch_sizes_from_compilation_config()
self._streaming_graph_frame_sizes = sorted(
{frames for frames in (self._initial_stream_chunk_frames, self._stream_chunk_frames) if frames > 0}
# codec_chunk_ramp ladder sizes join the streaming graph frame-size
# set so every ladder (B, T) combination is captured during warmup.
self._streaming_graph_frame_sizes = _resolve_streaming_graph_frame_sizes(
self._initial_stream_chunk_frames,
self._stream_chunk_frames,
self._connector_extra_cfg(),
)
# ------------------------------------------------------------------
@@ -666,6 +687,15 @@ class MossTTSCodecDecoder(nn.Module):
return int(extra_cfg[name])
return default
def _connector_extra_cfg(self) -> dict:
model_cfg = getattr(self.vllm_config, "model_config", None)
connector_cfg = getattr(model_cfg, "stage_connector_config", None)
if isinstance(connector_cfg, dict):
extra_cfg: dict | None = connector_cfg.get("extra", connector_cfg)
else:
extra_cfg = getattr(connector_cfg, "extra", None)
return extra_cfg if isinstance(extra_cfg, dict) else {}
def _streaming_graph_batch_sizes_from_compilation_config(self) -> list[int]:
if getattr(self.vllm_config.model_config, "enforce_eager", True):
return []
@@ -14,6 +14,10 @@ from vllm.inputs import TokensPrompt as OmniTokensPrompt
from vllm.logger import init_logger
from vllm_omni.data_entry_keys import CodesStruct, MetaStruct, OmniPayloadStruct
from vllm_omni.model_executor.stage_input_processors.chunk_size_utils import (
parse_chunk_ramp,
ramp_chunk_size,
)
logger = init_logger(__name__)
@@ -284,8 +288,21 @@ def talker2codec_raw_async_chunk(
initial_chunk_frames = chunk_frames
pending = len(pending_frames)
emitted_any = int(transfer_manager.put_req_chunk.get(req_id, 0)) > 0
threshold = initial_chunk_frames if initial_chunk_frames > 0 and not emitted_any else chunk_frames
# codec_chunk_ramp (opt-in): static ladder of chunk sizes replacing the
# initial_codec_chunk_frames -> codec_chunk_frames cliff. The chunk index
# is maintained by the connector (ramp_chunk_count, incremented per
# emitted chunk); past the ladder, ramp_chunk_size falls back to steady.
if not hasattr(transfer_manager, "_moss_ramp_parsed"):
transfer_manager._moss_ramp_parsed = parse_chunk_ramp(cfg, steady=chunk_frames)
_ramp = transfer_manager._moss_ramp_parsed
if _ramp is not None:
if not hasattr(transfer_manager, "ramp_chunk_count"):
transfer_manager.ramp_chunk_count = defaultdict(int)
_chunk_idx = int(transfer_manager.ramp_chunk_count.get(req_id, 0))
threshold = ramp_chunk_size(_chunk_idx, _ramp, chunk_frames)
else:
emitted_any = int(transfer_manager.put_req_chunk.get(req_id, 0)) > 0
threshold = initial_chunk_frames if initial_chunk_frames > 0 and not emitted_any else chunk_frames
if pending <= 0:
if is_finished:
transfer_manager.code_prompt_token_ids.pop(req_id, None)