[New Model] Support IndexTTS 2.5 (#5957)

Signed-off-by: Sysy <1370724210@qq.com>
Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
This commit is contained in:
Sy03andYueqian Lin authored and GitHub committed 2026-08-11 23:00:35 +00:00
1 parent 1ff2753469
commit 58007c0084
77 files changed
+7123 -519

No files matched your search

+152
View File
@@ -6,6 +6,9 @@ explicitly patch values that differ from vLLM.
import argparse
import inspect
import json
import os
import shutil
from types import SimpleNamespace
from unittest.mock import Mock
@@ -194,6 +197,155 @@ def test_qwen3_tts_code2wav_injects_max_position_embeddings(monkeypatch):
}
def test_patch_missing_local_hf_config(tmp_path):
"""Native model bundles may only contain a checkpoints/ directory."""
(tmp_path / "checkpoints").mkdir()
args = object.__new__(OmniEngineArgs)
args.model = str(tmp_path)
args.model_arch = "IndexTTS25TalkerForConditionalGeneration"
args.hf_config_path = None
try:
args._patch_empty_hf_config("indextts2_5")
assert args.hf_config_path is not None
config_path = args.hf_config_path + "/config.json"
with open(config_path, encoding="utf-8") as config_file:
config = json.load(config_file)
assert config == {
"model_type": "indextts2_5",
"architectures": ["IndexTTS25TalkerForConditionalGeneration"],
}
finally:
if hasattr(args, "_temp_config_dir"):
shutil.rmtree(args._temp_config_dir, ignore_errors=True)
@pytest.mark.parametrize(
"config_entry",
["malformed", "directory", "broken_symlink", "permission_error"],
)
def test_non_missing_local_hf_config_error_reaches_parent_loader(tmp_path, monkeypatch, config_entry):
"""Non-missing config errors must reach vLLM's normal loader."""
config_path = tmp_path / "config.json"
if config_entry == "malformed":
config_path.write_text("{not valid json", encoding="utf-8")
loader_error = json.JSONDecodeError("invalid config", "{not valid json", 1)
elif config_entry == "directory":
config_path.mkdir()
loader_error = IsADirectoryError(str(config_path))
elif config_entry == "broken_symlink":
config_path.symlink_to(tmp_path / "missing-target.json")
loader_error = FileNotFoundError(str(config_path))
else:
config_path.write_text("{}", encoding="utf-8")
loader_error = PermissionError(str(config_path))
parent_inputs = {}
def controlled_get_config_dict(cls, model, **kwargs):
if model == str(tmp_path):
raise loader_error
with open(os.path.join(model, "config.json"), encoding="utf-8") as config_file:
return json.load(config_file), {}
def fake_parent_create_model_config(self):
parent_inputs["called"] = True
parent_inputs["model"] = self.model
parent_inputs["hf_config_path"] = self.hf_config_path
config_root = self.hf_config_path or self.model
parent_inputs["config_root"] = config_root
return PretrainedConfig.get_config_dict(config_root)[0]
monkeypatch.setattr(PretrainedConfig, "get_config_dict", classmethod(controlled_get_config_dict))
monkeypatch.setattr(OmniEngineArgs, "_ensure_omni_models_registered", lambda self: True)
monkeypatch.setattr(EngineArgs, "create_model_config", fake_parent_create_model_config)
monkeypatch.setattr(
OmniModelConfig,
"from_vllm_model_config",
classmethod(lambda cls, model_config, **omni_kwargs: model_config),
)
args = OmniEngineArgs(
model=str(tmp_path),
model_arch="IndexTTS25TalkerForConditionalGeneration",
)
with pytest.raises(type(loader_error)) as exc_info:
args.create_model_config()
assert str(exc_info.value) == str(loader_error)
assert parent_inputs["called"] is True
assert parent_inputs["model"] == str(tmp_path)
assert parent_inputs["config_root"] == str(tmp_path)
assert parent_inputs["hf_config_path"] is None
assert args.model == str(tmp_path)
assert args.hf_config_path is None
assert not hasattr(args, "_temp_config_dir")
def test_patch_valid_hf_config_without_model_type_preserves_keys(tmp_path):
"""A valid partial config should be copied before required keys are added."""
original_config = {
"hidden_size": 1024,
"custom_key": {"nested": True},
}
(tmp_path / "config.json").write_text(json.dumps(original_config), encoding="utf-8")
args = object.__new__(OmniEngineArgs)
args.model = str(tmp_path)
args.model_arch = "IndexTTS25TalkerForConditionalGeneration"
args.hf_config_path = None
try:
args._patch_empty_hf_config("indextts2_5")
assert args.hf_config_path is not None
with open(os.path.join(args.hf_config_path, "config.json"), encoding="utf-8") as config_file:
patched_config = json.load(config_file)
assert patched_config["hidden_size"] == original_config["hidden_size"]
assert patched_config["custom_key"] == original_config["custom_key"]
assert patched_config["model_type"] == "indextts2_5"
assert patched_config["architectures"] == ["IndexTTS25TalkerForConditionalGeneration"]
finally:
if hasattr(args, "_temp_config_dir"):
shutil.rmtree(args._temp_config_dir, ignore_errors=True)
def test_remote_hf_config_error_reaches_parent_loader(monkeypatch):
"""Remote resolution failures must stay on vLLM's normal error path."""
loader_error = OSError("remote config resolution failed")
parent_inputs = {}
def controlled_get_config_dict(cls, model, **kwargs):
raise loader_error
def fake_parent_create_model_config(self):
parent_inputs["called"] = True
parent_inputs["model"] = self.model
parent_inputs["hf_config_path"] = self.hf_config_path
return PretrainedConfig.get_config_dict(self.model)[0]
monkeypatch.setattr(PretrainedConfig, "get_config_dict", classmethod(controlled_get_config_dict))
monkeypatch.setattr(OmniEngineArgs, "_ensure_omni_models_registered", lambda self: True)
monkeypatch.setattr(EngineArgs, "create_model_config", fake_parent_create_model_config)
args = OmniEngineArgs(
model="remote/model",
model_arch="IndexTTS25TalkerForConditionalGeneration",
)
with pytest.raises(OSError) as exc_info:
args.create_model_config()
assert str(exc_info.value) == str(loader_error)
assert parent_inputs["called"] is True
assert parent_inputs["model"] == "remote/model"
assert parent_inputs["hf_config_path"] is None
assert args.model == "remote/model"
assert args.hf_config_path is None
assert not hasattr(args, "_temp_config_dir")
def test_stage_specific_text_config_override():
"""Stage swap must refresh hf_text_config, dependent attrs, and model_arch_config."""
vllm_config = EngineArgs().create_model_config()
@@ -412,7 +412,7 @@ def test_stage_runtime_passes_log_stats_to_llm_replica_launch(monkeypatch):
monkeypatch.setattr(
runtime_mod.StageEngineCoreClientBase,
"make_async_mp_client",
lambda **kwargs: (captured.__setitem__("client_log_stats", kwargs["log_stats"]) or stage_client),
lambda **kwargs: captured.__setitem__("client_log_stats", kwargs["log_stats"]) or stage_client,
)
assert runtime._initialize_local_llm_replica(plan, stage_init_timeout=1) is stage_client
@@ -807,9 +807,9 @@ def test_build_stage0_input_processor_uses_omni_input_preprocessor(monkeypatch):
import vllm_omni.engine.stage_init_utils as init_mod
class DummyInputProcessor:
def __init__(self, vllm_config):
def __init__(self, vllm_config, renderer=None):
self.vllm_config = vllm_config
self.renderer = object()
self.renderer = renderer or object()
self.input_preprocessor = None
class DummyOmniInputPreprocessor:
@@ -828,6 +828,50 @@ def test_build_stage0_input_processor_uses_omni_input_preprocessor(monkeypatch):
assert input_processor.input_preprocessor.renderer is input_processor.renderer
def test_build_stage0_input_processor_does_not_resolve_tokenizer_when_skipped(
monkeypatch,
):
import vllm_omni.engine.stage_init_utils as init_mod
token_only_renderer = object()
seen = {}
class DummyInputProcessor:
def __init__(self, vllm_config, renderer=None):
if renderer is None:
raise AssertionError("skip_tokenizer_init must supply a renderer")
seen["renderer"] = renderer
self.renderer = renderer
self.input_preprocessor = None
class DummyOmniInputPreprocessor:
def __init__(self, vllm_config, renderer=None):
seen["preprocessor_renderer"] = renderer
monkeypatch.setattr(init_mod, "InputProcessor", DummyInputProcessor)
monkeypatch.setattr(
init_mod,
"_build_token_only_renderer",
lambda _config: token_only_renderer,
)
monkeypatch.setattr(
init_mod,
"OmniInputPreprocessor",
DummyOmniInputPreprocessor,
)
config = types.SimpleNamespace(
model_config=types.SimpleNamespace(
skip_tokenizer_init=True,
try_get_generation_config=lambda: {},
)
)
build_stage0_input_processor(config)
assert seen["renderer"] is token_only_renderer
assert seen["preprocessor_renderer"] is token_only_renderer
def test_inject_kv_stage_info_infers_sender_tp_topology():
from vllm_omni.engine.stage_init_utils import inject_kv_stage_info
+1
View File
@@ -52,6 +52,7 @@ def test_positional_construction_matches_base_request():
assert req.external_req_id is None
assert req.additional_information is None
assert req.prompt_embeds_payload is None
assert req.num_stale_output_tokens == 0
def test_positional_prompt_embeds_does_not_collide():