Merge branch 'main' into dev/vllm-align
This commit is contained in:
54 files changed
+1659
-500
No files matched your search
@@ -339,6 +339,7 @@ class OmniBase(PDDisaggregationMixin):
|
||||
allow_delta_coercion: bool = False,
|
||||
) -> Sequence[Any]:
|
||||
"""Resolve request parameters; pipeline sampling constraints override caller values."""
|
||||
normalized: Sequence[Any]
|
||||
if sampling_params_list is None:
|
||||
normalized = self.default_sampling_params_list
|
||||
# Set the output kind to delta since no params were specified
|
||||
@@ -354,7 +355,9 @@ class OmniBase(PDDisaggregationMixin):
|
||||
if len(normalized) != self.num_stages:
|
||||
raise ValueError(f"Expected {self.num_stages} sampling params, got {len(normalized)}")
|
||||
|
||||
if sampling_params_list is not None:
|
||||
# Streaming coercion may also change a constrained output kind in
|
||||
# the defaults (for example, an internal TTS stage's FINAL_ONLY).
|
||||
if sampling_params_list is not None or allow_delta_coercion:
|
||||
normalized = [
|
||||
self._apply_sampling_constraints(params, constraints)
|
||||
for params, constraints in zip(normalized, self.sampling_constraints_list, strict=True)
|
||||
@@ -364,7 +367,7 @@ class OmniBase(PDDisaggregationMixin):
|
||||
@staticmethod
|
||||
def _get_sampling_constraints_list(stage_configs: Sequence[Any]) -> list[dict[str, Any]]:
|
||||
"""Extract each stage's required sampling settings from runtime configs."""
|
||||
constraints_list = []
|
||||
constraints_list: list[dict[str, Any]] = []
|
||||
for stage_config in stage_configs:
|
||||
constraints = getattr(stage_config, "sampling_constraints", {})
|
||||
if not isinstance(constraints, Mapping):
|
||||
@@ -398,7 +401,7 @@ class OmniBase(PDDisaggregationMixin):
|
||||
req_state = self.request_states.get(request_id)
|
||||
prom = getattr(self, "prom_metrics", None)
|
||||
metrics = getattr(req_state, "metrics", None)
|
||||
if metrics is None or prom is None:
|
||||
if req_state is None or metrics is None or prom is None:
|
||||
return
|
||||
if str(request_id) in metrics.e2e_done or getattr(req_state, "failure_recorded", False):
|
||||
return
|
||||
|
||||
@@ -6,7 +6,7 @@ Both variants share the same build/validate flow (``_build_moss_tts_params``
|
||||
handles each); they are registered under distinct model-type names.
|
||||
"""
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
from vllm.inputs import tokens_input
|
||||
|
||||
@@ -61,7 +61,7 @@ class _MossTTSAdapterBase(ARTTSAdapter):
|
||||
# the process-wide speaker cache.
|
||||
encoder = build_reference_encoder(
|
||||
self._get_moss_processor(),
|
||||
variant=self._moss_variant,
|
||||
variant=cast(str, self._moss_variant),
|
||||
speaker_cache=self._speaker_cache,
|
||||
)
|
||||
self._moss_ref_encoder = encoder
|
||||
@@ -101,7 +101,7 @@ class _MossTTSAdapterBase(ARTTSAdapter):
|
||||
|
||||
return await encode_request_references(
|
||||
self._get_moss_ref_encoder(),
|
||||
request.ref_audio,
|
||||
cast(str, request.ref_audio),
|
||||
request.ref_audio_2 if two_speaker else None,
|
||||
resolve_ref_audio=self._resolve_ref_audio,
|
||||
get_artifact_key=self._get_resolved_ref_audio_artifact_key,
|
||||
@@ -179,15 +179,16 @@ class _MossTTSAdapterBase(ARTTSAdapter):
|
||||
|
||||
v = self._moss_variant
|
||||
|
||||
params: dict[str, Any]
|
||||
# ---- Legacy nano path (unchanged) ----
|
||||
if v is None: # moss_tts_nano
|
||||
params: dict[str, Any] = {
|
||||
params = {
|
||||
"text": [request.input or ""],
|
||||
"mode": ["voice_clone"],
|
||||
}
|
||||
if request.max_new_tokens is not None:
|
||||
params["max_new_frames"] = [request.max_new_tokens]
|
||||
wav_list, sr, cache_key = await self._resolve_ref_audio(request.ref_audio)
|
||||
wav_list, sr, cache_key = await self._resolve_ref_audio(cast(str, request.ref_audio))
|
||||
params["prompt_audio_array"] = [[wav_list, sr]]
|
||||
params["ref_audio_cache_key"] = cache_key
|
||||
return params
|
||||
@@ -201,13 +202,13 @@ class _MossTTSAdapterBase(ARTTSAdapter):
|
||||
# talker reads for short prompts; full Realtime support needs a
|
||||
# separate processor.from_module path which we don't wire here.
|
||||
if v == "realtime":
|
||||
params: dict[str, Any] = {
|
||||
params = {
|
||||
"text": [request.input or ""],
|
||||
"mode": ["voice_clone"],
|
||||
}
|
||||
if request.max_new_tokens is not None:
|
||||
params["max_new_frames"] = [request.max_new_tokens]
|
||||
wav_list, sr, cache_key = await self._resolve_ref_audio(request.ref_audio)
|
||||
wav_list, sr, cache_key = await self._resolve_ref_audio(cast(str, request.ref_audio))
|
||||
params["prompt_audio_array"] = [[wav_list, sr]]
|
||||
params["ref_audio_cache_key"] = cache_key
|
||||
return params
|
||||
@@ -254,13 +255,20 @@ class _MossTTSAdapterBase(ARTTSAdapter):
|
||||
# Build the unified-codes prompt: (L, 1+n_vq) where col 0 is text/special
|
||||
# tokens and cols 1..n_vq are the delay-pattern audio code grid (mostly
|
||||
# audio_pad_code outside the reference block).
|
||||
user_msg = proc.build_user_message(**user_kwargs)
|
||||
batch = proc(conversations=[[user_msg]], mode="generation")
|
||||
if v == "local" and request.ref_text and request.ref_text.strip():
|
||||
reference = user_kwargs.pop("reference")
|
||||
user_kwargs["text"] = request.ref_text.strip() + " " + (request.input or "")
|
||||
user_msg = proc.build_user_message(**user_kwargs)
|
||||
assistant_msg = proc.build_assistant_message(audio_codes_list=reference)
|
||||
batch = proc(conversations=[[user_msg, assistant_msg]], mode="continuation")
|
||||
else:
|
||||
user_msg = proc.build_user_message(**user_kwargs)
|
||||
batch = proc(conversations=[[user_msg]], mode="generation")
|
||||
unified = batch["input_ids"][0] # torch.LongTensor (L, 1+n_vq)
|
||||
text_ids: list[int] = unified[:, 0].tolist()
|
||||
audio_codes: torch.Tensor = unified[:, 1:].contiguous().to(torch.int64)
|
||||
|
||||
params: dict[str, Any] = {
|
||||
params = {
|
||||
"prompt_token_ids": text_ids,
|
||||
"codes": {"ref": audio_codes},
|
||||
}
|
||||
|
||||
@@ -278,9 +278,9 @@ def maybe_coerce_to_message_type(params: SamplingParams, is_streaming: bool):
|
||||
if params.output_kind == target_type:
|
||||
return params
|
||||
elif is_streaming and params.output_kind == RequestOutputKind.FINAL_ONLY:
|
||||
logger.warning("Request appears to be streaming, but got request type final only!")
|
||||
logger.debug("Coercing FINAL_ONLY output to DELTA for streaming")
|
||||
elif not is_streaming and params.output_kind == RequestOutputKind.DELTA:
|
||||
logger.warning("Request appears to not be streaming, but got request type delta!")
|
||||
logger.debug("Coercing DELTA output to FINAL_ONLY for non-streaming")
|
||||
|
||||
if not params.skip_clone:
|
||||
params = params.clone()
|
||||
|
||||
Reference in new issue
Block a user