[Model] Add Gepard-1.0 OpenAI /v1/audio/speech serving (#7499)

Signed-off-by: Mengjie Zhao <zmj0129@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Mengjie ZhaoandCursor authored and GitHub committed 2026-09-15 14:56:51 -07:00
1 parent 78934753ff
commit c17126c219
17 files changed
+1329 -25

No files matched your search

+34 -15
View File
@@ -53,6 +53,7 @@ from vllm_omni.entrypoints.openai.speech_usage import (
qwen3_tts_input_token_details,
)
from vllm_omni.entrypoints.openai.tts_adapters import (
OutputPolicy,
SpeechServingContext,
TTSGenerationError,
all_tts_stage_keys,
@@ -396,6 +397,11 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
self._max_instructions_length = self._compute_max_instructions_length()
self._tts_tokenizer = None
# Per-request output policy from the adapter's PreparedRequest. Keyed
# by request_id so concurrent speech requests cannot overwrite each
# other. Stored only for non-streaming requests and consumed (popped)
# by the non-streaming accumulator in `_generate_audio_bytes`.
self._speech_output_policies: dict[str, OutputPolicy] = {}
# Batch configuration
self._batch_max_items: int = getattr(self.engine_client, "tts_batch_max_items", 32)
@@ -1872,6 +1878,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
tts_params = prepared.tts_params
model_type = prepared.model_type
qwen3_ref_audio_warmup_artifact_key = prepared.warmup_artifact_key
output_policy = prepared.output_policy
else:
# Qwen omni models (Qwen3-Omni, Qwen2.5-Omni) use a "talker"
# stage whose preprocess requires chat-templated tokens. The
@@ -1893,6 +1900,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
)
tts_params = {}
prompt = {"prompt": request.input}
output_policy = OutputPolicy()
if model_type is None:
if self._is_tts:
@@ -1962,6 +1970,13 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
qwen3_ref_audio_warmup_artifact_key,
x_vector_only=self._tts_x_vector_only(tts_params),
)
# Only the non-streaming path consumes output policies (in
# `_generate_audio_bytes`); streaming never reads them. Store late —
# after every fallible step above — and skip streaming requests
# entirely, so no caller has to discard entries (request ids are
# unique per request, so a stranded entry would never be reclaimed).
if not request.is_streaming():
self._speech_output_policies[request_id] = output_policy
return request_id, generator, tts_params
async def _generate_pcm_chunks(
@@ -2041,13 +2056,17 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
artifact_ready = False
try:
# MOSS-TTS-Nano emits delta chunks per yield (single-stage,
# async_chunk=false). The engine surfaces each yield as its own
# RequestOutput, so we need to accumulate across the async-for loop —
# final_output alone only carries the last (often empty) sentinel.
is_moss = self._tts_model_type == "moss_tts_nano"
moss_chunks: list[Any] = []
moss_sample_rate: int | None = None
# Sparse-audio models (MOSS-TTS-Nano, Gepard) emit delta chunks per
# yield with async_chunk=false. The engine surfaces each yield as its
# own RequestOutput, so we accumulate across the async-for loop when
# the adapter asks for it — final_output alone may only carry the
# last (often empty) sentinel. Prefer the engine's own concatenated
# waveform when FINAL_ONLY already produced one.
accumulate_nonstreaming = self._speech_output_policies.pop(
request_id, OutputPolicy()
).accumulate_nonstreaming
delta_chunks: list[Any] = []
delta_sample_rate: int | None = None
final_output: OmniRequestOutput | None = None
# Non-streaming is FINAL_ONLY, so the stage-0 output carries the full
@@ -2067,7 +2086,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
_, audio_key = self._extract_audio_output(res)
if audio_key is not None:
audio_res = res
if not is_moss:
if not accumulate_nonstreaming:
continue
try:
step_audio, step_key = self._extract_audio_output(res)
@@ -2080,11 +2099,11 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
candidates = chunk if isinstance(chunk, list) else [chunk]
for cand in candidates:
if hasattr(cand, "numel") and cand.numel() > 0:
moss_chunks.append(cand)
delta_chunks.append(cand)
sr_step = step_audio.get("sr")
if sr_step is not None:
sr_val_step = sr_step[-1] if isinstance(sr_step, list) and sr_step else sr_step
moss_sample_rate = int(sr_val_step.item()) if hasattr(sr_val_step, "item") else int(sr_val_step)
delta_sample_rate = int(sr_val_step.item()) if hasattr(sr_val_step, "item") else int(sr_val_step)
if final_output is None:
raise ValueError("No output generated from the model.")
@@ -2117,7 +2136,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
sr_val = sr_raw[-1] if isinstance(sr_raw, list) and sr_raw else sr_raw
sample_rate = sr_val.item() if hasattr(sr_val, "item") else int(sr_val)
if is_moss:
if accumulate_nonstreaming:
# Prefer the engine's own consolidated audio when present. After the
# vllm 0.20 rebase non-stream requests resolve to FINAL_ONLY, so
# final_output already carries the full concatenated waveform; the
@@ -2133,12 +2152,12 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
if final_audio is not None:
audio_tensor = final_audio
elif moss_chunks:
audio_tensor = torch.cat(moss_chunks, dim=-1)
elif delta_chunks:
audio_tensor = torch.cat(delta_chunks, dim=-1)
else:
audio_tensor = np.zeros((0,), dtype=np.float32)
if moss_sample_rate is not None:
sample_rate = moss_sample_rate
if delta_sample_rate is not None:
sample_rate = delta_sample_rate
elif isinstance(audio_tensor, list):
async_chunk = bool(getattr(self.engine_client.model_config, "async_chunk", False))
if async_chunk: