A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 16, 22:00 UTC
[CI/Build] [3/3] Reorganize entrypoints tests (#5966)
Cyrus Leung committed
Jun 30, 2024 at 12:58 UTC
9d47f64eb6f35e42840b1e4ca6dc68167014abcd
17 files changed
+19
-48
.buildkite/test-pipeline.yaml
+2
-2
@@ -89,8 +89,8 @@ steps:
89
mirror_hardwares: [amd]
90
91
commands:
92
- - pytest -v -s entrypoints -m llm
93
- - pytest -v -s entrypoints -m openai
92
+ - pytest -v -s entrypoints/llm
93
+ - pytest -v -s entrypoints/openai
94
95
- label: Examples Test
96
working_dir: "/vllm-workspace/examples"
pyproject.toml
-2
@@ -69,7 +69,5 @@ skip_gitignore = true
69
[tool.pytest.ini_options]
70
markers = [
71
"skip_global_cleanup",
72
- "llm: run tests for vLLM API only",
73
- "openai: run tests for OpenAI API only",
72
"vlm: run tests for vision language models only",
73
]
tests/entrypoints/llm/__init__.py
tests/entrypoints/llm/test_encode.py
renamed
+1
-3
@@ -5,7 +5,7 @@ import pytest
5
6
from vllm import LLM, EmbeddingRequestOutput, PoolingParams
7
8
-from ..conftest import cleanup
8
+from ...conftest import cleanup
9
10
MODEL_NAME = "intfloat/e5-mistral-7b-instruct"
11
@@ -25,8 +25,6 @@ TOKEN_IDS = [
25
[1000, 1003, 1001, 1002],
26
]
27
28
-pytestmark = pytest.mark.llm
29
-
28
29
@pytest.fixture(scope="module")
30
def llm():
tests/entrypoints/llm/test_generate.py
renamed
+1
-3
@@ -5,7 +5,7 @@ import pytest
5
6
from vllm import LLM, RequestOutput, SamplingParams
7
8
-from ..conftest import cleanup
8
+from ...conftest import cleanup
9
10
MODEL_NAME = "facebook/opt-125m"
11
@@ -23,8 +23,6 @@ TOKEN_IDS = [
23
[0, 3, 1, 2],
24
]
25
26
-pytestmark = pytest.mark.llm
27
-
26
27
@pytest.fixture(scope="module")
28
def llm():
tests/entrypoints/llm/test_generate_multiple_loras.py
renamed
+1
-3
@@ -7,7 +7,7 @@ from huggingface_hub import snapshot_download
7
from vllm import LLM
8
from vllm.lora.request import LoRARequest
9
10
-from ..conftest import cleanup
10
+from ...conftest import cleanup
11
12
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
13
@@ -20,8 +20,6 @@ PROMPTS = [
20
21
LORA_NAME = "typeof/zephyr-7b-beta-lora"
22
23
-pytestmark = pytest.mark.llm
24
-
23
24
@pytest.fixture(scope="module")
25
def llm():
tests/entrypoints/openai/__init__.py
tests/entrypoints/openai/test_chat.py
renamed
+1
-3
@@ -14,7 +14,7 @@ import torch
14
from huggingface_hub import snapshot_download
15
from openai import BadRequestError
16
17
-from ..utils import RemoteOpenAIServer
17
+from ...utils import RemoteOpenAIServer
18
19
# any model with a chat template should work here
20
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
@@ -69,8 +69,6 @@ TEST_CHOICE = [
69
"Swift", "Kotlin"
70
]
71
72
-pytestmark = pytest.mark.openai
73
-
72
73
@pytest.fixture(scope="module")
74
def zephyr_lora_files():
tests/entrypoints/openai/test_completion.py
renamed
+1
-3
@@ -16,7 +16,7 @@ from openai import BadRequestError
16
17
from vllm.transformers_utils.tokenizer import get_tokenizer
18
19
-from ..utils import RemoteOpenAIServer
19
+from ...utils import RemoteOpenAIServer
20
21
# any model with a chat template should work here
22
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
@@ -71,8 +71,6 @@ TEST_CHOICE = [
71
"Swift", "Kotlin"
72
]
73
74
-pytestmark = pytest.mark.openai
75
-
74
75
@pytest.fixture(scope="module")
76
def zephyr_lora_files():
tests/entrypoints/openai/test_embedding.py
renamed
+1
-3
@@ -2,12 +2,10 @@ import openai
2
import pytest
3
import ray
4
5
-from ..utils import RemoteOpenAIServer
5
+from ...utils import RemoteOpenAIServer
6
7
EMBEDDING_MODEL_NAME = "intfloat/e5-mistral-7b-instruct"
8
9
-pytestmark = pytest.mark.openai
10
-
9
10
@pytest.fixture(scope="module")
11
def ray_ctx():
tests/entrypoints/openai/test_guided_processors.py
renamed
-2
@@ -52,8 +52,6 @@ TEST_SCHEMA = {
52
TEST_REGEX = (r"((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}"
53
r"(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)")
54
55
-pytestmark = pytest.mark.openai
56
-
55
56
def test_guided_logits_processors():
57
"""Basic unit test for RegexLogitsProcessor and JSONLogitsProcessor."""
tests/entrypoints/openai/test_models.py
renamed
+1
-3
@@ -6,7 +6,7 @@ import ray
6
# downloading lora to test lora requests
7
from huggingface_hub import snapshot_download
8
9
-from ..utils import RemoteOpenAIServer
9
+from ...utils import RemoteOpenAIServer
10
11
# any model with a chat template should work here
12
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
@@ -14,8 +14,6 @@ MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
14
# generation quality here
15
LORA_NAME = "typeof/zephyr-7b-beta-lora"
16
17
-pytestmark = pytest.mark.openai
18
-
17
18
@pytest.fixture(scope="module")
19
def zephyr_lora_files():
tests/entrypoints/openai/test_oot_registration.py
renamed
-3
@@ -1,7 +1,6 @@
1
import sys
2
import time
3
4
-import pytest
4
import torch
5
from openai import OpenAI, OpenAIError
6
@@ -10,8 +9,6 @@ from vllm.model_executor.models.opt import OPTForCausalLM
9
from vllm.model_executor.sampling_metadata import SamplingMetadata
10
from vllm.utils import get_open_port
11
13
-pytestmark = pytest.mark.openai
14
-
12
13
class MyOPTForCausalLM(OPTForCausalLM):
14
tests/entrypoints/openai/test_run_batch.py
renamed
tests/entrypoints/openai/test_serving_chat.py
-4
@@ -1,15 +1,11 @@
1
import asyncio
2
from dataclasses import dataclass
3
4
-import pytest
5
-
4
from vllm.entrypoints.openai.serving_chat import OpenAIServingChat
5
6
MODEL_NAME = "openai-community/gpt2"
7
CHAT_TEMPLATE = "Dummy chat template for testing {}"
8
11
-pytestmark = pytest.mark.openai
12
-
9
10
@dataclass
11
class MockModelConfig:
tests/entrypoints/openai/test_vision.py
renamed
+3
-10
@@ -1,4 +1,3 @@
1
-from pathlib import Path
1
from typing import Dict, List
2
3
import openai
@@ -8,12 +7,12 @@ import ray
7
8
from vllm.multimodal.utils import ImageFetchAiohttp, encode_image_base64
9
11
-from ..utils import RemoteOpenAIServer
10
+from ...utils import VLLM_PATH, RemoteOpenAIServer
11
12
MODEL_NAME = "llava-hf/llava-1.5-7b-hf"
14
-LLAVA_CHAT_TEMPLATE = (Path(__file__).parent.parent.parent /
15
- "examples/template_llava.jinja")
13
+LLAVA_CHAT_TEMPLATE = VLLM_PATH / "examples/template_llava.jinja"
14
assert LLAVA_CHAT_TEMPLATE.exists()
15
+
16
# Test different image extensions (JPG/PNG) and formats (gray/RGB/RGBA)
17
TEST_IMAGE_URLS = [
18
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
@@ -22,8 +21,6 @@ TEST_IMAGE_URLS = [
21
"https://upload.wikimedia.org/wikipedia/commons/0/0b/RGBA_comp.png",
22
]
23
25
-pytestmark = pytest.mark.openai
26
-
24
25
@pytest.fixture(scope="module")
26
def ray_ctx():
@@ -279,7 +276,3 @@ async def test_multi_image_input(client: openai.AsyncOpenAI, model_name: str,
276
)
277
completion = completion.choices[0].text
278
assert completion is not None and len(completion) >= 0
282
-
283
-
284
-if __name__ == "__main__":
285
- pytest.main([__file__])
tests/utils.py
+7
-4
@@ -4,7 +4,8 @@ import sys
4
import time
5
import warnings
6
from contextlib import contextmanager
7
-from typing import Dict, List
7
+from pathlib import Path
8
+from typing import Any, Dict, List
9
10
import openai
11
import ray
@@ -40,8 +41,8 @@ else:
41
nvmlShutdown()
42
43
43
-# Path to root of repository so that utilities can be imported by ray workers
44
-VLLM_PATH = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir))
44
+VLLM_PATH = Path(__file__).parent.parent
45
+"""Path to root of the vLLM repository."""
46
47
48
class RemoteOpenAIServer:
@@ -153,10 +154,12 @@ def init_test_distributed_environment(
154
def multi_process_parallel(
155
tp_size: int,
156
pp_size: int,
156
- test_target,
157
+ test_target: Any,
158
) -> None:
159
# Using ray helps debugging the error when it failed
160
# as compared to multiprocessing.
161
+ # NOTE: We need to set working_dir for distributed tests,
162
+ # otherwise we may get import errors on ray workers
163
ray.init(runtime_env={"working_dir": VLLM_PATH})
164
165
distributed_init_port = get_open_port()