-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
[Voxtral] Add more tests #21010
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
Merged
[Voxtral] Add more tests #21010
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,115 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import json | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
| from mistral_common.audio import Audio | ||
| from mistral_common.protocol.instruct.messages import (AudioChunk, RawAudio, | ||
| TextChunk, UserMessage) | ||
|
|
||
| from vllm.transformers_utils.tokenizer import MistralTokenizer | ||
|
|
||
| from ....conftest import AudioTestAssets | ||
| from ....utils import RemoteOpenAIServer | ||
| from .test_ultravox import MULTI_AUDIO_PROMPT, run_multi_audio_test | ||
|
|
||
| MODEL_NAME = "mistralai/Voxtral-Mini-3B-2507" | ||
| MISTRAL_FORMAT_ARGS = [ | ||
| "--tokenizer_mode", "mistral", "--config_format", "mistral", | ||
| "--load_format", "mistral" | ||
| ] | ||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def server(request, audio_assets: AudioTestAssets): | ||
| args = [ | ||
| "--enforce-eager", | ||
| "--limit-mm-per-prompt", | ||
| json.dumps({"audio": len(audio_assets)}), | ||
| ] + MISTRAL_FORMAT_ARGS | ||
|
|
||
| with RemoteOpenAIServer(MODEL_NAME, | ||
| args, | ||
| env_dict={"VLLM_AUDIO_FETCH_TIMEOUT": | ||
| "30"}) as remote_server: | ||
| yield remote_server | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture | ||
| async def client(server): | ||
| async with server.get_async_client() as async_client: | ||
| yield async_client | ||
|
|
||
|
|
||
| def _get_prompt(audio_assets, question): | ||
| tokenizer = MistralTokenizer.from_pretrained(MODEL_NAME) | ||
|
|
||
| audios = [ | ||
| Audio.from_file(str(audio_assets[i].get_local_path()), strict=False) | ||
| for i in range(len(audio_assets)) | ||
| ] | ||
| audio_chunks = [ | ||
| AudioChunk(input_audio=RawAudio.from_audio(audio)) for audio in audios | ||
| ] | ||
|
|
||
| text_chunk = TextChunk(text=question) | ||
| messages = [UserMessage(content=[*audio_chunks, text_chunk]).to_openai()] | ||
|
|
||
| return tokenizer.apply_chat_template(messages=messages) | ||
|
|
||
|
|
||
| @pytest.mark.core_model | ||
| @pytest.mark.parametrize("dtype", ["half"]) | ||
| @pytest.mark.parametrize("max_tokens", [128]) | ||
| @pytest.mark.parametrize("num_logprobs", [5]) | ||
| def test_models_with_multiple_audios(vllm_runner, | ||
| audio_assets: AudioTestAssets, dtype: str, | ||
| max_tokens: int, | ||
| num_logprobs: int) -> None: | ||
| vllm_prompt = _get_prompt(audio_assets, MULTI_AUDIO_PROMPT) | ||
| run_multi_audio_test( | ||
| vllm_runner, | ||
| [(vllm_prompt, [audio.audio_and_sample_rate | ||
| for audio in audio_assets])], | ||
| MODEL_NAME, | ||
| dtype=dtype, | ||
| max_tokens=max_tokens, | ||
| num_logprobs=num_logprobs, | ||
| tokenizer_mode="mistral", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_online_serving(client, audio_assets: AudioTestAssets): | ||
| """Exercises online serving with/without chunked prefill enabled.""" | ||
|
|
||
| def asset_to_chunk(asset): | ||
| audio = Audio.from_file(str(asset.get_local_path()), strict=False) | ||
| audio.format = "wav" | ||
| audio_dict = AudioChunk.from_audio(audio).to_openai() | ||
| return audio_dict | ||
|
|
||
| audio_chunks = [asset_to_chunk(asset) for asset in audio_assets] | ||
| messages = [{ | ||
| "role": | ||
| "user", | ||
| "content": [ | ||
| *audio_chunks, | ||
| { | ||
| "type": | ||
| "text", | ||
| "text": | ||
| f"What's happening in these {len(audio_assets)} audio clips?" | ||
| }, | ||
| ], | ||
| }] | ||
|
|
||
| chat_completion = await client.chat.completions.create(model=MODEL_NAME, | ||
| messages=messages, | ||
| max_tokens=10) | ||
|
|
||
| assert len(chat_completion.choices) == 1 | ||
| choice = chat_completion.choices[0] | ||
| assert choice.finish_reason == "length" |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this also need
--config_format mistral --load_format mistral?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah actually that'd be safer - good point. It doesn't need it if there are only "mistral" format weights, but as soon as we add transformers weights to the repo it probably breaks. Will open a quick fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah but can't set config_format or load_format - hmm should I add config_format and load_format then also to the
_HfExamplesInfoobject?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but you need to also update a bunch of tests where
HF_EXAMPLE_MODELSis being used to ensure the settings are being forwarded correctly to vLLMUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test starts failing for everyone on CI, i.e. https://buildkite.com/vllm/ci/builds/24375#01981fb2-e37e-44e5-a313-b157a4ffd669/8532-9390, after https://huggingface.co/mistralai/Voxtral-Mini-3B-2507/commit/c63c83ed2e3bbb75da6f2bf67f9a499690c1e689#d2h-457069 was committed to HF today. It looks like a new transformers package is needed, but it's not public yet
4.54.0.dev0. Would there be any short-term mitigation to keep CI sane until we have that?