[Bugfix][Multimodal] Restore cached audio inputs with UUIDs (#56310)

Signed-off-by: JiataiWang <wangjiatai@proton.me>
Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
Jiatai Wang
2026-09-10 19:20:03 +00:00
committed by GitHub
co-authored by OpenAI Codex
parent 7de70fa7ae
commit a36dfc93cb
4 changed files with 32 additions and 5 deletions
@@ -2384,8 +2384,10 @@ def test_parse_chat_messages_include_thinking_chunk(mistral_model_config):
assert conversation_with_thinking == expected_conversation
@pytest.mark.parametrize("input_audio", [None, {}, {"data": "", "format": "wav"}])
def test_parse_chat_messages_single_empty_audio_with_uuid(
qwen2_audio_model_config,
input_audio,
):
audio_uuid = "abcd"
conversation, mm_data, mm_uuids = parse_chat_messages(
@@ -2395,7 +2397,7 @@ def test_parse_chat_messages_single_empty_audio_with_uuid(
"content": [
{
"type": "input_audio",
"input_audio": {},
"input_audio": input_audio,
"uuid": audio_uuid,
},
{"type": "text", "text": "What does the audio say?"},
@@ -2418,8 +2420,10 @@ def test_parse_chat_messages_single_empty_audio_with_uuid(
@pytest.mark.asyncio
@pytest.mark.parametrize("input_audio", [None, {}, {"data": "", "format": "wav"}])
async def test_parse_chat_messages_single_empty_audio_with_uuid_async(
qwen2_audio_model_config,
input_audio,
):
audio_uuid = "abcd"
conversation, mm_data, mm_uuids = await parse_chat_messages_async(
@@ -2429,7 +2433,7 @@ async def test_parse_chat_messages_single_empty_audio_with_uuid_async(
"content": [
{
"type": "input_audio",
"input_audio": {},
"input_audio": input_audio,
"uuid": audio_uuid,
},
{"type": "text", "text": "What does the audio say?"},
+18
View File
@@ -6,6 +6,7 @@ import torch
from PIL import Image
from vllm.multimodal.parse import (
AudioProcessorItems,
ImageProcessorItems,
MultiModalDataParser,
VideoProcessorItems,
@@ -58,6 +59,7 @@ def test_frame_size_hwc_chw(frame):
@pytest.mark.parametrize(
"modality,processor_cls",
[
("audio", AudioProcessorItems),
("image", ImageProcessorItems),
("video", VideoProcessorItems),
],
@@ -68,3 +70,19 @@ def test_parse_mm_data_accepts_none_cached_item(modality, processor_cls):
assert isinstance(items, processor_cls)
assert len(items) == 1
assert items.get(0) is None
def test_cached_audio_items_preserve_positions_during_resampling():
waveform = np.arange(16, dtype=np.float32)
parser = MultiModalDataParser(
target_sr=16000, target_channels=1, audio_resample_method="scipy"
)
items = parser.parse_mm_data(
{"audio": [None, (waveform, 8000), None, (waveform, 16000)]}
)["audio"]
assert len(items) == 4
assert items.get(0) is None
assert items.get(2) is None
assert len(items.get(1)) == 32
np.testing.assert_array_equal(items.get(3), waveform)