Skip to content

Commit 18016a5

Browse files
[Bugfix] Fix CI failures for InternVL and Mantis models (#12728)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent 649550f commit 18016a5

File tree

4 files changed

+79
-412
lines changed

4 files changed

+79
-412
lines changed

tests/models/decoder_only/vision_language/test_models.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Type
1010

1111
import pytest
12+
from packaging.version import Version
1213
from transformers import AutoModelForVision2Seq
1314
from transformers import __version__ as TRANSFORMERS_VERSION
1415

@@ -154,13 +155,7 @@
154155
stop_str=["<|im_end|>"],
155156
image_size_factors=[(0.10, 0.15)],
156157
max_tokens=64,
157-
marks=[
158-
pytest.mark.skipif(
159-
TRANSFORMERS_VERSION < "4.48.0",
160-
reason="HF model requires transformers>=4.48.0",
161-
),
162-
large_gpu_mark(min_gb=64),
163-
],
158+
marks=[large_gpu_mark(min_gb=64)],
164159
),
165160
"blip2": VLMTestInfo(
166161
models=["Salesforce/blip2-opt-2.7b"],
@@ -206,7 +201,7 @@
206201
image_size_factors=[(), (1.0, ), (1.0, 1.0, 1.0), (0.1, 0.5, 1.0)],
207202
marks=[
208203
pytest.mark.skipif(
209-
TRANSFORMERS_VERSION >= "4.48.0",
204+
Version(TRANSFORMERS_VERSION) >= Version("4.48"),
210205
reason="HF model is not compatible with transformers>=4.48.0",
211206
)
212207
],
@@ -339,6 +334,12 @@
339334
auto_cls=AutoModelForVision2Seq,
340335
vllm_output_post_proc=model_utils.mantis_vllm_to_hf_output,
341336
patch_hf_runner=model_utils.mantis_patch_hf_runner,
337+
marks=[
338+
pytest.mark.skipif(
339+
Version(TRANSFORMERS_VERSION) >= Version("4.48"),
340+
reason="HF model is not compatible with transformers>=4.48.0",
341+
)
342+
],
342343
),
343344
"minicpmv_25": VLMTestInfo(
344345
models=["openbmb/MiniCPM-Llama3-V-2_5"],

tests/models/registry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ def check_available_online(
224224

225225
_MULTIMODAL_EXAMPLE_MODELS = {
226226
# [Decoder-only]
227-
"AriaForConditionalGeneration": _HfExamplesInfo("rhymes-ai/Aria",
228-
min_transformers_version="4.48"),
227+
"AriaForConditionalGeneration": _HfExamplesInfo("rhymes-ai/Aria"),
229228
"Blip2ForConditionalGeneration": _HfExamplesInfo("Salesforce/blip2-opt-2.7b"), # noqa: E501
230229
"ChameleonForConditionalGeneration": _HfExamplesInfo("facebook/chameleon-7b"), # noqa: E501
231230
"ChatGLMModel": _HfExamplesInfo("THUDM/glm-4v-9b",

tests/multimodal/test_processing.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
from contextlib import nullcontext
4+
from types import MethodType
45
from typing import cast
56
from unittest.mock import MagicMock
67

78
import numpy as np
89
import pytest
10+
from transformers import ProcessorMixin
911

1012
from vllm.config import ModelConfig
1113
from vllm.multimodal import MULTIMODAL_REGISTRY
@@ -636,3 +638,70 @@ def test_limit_mm_per_prompt_apply(model_id, num_images, limit, is_valid):
636638
mm_data=mm_data,
637639
hf_processor_mm_kwargs={},
638640
)
641+
642+
643+
class _ProcessorProxy:
644+
645+
def __init__(self, processor: ProcessorMixin) -> None:
646+
super().__init__()
647+
648+
self.__processor = processor
649+
650+
def __getattr__(self, key: str):
651+
return getattr(self.__processor, key)
652+
653+
def __call__(
654+
self,
655+
text=None,
656+
images=None,
657+
videos=None,
658+
exists=None,
659+
return_tensors=None,
660+
):
661+
return dict(exists=exists)
662+
663+
664+
@pytest.mark.parametrize("model_id", ["Qwen/Qwen2-VL-7B-Instruct"]) # Dummy
665+
# yapf: disable
666+
@pytest.mark.parametrize(
667+
("call_kwargs", "expected_kwargs"),
668+
[
669+
# Should ignore invalid kwargs
670+
({"does_not_exist": 100}, {"exists": None}),
671+
({"exists": 1}, {"exists": 1}),
672+
({"does_not_exist": 100, "exists": 1}, {"exists": 1}),
673+
],
674+
)
675+
# yapf: enable
676+
def test_hf_processor_kwargs(model_id, call_kwargs, expected_kwargs):
677+
model_config = ModelConfig(
678+
model=model_id,
679+
task="auto",
680+
tokenizer=model_id,
681+
tokenizer_mode="auto",
682+
trust_remote_code=False,
683+
seed=0,
684+
dtype="half",
685+
revision=None,
686+
)
687+
688+
processor = MULTIMODAL_REGISTRY.create_processor(
689+
model_config,
690+
tokenizer=cached_get_tokenizer(model_config.tokenizer),
691+
)
692+
orig_get_hf_processor = processor.info.get_hf_processor
693+
694+
def get_hf_processor(self, **kwargs):
695+
assert kwargs == call_kwargs
696+
return _ProcessorProxy(orig_get_hf_processor())
697+
698+
processor.info.get_hf_processor = MethodType(get_hf_processor,
699+
processor.info)
700+
701+
out_kwargs = processor._call_hf_processor(
702+
prompt="",
703+
mm_data={},
704+
mm_kwargs=call_kwargs,
705+
)
706+
707+
assert out_kwargs == expected_kwargs

0 commit comments

Comments
 (0)