-
-
Notifications
You must be signed in to change notification settings - Fork 21k
feat[vLLM × v5]: Add audio support for the Transformers backend #39330
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
vllm-bot
merged 35 commits into
vllm-project:main
from
harshaljanjani:feat/audio-encoder-transformers-backend
Jul 25, 2026
Merged
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e6527d1
feat: Add audio encoder support for transformers backend
harshaljanjani 5cfa34d
Merge branch 'main' into feat/audio-encoder-transformers-backend
harshaljanjani 934198d
refactor: Simplify after ALM standardization
harshaljanjani 86f684d
nit: Fix garbled outputs
harshaljanjani 04bcbec
refactor: Resolve review comments
harshaljanjani ad19ea3
chore: Make linter happy :)
harshaljanjani ae28a0f
refactor: Resolve second review round
harshaljanjani 75a56d4
Merge branch 'main' into feat/audio-encoder-transformers-backend
harshaljanjani 3bd5704
fix: Remove fetch_audio()
harshaljanjani 213d138
fix: Improve get_max_audio_tokens()
harshaljanjani 3e03ddc
refactor: Address Transformers PR init review
harshaljanjani 2ca58cb
Merge remote-tracking branch 'upstream/main' into feat/audio-encoder-…
harshaljanjani b81f97c
refactor: Revert based on Transformers companion PR change
harshaljanjani 8312853
nit: Fix outputs after Transformers sync
harshaljanjani 5b9b7d0
fix: Add minimum version
harshaljanjani b36ea89
Merge remote-tracking branch 'upstream/main' into feat/audio-encoder-…
harshaljanjani d94c3d5
fix: Regenerate audio fixtures post-merge
harshaljanjani 0dd0a81
refactor: Resolve review comments 2
harshaljanjani 12afe2b
nit: Revert after Transformers sync
harshaljanjani ebcf161
Merge branch 'main' into feat/audio-encoder-transformers-backend
harshaljanjani b5025a4
refactor: Resolve review comments 3
harshaljanjani d162f95
feat: Add VibeVoiceAsr to registry
harshaljanjani 0b703e6
Merge branch 'main' into pr/harshaljanjani/39330
hmellor 7211088
update doc
hmellor 696927b
add multi input tests
hmellor ddd29f0
Update version checks
hmellor a2fe328
fix: Fix tests - 1
harshaljanjani 36bbd19
refactor: Refactor tests
harshaljanjani a7da743
fix: Support models with separate PEFT adapters
harshaljanjani da0bd05
Merge branch 'main' into feat/audio-encoder-transformers-backend
mergify[bot] fc25b16
Merge branch 'main' into feat/audio-encoder-transformers-backend
hmellor dbdd63d
fix: Bump VibeVoice ver and remove skip
harshaljanjani f0c2a9f
revert: Revert dbdd6
harshaljanjani 3d1a3aa
Merge branch 'main' into feat/audio-encoder-transformers-backend
hmellor ec7a678
Merge branch 'main' into feat/audio-encoder-transformers-backend
hmellor 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
164 changes: 164 additions & 0 deletions
164
tests/models/multimodal/processing/test_transformers_audio.py
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,164 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| import numpy as np | ||
| import pytest | ||
|
|
||
| from vllm import SamplingParams | ||
| from vllm.config import ModelConfig | ||
| from vllm.envs import disable_envs_cache | ||
| from vllm.multimodal import MULTIMODAL_REGISTRY | ||
|
|
||
| AUDIO_MODEL_SETTINGS = { | ||
| "ibm-granite/granite-speech-3.3-2b": { | ||
| "prompt": ( | ||
| "<|start_of_role|>system<|end_of_role|>" | ||
| "You are a helpful AI assistant<|end_of_text|>\n" | ||
| "<|start_of_role|>user<|end_of_role|>" | ||
| "<|audio|>can you transcribe the speech into a written format?" | ||
| "<|end_of_text|>\n" | ||
| "<|start_of_role|>assistant<|end_of_role|>" | ||
| ), | ||
| }, | ||
| "nvidia/audio-flamingo-3-hf": { | ||
| "prompt": ( | ||
| "<|im_start|>system\n" | ||
| "You are a helpful assistant.<|im_end|>\n" | ||
| "<|im_start|>user\n" | ||
| "<sound>Transcribe the input speech.<|im_end|>\n" | ||
| "<|im_start|>assistant\n" | ||
| ), | ||
| }, | ||
| "mistralai/Voxtral-Mini-3B-2507": { | ||
| "prompt": ("[INST][AUDIO]What can you tell me about this audio?[/INST]"), | ||
| }, | ||
| "microsoft/VibeVoice-ASR-HF": { | ||
| "prompt": ( | ||
| "<|im_start|>system\n" | ||
| "You are a helpful assistant that transcribes audio input " | ||
| "into text output in JSON format.<|im_end|>\n" | ||
| "<|im_start|>user\n" | ||
| "<|object_ref_start|><|box_start|><|object_ref_end|>\n" | ||
| "This is a 1.0 seconds audio, please transcribe it with " | ||
| "these keys: Start time, End time, Speaker ID, Content" | ||
| "<|im_end|>\n" | ||
| "<|im_start|>assistant\n" | ||
| ), | ||
| }, | ||
| "zai-org/GLM-ASR-Nano-2512": { | ||
| "prompt": ( | ||
| "<|user|>\n" | ||
| "<|begin_of_audio|><|pad|><|end_of_audio|><|user|>\n" | ||
| "Please transcribe this audio into text" | ||
| "<|assistant|>\n" | ||
| ), | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model_id", | ||
| [ | ||
| "ibm-granite/granite-speech-3.3-2b", | ||
| "nvidia/audio-flamingo-3-hf", | ||
| pytest.param( | ||
| "mistralai/Voxtral-Mini-3B-2507", | ||
| marks=pytest.mark.xfail( | ||
| reason="MistralCommonBackend tokenizer does not produce audio " | ||
| "placeholder token (ID 24) from text; requires " | ||
| "apply_chat_template path", | ||
| strict=False, | ||
| ), | ||
| ), | ||
|
hmellor marked this conversation as resolved.
|
||
| "microsoft/VibeVoice-ASR-HF", | ||
| "zai-org/GLM-ASR-Nano-2512", | ||
| ], | ||
| ) | ||
| def test_audio_multimodal_processor(model_id): | ||
| settings = AUDIO_MODEL_SETTINGS[model_id] | ||
|
|
||
| model_config = ModelConfig( | ||
| model=model_id, | ||
| model_impl="transformers", | ||
| ) | ||
|
|
||
| mm_processor = MULTIMODAL_REGISTRY.create_processor(model_config) | ||
|
|
||
| audio = np.zeros(16000, dtype=np.float32) | ||
| mm_data = {"audio": (audio, 16000)} | ||
|
|
||
| result = mm_processor( | ||
| prompt=settings["prompt"], | ||
| mm_items=mm_processor.info.parse_mm_data(mm_data), | ||
| hf_processor_mm_kwargs={}, | ||
| ) | ||
|
|
||
| assert "prompt_token_ids" in result | ||
| assert len(result["prompt_token_ids"]) > 0 | ||
|
|
||
| mm_placeholders = result.get("mm_placeholders", {}) | ||
| assert "audio" in mm_placeholders, f"No audio placeholders found for {model_id}" | ||
| assert len(mm_placeholders["audio"]) == 1 | ||
|
|
||
| placeholder = mm_placeholders["audio"][0] | ||
| assert placeholder.length > 0 | ||
| assert placeholder.offset >= 0 | ||
|
|
||
| audio_items = result.get("mm_kwargs", {}).get("audio", []) | ||
| assert len(audio_items) == 1, f"Expected 1 audio item, got {len(audio_items)}" | ||
| item_keys = list(audio_items[0].keys()) | ||
| has_features = "input_features" in item_keys or "input_values" in item_keys | ||
| assert has_features, ( | ||
| f"No audio features (input_features/input_values) in {item_keys} for {model_id}" | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model_id", | ||
| [ | ||
| "ibm-granite/granite-speech-3.3-2b", | ||
| "nvidia/audio-flamingo-3-hf", | ||
| pytest.param( | ||
| "mistralai/Voxtral-Mini-3B-2507", | ||
| marks=pytest.mark.xfail( | ||
| reason="MistralCommonBackend tokenizer does not produce audio " | ||
| "placeholder token (ID 24) from text; requires " | ||
| "apply_chat_template path", | ||
| strict=False, | ||
| ), | ||
| ), | ||
| "microsoft/VibeVoice-ASR-HF", | ||
| "zai-org/GLM-ASR-Nano-2512", | ||
| ], | ||
| ) | ||
| def test_audio_model_loading(monkeypatch, vllm_runner, model_id): | ||
| """Single-process workaround for V1 fork safety deadlock issue | ||
| (vllm-project/vllm/issues/17676). Running multiple audio models together | ||
| under pytest can cause (possibly flaky) hangs, so they are grouped under | ||
| the same config. Using VLLM_WORKER_MULTIPROC_METHOD=spawn avoids the | ||
| deadlock and allows worker processes to terminate cleanly, and release | ||
| GPU memory between test runs until the issue is fixed.""" | ||
| # TODO: Remove monkeypatch once | ||
| # https://github.com/vllm-project/vllm/issues/17676 is fixed. | ||
| disable_envs_cache() | ||
| monkeypatch.setenv("VLLM_WORKER_MULTIPROC_METHOD", "spawn") | ||
|
|
||
| settings = AUDIO_MODEL_SETTINGS[model_id] | ||
|
|
||
| with vllm_runner( | ||
| model_id, | ||
| model_impl="transformers", | ||
| max_model_len=2048, | ||
| enforce_eager=True, | ||
| limit_mm_per_prompt={"audio": 1}, | ||
| ) as vllm_model: | ||
| model_config = vllm_model.llm.llm_engine.model_config | ||
| assert model_config.using_transformers_backend() | ||
|
|
||
| audio = np.zeros(16000 * 2, dtype=np.float32) | ||
| outputs = vllm_model.generate( | ||
| prompts=[settings["prompt"]], | ||
| sampling_params=SamplingParams(max_tokens=16, temperature=0.0), | ||
| audios=[(audio, 16000)], | ||
| ) | ||
| assert len(outputs) == 1 | ||
| assert len(outputs[0][1]) > 0 | ||
|
hmellor marked this conversation as resolved.
Outdated
|
||
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
Oops, something went wrong.
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.