main
py 57 lines 1.64 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 tests.conftest import VllmRunner
10 from tests.utils import create_new_process_for_each_test
11
12 pytestmark = pytest.mark.skipif(
13 importlib.util.find_spec("terratorch") is None,
14 reason="terratorch unavailable while PyPI has `lightning` quarantined; see #41376",
15 )
16
17
18 @create_new_process_for_each_test() # Hangs otherwise
19 @pytest.mark.parametrize(
20 "model",
21 [
22 "ibm-nasa-geospatial/Prithvi-EO-2.0-300M-TL-Sen1Floods11",
23 "ibm-nasa-geospatial/Prithvi-EO-2.0-300M-BurnScars",
24 ],
25 )
26 def test_inference(
27 vllm_runner: type[VllmRunner],
28 model: str,
29 ) -> None:
30 pixel_values = torch.full((6, 512, 512), 1.0, dtype=torch.float16)
31 location_coords = torch.full((1, 2), 1.0, dtype=torch.float16)
32 prompt = dict(
33 prompt_token_ids=[1],
34 multi_modal_data={
35 "image": {
36 "pixel_values": pixel_values,
37 "location_coords": location_coords,
38 }
39 },
40 )
41
42 with vllm_runner(
43 model,
44 runner="pooling",
45 dtype="half",
46 enforce_eager=True,
47 skip_tokenizer_init=True,
48 enable_mm_embeds=True,
49 # Limit the maximum number of sequences to avoid the
50 # test going OOM during the warmup run
51 max_num_seqs=32,
52 default_torch_num_threads=1,
53 ) as vllm_model:
54 vllm_output = vllm_model.llm.encode(prompt, pooling_task="plugin")
55 assert torch.equal(
56 torch.isnan(vllm_output[0].outputs.data).any(), torch.tensor(False)
57 )