main
py 64 lines 1.55 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 import importlib.util
5
6 import pytest
7 import torch
8
9 from ....conftest import VllmRunner
10
11 pytestmark = pytest.mark.skipif(
12 importlib.util.find_spec("terratorch") is None,
13 reason="terratorch unavailable while PyPI has `lightning` quarantined; see #41376",
14 )
15
16
17 def _run_test(
18 vllm_runner: type[VllmRunner],
19 model: str,
20 ) -> None:
21 prompt = [
22 {
23 # This model deals with no text input
24 "prompt_token_ids": [1],
25 "multi_modal_data": {
26 "image": {
27 "pixel_values": torch.ones((6, 512, 512), dtype=torch.float16),
28 "location_coords": torch.ones((1, 2), dtype=torch.float16),
29 }
30 },
31 }
32 for _ in range(10)
33 ]
34
35 with vllm_runner(
36 model,
37 runner="pooling",
38 dtype="half",
39 enforce_eager=True,
40 skip_tokenizer_init=True,
41 enable_mm_embeds=True,
42 # Limit the maximum number of sequences to avoid the
43 # test going OOM during the warmup run
44 max_num_seqs=32,
45 default_torch_num_threads=1,
46 ) as vllm_model:
47 vllm_model.llm.encode(prompt, pooling_task="plugin")
48
49
50 MODELS = ["ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL-Sen1Floods11"]
51
52
53 @pytest.mark.core_model
54 @pytest.mark.parametrize("model", MODELS)
55 def test_models_image(
56 hf_runner,
57 vllm_runner,
58 image_assets,
59 model: str,
60 ) -> None:
61 _run_test(
62 vllm_runner,
63 model,
64 )