Commit 04629132 authored by zhuwenwen's avatar zhuwenwen
Browse files

[tests] fix tests

parent 07c69390
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import itertools import itertools
from functools import partial from functools import partial
import os
import pytest import pytest
from PIL import Image from PIL import Image
from pqdm.threads import pqdm from pqdm.threads import pqdm
...@@ -12,6 +13,7 @@ from vllm.multimodal.parse import ImageSize ...@@ -12,6 +13,7 @@ from vllm.multimodal.parse import ImageSize
from vllm.multimodal.processing import BaseMultiModalProcessor from vllm.multimodal.processing import BaseMultiModalProcessor
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
def _validate_image_max_tokens_one( def _validate_image_max_tokens_one(
...@@ -33,7 +35,7 @@ def _validate_image_max_tokens_one( ...@@ -33,7 +35,7 @@ def _validate_image_max_tokens_one(
@pytest.mark.skip("This test takes around 5 minutes to run. " @pytest.mark.skip("This test takes around 5 minutes to run. "
"Comment this out to run it manually.") "Comment this out to run it manually.")
@pytest.mark.parametrize("model_id", @pytest.mark.parametrize("model_id",
["llava-hf/llava-onevision-qwen2-0.5b-ov-hf"]) [os.path.join(models_path_prefix, "llava-hf/llava-onevision-qwen2-0.5b-ov-hf")])
def test_processor_max_tokens(model_id): def test_processor_max_tokens(model_id):
ctx = build_model_context( ctx = build_model_context(
model_id, model_id,
...@@ -127,7 +129,7 @@ def _test_image_prompt_replacements( ...@@ -127,7 +129,7 @@ def _test_image_prompt_replacements(
@pytest.mark.parametrize("model_id", @pytest.mark.parametrize("model_id",
["llava-hf/llava-onevision-qwen2-0.5b-ov-hf"]) [os.path.join(models_path_prefix, "llava-hf/llava-onevision-qwen2-0.5b-ov-hf")])
@pytest.mark.parametrize("num_imgs", [1, 2]) @pytest.mark.parametrize("num_imgs", [1, 2])
def test_processor_prompt_replacements_regression(model_id, num_imgs): def test_processor_prompt_replacements_regression(model_id, num_imgs):
ctx = build_model_context( ctx = build_model_context(
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
"""Tests for mllama's multimodal preprocessing and profiling.""" """Tests for mllama's multimodal preprocessing and profiling."""
import os
import pytest import pytest
from transformers import MllamaConfig from transformers import MllamaConfig
...@@ -7,10 +8,11 @@ from vllm.multimodal import MULTIMODAL_REGISTRY ...@@ -7,10 +8,11 @@ from vllm.multimodal import MULTIMODAL_REGISTRY
from vllm.multimodal.profiling import MultiModalProfiler from vllm.multimodal.profiling import MultiModalProfiler
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
@pytest.mark.parametrize("model_id", @pytest.mark.parametrize("model_id",
["meta-llama/Llama-3.2-11B-Vision-Instruct"]) [os.path.join(models_path_prefix, "meta-llama/Llama-3.2-11B-Vision-Instruct")])
@pytest.mark.parametrize("max_model_len", [4096, 8192, 25600, 131072]) @pytest.mark.parametrize("max_model_len", [4096, 8192, 25600, 131072])
@pytest.mark.parametrize("max_num_seqs", [1, 2, 8]) @pytest.mark.parametrize("max_num_seqs", [1, 2, 8])
def test_profiling( def test_profiling(
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
"""Tests for phi3v's multimodal preprocessing kwargs.""" """Tests for phi3v's multimodal preprocessing kwargs."""
import os
import pytest import pytest
from vllm.multimodal import MULTIMODAL_REGISTRY from vllm.multimodal import MULTIMODAL_REGISTRY
from ....conftest import _ImageAssets from ....conftest import _ImageAssets
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
@pytest.mark.parametrize("model_id", ["microsoft/Phi-3.5-vision-instruct"]) @pytest.mark.parametrize("model_id", [os.path.join(models_path_prefix, "microsoft/Phi-3.5-vision-instruct")])
# yapf: disable # yapf: disable
@pytest.mark.parametrize( @pytest.mark.parametrize(
("mm_processor_kwargs", "expected_toks_per_img"), ("mm_processor_kwargs", "expected_toks_per_img"),
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
"""Tests for phi4mm's multimodal preprocessing kwargs.""" """Tests for phi4mm's multimodal preprocessing kwargs."""
import os
import pytest import pytest
from vllm.multimodal import MULTIMODAL_REGISTRY from vllm.multimodal import MULTIMODAL_REGISTRY
from ....conftest import _ImageAssets from ....conftest import _ImageAssets
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
@pytest.mark.parametrize("model_id", ["microsoft/Phi-4-multimodal-instruct"]) @pytest.mark.parametrize("model_id", [os.path.join(models_path_prefix, "microsoft/Phi-4-multimodal-instruct")])
# yapf: disable # yapf: disable
@pytest.mark.parametrize( @pytest.mark.parametrize(
("mm_processor_kwargs", "expected_toks_per_img"), ("mm_processor_kwargs", "expected_toks_per_img"),
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import os
import pytest import pytest
from vllm.multimodal import MULTIMODAL_REGISTRY from vllm.multimodal import MULTIMODAL_REGISTRY
from ....conftest import _ImageAssets from ....conftest import _ImageAssets
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
@pytest.mark.parametrize("model_id", ["Qwen/Qwen2-VL-2B-Instruct"]) @pytest.mark.parametrize("model_id", [os.path.join(models_path_prefix, "Qwen/Qwen2-VL-2B-Instruct")])
# yapf: disable # yapf: disable
@pytest.mark.parametrize( @pytest.mark.parametrize(
("mm_processor_kwargs", "expected_toks_per_img", "expected_pixels_shape"), [ ("mm_processor_kwargs", "expected_toks_per_img", "expected_pixels_shape"), [
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
"""Tests for smolvlm's multimodal preprocessing kwargs.""" """Tests for smolvlm's multimodal preprocessing kwargs."""
import os
import pytest import pytest
from transformers import SmolVLMConfig from transformers import SmolVLMConfig
...@@ -7,9 +8,10 @@ from vllm.multimodal import MULTIMODAL_REGISTRY ...@@ -7,9 +8,10 @@ from vllm.multimodal import MULTIMODAL_REGISTRY
from ....conftest import _ImageAssets from ....conftest import _ImageAssets
from ...utils import build_model_context from ...utils import build_model_context
from ....utils import models_path_prefix
@pytest.mark.parametrize("model_id", ["HuggingFaceTB/SmolVLM2-2.2B-Instruct"]) @pytest.mark.parametrize("model_id", [os.path.join(models_path_prefix, "HuggingFaceTB/SmolVLM2-2.2B-Instruct")])
# yapf: disable # yapf: disable
@pytest.mark.parametrize( @pytest.mark.parametrize(
("mm_processor_kwargs", "expected_toks_per_img"), ("mm_processor_kwargs", "expected_toks_per_img"),
......
...@@ -8,7 +8,9 @@ import os ...@@ -8,7 +8,9 @@ import os
import pytest import pytest
from packaging.version import Version from packaging.version import Version
from transformers import __version__ as TRANSFORMERS_VERSION from transformers import __version__ as TRANSFORMERS_VERSION
# from ..utils import models_path_prefix
models_path_prefix = os.getenv('VLLM_OPTEST_MODELS_PATH') or os.getenv("OPTEST_MODELS_PATH")
@dataclass(frozen=True) @dataclass(frozen=True)
...@@ -109,8 +111,6 @@ class _HfExamplesInfo: ...@@ -109,8 +111,6 @@ class _HfExamplesInfo:
pytest.skip(msg) pytest.skip(msg)
models_path_prefix = os.getenv('VLLM_OPTEST_MODELS_PATH') or os.getenv("OPTEST_MODELS_PATH")
# yapf: disable # yapf: disable
_TEXT_GENERATION_EXAMPLE_MODELS = { _TEXT_GENERATION_EXAMPLE_MODELS = {
# [Decoder-only] # [Decoder-only]
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import warnings import warnings
import os
import pytest import pytest
import torch.cuda import torch.cuda
...@@ -20,6 +21,8 @@ from vllm.platforms import current_platform ...@@ -20,6 +21,8 @@ from vllm.platforms import current_platform
from ..utils import create_new_process_for_each_test from ..utils import create_new_process_for_each_test
from .registry import HF_EXAMPLE_MODELS from .registry import HF_EXAMPLE_MODELS
models_path_prefix = os.getenv('VLLM_OPTEST_MODELS_PATH') or os.getenv("OPTEST_MODELS_PATH")
@pytest.mark.parametrize("model_arch", ModelRegistry.get_supported_archs()) @pytest.mark.parametrize("model_arch", ModelRegistry.get_supported_archs())
def test_registry_imports(model_arch): def test_registry_imports(model_arch):
...@@ -52,12 +55,12 @@ def test_registry_imports(model_arch): ...@@ -52,12 +55,12 @@ def test_registry_imports(model_arch):
@create_new_process_for_each_test() @create_new_process_for_each_test()
@pytest.mark.parametrize("model_arch,is_mm,init_cuda,is_ce", [ @pytest.mark.parametrize("model_arch,is_mm,init_cuda,is_ce", [
("LlamaForCausalLM", False, False, False), (os.path.join(models_path_prefix, "LlamaForCausalLM"), False, False, False),
("MllamaForConditionalGeneration", True, False, False), (os.path.join(models_path_prefix, "MllamaForConditionalGeneration"), True, False, False),
("LlavaForConditionalGeneration", True, True, False), (os.path.join(models_path_prefix, "LlavaForConditionalGeneration"), True, True, False),
("BertForSequenceClassification", False, False, True), (os.path.join(models_path_prefix, "BertForSequenceClassification"), False, False, True),
("RobertaForSequenceClassification", False, False, True), (os.path.join(models_path_prefix, "RobertaForSequenceClassification"), False, False, True),
("XLMRobertaForSequenceClassification", False, False, True), (os.path.join(models_path_prefix, "XLMRobertaForSequenceClassification"), False, False, True),
]) ])
def test_registry_model_property(model_arch, is_mm, init_cuda, is_ce): def test_registry_model_property(model_arch, is_mm, init_cuda, is_ce):
assert ModelRegistry.is_multimodal_model(model_arch) is is_mm assert ModelRegistry.is_multimodal_model(model_arch) is is_mm
...@@ -77,9 +80,9 @@ def test_registry_model_property(model_arch, is_mm, init_cuda, is_ce): ...@@ -77,9 +80,9 @@ def test_registry_model_property(model_arch, is_mm, init_cuda, is_ce):
@create_new_process_for_each_test() @create_new_process_for_each_test()
@pytest.mark.parametrize("model_arch,is_pp,init_cuda", [ @pytest.mark.parametrize("model_arch,is_pp,init_cuda", [
("MLPSpeculatorPreTrainedModel", False, False), (os.path.join(models_path_prefix, "MLPSpeculatorPreTrainedModel"), False, False),
("DeepseekV2ForCausalLM", True, False), (os.path.join(models_path_prefix, "DeepseekV2ForCausalLM"), True, False),
("Qwen2VLForConditionalGeneration", True, True), (os.path.join(models_path_prefix, "Qwen2VLForConditionalGeneration"), True, True),
]) ])
def test_registry_is_pp(model_arch, is_pp, init_cuda): def test_registry_is_pp(model_arch, is_pp, init_cuda):
assert ModelRegistry.is_pp_supported_model(model_arch) is is_pp assert ModelRegistry.is_pp_supported_model(model_arch) is is_pp
......
File mode changed from 100755 to 100644
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment