mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-08 19:25:51 +08:00
[Bugfix] Fix default MM LoRA alignment for single str prompts (#29140)
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
This commit is contained in:
parent
30b9c67743
commit
b4734b9550
@ -5,7 +5,9 @@ Tests for applying default registered multimodal loras.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import unittest.mock as mock
|
||||||
|
|
||||||
|
import pytest
|
||||||
from huggingface_hub import snapshot_download
|
from huggingface_hub import snapshot_download
|
||||||
|
|
||||||
from vllm.lora.request import LoRARequest
|
from vllm.lora.request import LoRARequest
|
||||||
@ -114,3 +116,36 @@ def test_default_mm_lora_fails_with_overridden_lora_request(
|
|||||||
default_mm_loras={"audio": IMAGE_LORA_PATH},
|
default_mm_loras={"audio": IMAGE_LORA_PATH},
|
||||||
expected_suffix=RESPONSE_SUFFIX_WITH_LORA,
|
expected_suffix=RESPONSE_SUFFIX_WITH_LORA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_mm_lora_does_not_expand_string_reqs(vllm_runner):
|
||||||
|
class MockEngineException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Regression test for ensuring default multimodal lora resolution
|
||||||
|
# does not expand the lora req if the prompt type is a string.
|
||||||
|
vllm_runner_kwargs = {
|
||||||
|
**VLLM_RUNNER_BASE_KWARGS,
|
||||||
|
**{"default_mm_loras": {"audio": AUDIO_LORA_PATH}},
|
||||||
|
}
|
||||||
|
|
||||||
|
# Avoid the full generation call since these tests are expensive;
|
||||||
|
# just check what lora request is actually submitted to the engine
|
||||||
|
mock_err = "Engine is mocked for this test"
|
||||||
|
|
||||||
|
with (
|
||||||
|
mock.patch(
|
||||||
|
"vllm.v1.engine.llm_engine.LLMEngine.add_request",
|
||||||
|
side_effect=MockEngineException(mock_err),
|
||||||
|
) as mock_add_request,
|
||||||
|
vllm_runner(**vllm_runner_kwargs) as vllm_model,
|
||||||
|
):
|
||||||
|
# Die once we actually submit the request to the engine
|
||||||
|
with pytest.raises(MockEngineException):
|
||||||
|
vllm_model.llm.generate(prompts=AUDIO_PROMPT)
|
||||||
|
|
||||||
|
# Then check to make sure the submitted lora request
|
||||||
|
# and text prompt were zipped together correctly
|
||||||
|
engine_args, engine_kwargs = mock_add_request.call_args
|
||||||
|
assert engine_kwargs["lora_request"] is None
|
||||||
|
assert engine_kwargs["prompt_text"] == AUDIO_PROMPT
|
||||||
|
|||||||
@ -466,7 +466,7 @@ class LLM:
|
|||||||
):
|
):
|
||||||
return lora_request
|
return lora_request
|
||||||
|
|
||||||
if not isinstance(prompts, Sequence):
|
if not isinstance(prompts, Sequence) or isinstance(prompts, str):
|
||||||
prompts = [prompts]
|
prompts = [prompts]
|
||||||
|
|
||||||
optional_loras = (
|
optional_loras = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user