[Core][Model] Enable Qwen3-TTS MRV2 and optimize the TTS pipeline (#7781)

Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
Sy03 authored and GitHub committed 2026-09-20 23:03:08 -07:00
1 parent d139c600c7
commit a9e2117f5e
103 files changed
+10232 -661

No files matched your search

+56 -2
View File
@@ -6,18 +6,72 @@ from typing import Any
import torch
from vllm.logger import init_logger
from vllm.sampling_params import SamplingParams
from vllm.v1.sample.logits_processor import LogitsProcessors, MinTokensLogitsProcessor
logger = init_logger(__name__)
__all__ = [
"build_model_sampler_extra_args",
"call_model_sampler",
"apply_fixed_seed_to_sampling_params",
"get_tts_local_seed",
"clamp_prompt_ids_to_penalty_padding",
"sanitize_min_tokens_stop_ids",
"sanitize_sampling_params_min_tokens_stop_ids",
"build_model_sampler_extra_args",
"call_model_sampler",
]
def get_tts_local_seed(sampling_params: Any) -> int | None:
"""Return the explicit per-request Talker MTP seed, if configured."""
extra_args = getattr(sampling_params, "extra_args", None) if sampling_params is not None else None
seed = extra_args.get("tts_local_seed") if isinstance(extra_args, dict) else None
return int(seed) if seed is not None else None
def apply_fixed_seed_to_sampling_params(
sampling_params: Any,
seed: int,
*,
seed_talker_mtp: bool,
) -> None:
"""Apply one request seed to a stage sampler and, for Talkers, its MTP RNG."""
seed = int(seed)
sampling_params.seed = seed
if not seed_talker_mtp:
return
extra_args = dict(getattr(sampling_params, "extra_args", None) or {})
extra_args["tts_local_seed"] = seed
sampling_params.extra_args = extra_args
def sanitize_sampling_params_min_tokens_stop_ids(
sampling_params: SamplingParams,
logits_vocab: int,
) -> None:
"""Remove unreachable ids before MRv2 builds persistent min-token state.
MRv2 copies ``SamplingParams.all_stop_token_ids`` into GPU-resident
``LogitBiasState`` when a request is registered. Narrow codec heads cannot
safely carry the text tokenizer EOS in that state. The engine-facing EOS
and explicit ``stop_token_ids`` fields remain unchanged; only the set used
by the sampler's min-token mask is normalized.
"""
if sampling_params.min_tokens <= 0:
return
stop_token_ids = sampling_params.all_stop_token_ids
unreachable = {token_id for token_id in stop_token_ids if token_id < 0 or token_id >= logits_vocab}
if not unreachable:
return
stop_token_ids.difference_update(unreachable)
logger.warning_once(
"min_tokens: dropped stop token ids %s that exceed the logits vocabulary (%d); "
"the model head cannot emit them.",
str(sorted(unreachable)),
logits_vocab,
)
def build_model_sampler_extra_args(input_batch: Any, requests: Any) -> list[dict | None]:
"""Return per-request ``SamplingParams.extra_args`` in batch-row order."""
request_states = requests or {}