-
Notifications
You must be signed in to change notification settings - Fork 941
[Bugfix][Refactor] Migrate Voxtral TTS config and parser registry #3065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
princepride
merged 6 commits into
vllm-project:main
from
yuanheng-zhao:fix/voctral-tts-registry
Apr 25, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ec407f3
migrarte voxtral tts config/parser to transformers_utils
yuanheng-zhao 899aa84
deprecate redundant path
yuanheng-zhao ce837e5
trivial
yuanheng-zhao d2d5acc
renmae
yuanheng-zhao 64ead38
Merge branch 'main' into fix/voctral-tts-registry
yuanheng-zhao 414ea72
Merge branch 'main' into fix/voctral-tts-registry
yuanheng-zhao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 0 additions & 108 deletions
108
vllm_omni/model_executor/models/voxtral_tts/configuration_voxtral_tts.py
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from transformers import AutoConfig, PretrainedConfig | ||
|
|
||
|
|
||
| class VoxtralTTSConfig(PretrainedConfig): | ||
| """HuggingFace-style config for Voxtral TTS models.""" | ||
|
|
||
| model_type = "voxtral_tts" | ||
|
|
||
| def __init__( | ||
| self, | ||
| text_config: PretrainedConfig | dict | None = None, | ||
| audio_config: dict[str, Any] | None = None, | ||
| **kwargs: Any, | ||
| ) -> None: | ||
| super().__init__(**kwargs) | ||
|
|
||
| if isinstance(text_config, PretrainedConfig): | ||
| self.text_config = text_config | ||
| elif isinstance(text_config, dict): | ||
| self.text_config = PretrainedConfig.from_dict(text_config) | ||
| else: | ||
| self.text_config = PretrainedConfig() | ||
|
|
||
| self.audio_config = audio_config or {} | ||
|
|
||
| def get_text_config(self, **kwargs: Any) -> PretrainedConfig: | ||
| return self.text_config | ||
|
|
||
|
|
||
| AutoConfig.register("voxtral_tts", VoxtralTTSConfig) | ||
|
|
||
| __all__ = ["VoxtralTTSConfig"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| """Custom vLLM config parsers for vllm-omni.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import importlib | ||
|
|
||
| _CLASS_TO_MODULE: dict[str, str] = { | ||
| "VoxtralTTSConfigParser": "vllm_omni.transformers_utils.parsers.voxtral_tts", | ||
| } | ||
|
|
||
| __all__ = ["VoxtralTTSConfigParser"] | ||
|
|
||
|
|
||
| def __getattr__(name: str): | ||
| if name in _CLASS_TO_MODULE: | ||
| module_name = _CLASS_TO_MODULE[name] | ||
| module = importlib.import_module(module_name) | ||
| return getattr(module, name) | ||
|
|
||
| raise AttributeError(f"module 'vllm_omni.transformers_utils.parsers' has no attribute {name!r}") | ||
|
|
||
|
|
||
| def __dir__(): | ||
| return sorted(list(__all__)) | ||
|
|
||
|
|
||
| # Eagerly import parser modules so their registry side-effects run as soon as | ||
| # `vllm_omni.transformers_utils.parsers` is imported. | ||
| from vllm_omni.transformers_utils.parsers import voxtral_tts as _voxtral_tts # noqa: F401, E402 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| from transformers import PretrainedConfig | ||
| from vllm.logger import init_logger | ||
| from vllm.transformers_utils.config import ( | ||
| _CONFIG_FORMAT_TO_CONFIG_PARSER, | ||
| MistralConfigParser, | ||
| _download_mistral_config_file, | ||
| ) | ||
|
|
||
| from vllm_omni.transformers_utils.configs.voxtral_tts import VoxtralTTSConfig | ||
|
|
||
| logger = init_logger(__name__) | ||
|
|
||
| _VOXTRAL_TTS_ARCHS = frozenset({"VoxtralTTSForConditionalGeneration"}) | ||
| _VOXTRAL_TTS_MODEL_TYPE = "voxtral_tts" | ||
|
|
||
|
|
||
| def _is_voxtral_tts_params(config_dict: dict) -> bool: | ||
| """Return True if the Mistral params.json describes a Voxtral-TTS model""" | ||
| if config_dict.get("model_type") == _VOXTRAL_TTS_MODEL_TYPE: | ||
| return True | ||
| architectures = set(config_dict.get("architectures") or []) | ||
| return bool(architectures & _VOXTRAL_TTS_ARCHS) | ||
|
|
||
|
|
||
| def _remap_voxtral_tts_audio_args(config_dict: dict) -> dict: | ||
| encoder_args = config_dict["multimodal"].pop("audio_model_args") | ||
| audio_tokenizer_args = config_dict["multimodal"].pop("audio_tokenizer_args", None) | ||
| if encoder_args is None: | ||
| return {} | ||
|
|
||
| acoustic_args = encoder_args.get("acoustic_transformer_args", {}) | ||
| if acoustic_args.get("n_decoding_steps") is None: | ||
| logger.warning( | ||
| "n_decoding_steps not provided in acoustic_transformer_args, defaulting to 7. " | ||
| "Please add 'n_decoding_steps' to params.json under acoustic_transformer_args." | ||
| ) | ||
| acoustic_args["n_decoding_steps"] = 7 | ||
|
|
||
| return { | ||
| "sampling_rate": encoder_args["audio_encoding_args"]["sampling_rate"], | ||
| "codec_args": audio_tokenizer_args, | ||
| "audio_model_args": encoder_args, | ||
| "speaker_id": (audio_tokenizer_args or {}).get("voice", {}), | ||
| } | ||
|
|
||
|
|
||
| def _parse_voxtral_tts(config_dict: dict) -> tuple[dict, PretrainedConfig]: | ||
| from vllm.transformers_utils.configs.mistral import ( | ||
| _remap_general_mistral_args, | ||
| _remap_mistral_quantization_args, | ||
| ) | ||
|
|
||
| audio_config: dict[str, Any] = {} | ||
| if (config_dict.get("multimodal") or {}).get("audio_model_args"): | ||
| audio_config = _remap_voxtral_tts_audio_args(config_dict) | ||
|
|
||
| text_config = {k: v for k, v in config_dict.items() if k != "multimodal"} | ||
| text_config = _remap_general_mistral_args(text_config) | ||
| if text_config.get("quantization"): | ||
| text_config = _remap_mistral_quantization_args(text_config) | ||
| text_config.setdefault("architectures", ["MistralForCausalLM"]) | ||
|
|
||
| config = VoxtralTTSConfig( | ||
| text_config=PretrainedConfig.from_dict(text_config), | ||
| audio_config=audio_config, | ||
| architectures=config_dict.get("architectures", ["VoxtralTTSForConditionalGeneration"]), | ||
| ) | ||
| return config_dict, config | ||
|
|
||
|
|
||
| class VoxtralTTSConfigParser(MistralConfigParser): | ||
| """Mistral parser that also recognizes Voxtral-TTS checkpoints.""" | ||
|
|
||
| def parse( | ||
| self, | ||
| model: str | Path, | ||
| trust_remote_code: bool, | ||
| revision: str | None = None, | ||
| code_revision: str | None = None, | ||
| **kwargs: Any, | ||
| ) -> tuple[dict, PretrainedConfig]: | ||
| config_dict = _download_mistral_config_file(model, revision) | ||
|
|
||
| if _is_voxtral_tts_params(config_dict): | ||
| return _parse_voxtral_tts(config_dict) | ||
|
|
||
| return super().parse( | ||
| model, | ||
| trust_remote_code, | ||
| revision=revision, | ||
| code_revision=code_revision, | ||
| **kwargs, | ||
| ) | ||
|
|
||
|
|
||
| # Replace the default "mistral" slot directly. | ||
| # Any non-Voxtral-TTS Mistral ckpt still goes through | ||
| # the upstream code path via super().parse(). | ||
| _CONFIG_FORMAT_TO_CONFIG_PARSER["mistral"] = VoxtralTTSConfigParser | ||
|
|
||
| __all__ = ["VoxtralTTSConfigParser"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.