[CosyVoice3] Fix vLLM 0.19.0 compatibility issues (#2486)

This commit is contained in:
Yueqian Lin authored and GitHub committed 2026-04-05 08:45:49 +08:00
1 parent 0cf38197a0
commit d92439c155
6 files changed
+40 -4

No files matched your search

@@ -7,6 +7,8 @@ class CosyVoice3Config(PretrainedConfig):
model_type = "cosyvoice3"
def __init__(self, **kwargs):
# Set speech EOS so vLLM stops generation at the right token
kwargs.setdefault("eos_token_id", 6562)
super().__init__(**kwargs)
self.sample_rate = 24000
self.llm_input_size = 896
@@ -432,7 +432,7 @@ class CosyVoice3Model(
return OmniOutput(
text_hidden_states=None,
multimodal_outputs={"audio": tts_speech, "sr": 22050},
multimodal_outputs={"audio": tts_speech, "sr": torch.tensor(22050)},
)
else:
raise ValueError(f"Unsupported model_stage: {self.model_stage}")
@@ -192,8 +192,10 @@ class CosyVoice3Code2Wav(nn.Module):
# Create mask
mask = (~make_pad_mask(full_token_len)).unsqueeze(-1).to(embedding)
# Token embedding
token_emb = self.input_embedding(torch.clamp(full_token, min=0)) * mask
# Token embedding (clamp to valid codebook range; EOS/padding tokens may exceed vocab_size)
token_emb = (
self.input_embedding(torch.clamp(full_token, min=0, max=self.input_embedding.num_embeddings - 1)) * mask
)
# Pre-lookahead processing
h = self.pre_lookahead_layer(token_emb)