@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / ce30dca5c4
Fork 0

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 14, 05:30 UTC

[CI]: reduce HTTP calls inside entrypoints openai tests (#23646)

Signed-off-by: AzizCode92 <azizbenothman76@gmail.com> Signed-off-by: Aziz <azizbenothman76@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

Aziz committed Sep 2, 2025 at 12:49 UTC ce30dca5c44353f278dc114bd6f03b11700088eb
8 files changed +30 -74
tests/entrypoints/conftest.py
+29
@@ -201,3 +201,32 @@ table: "table_1" | "table_2"
201 condition: column "=" number
202 number: "1" | "2"
203 """)
204 +
205 +
206 +@pytest.fixture(scope="session")
207 +def zephyr_lora_files():
208 + """Download zephyr LoRA files once per test session."""
209 + from huggingface_hub import snapshot_download
210 + return snapshot_download(repo_id="typeof/zephyr-7b-beta-lora")
211 +
212 +
213 +@pytest.fixture(scope="session")
214 +def zephyr_lora_added_tokens_files(zephyr_lora_files):
215 + """Create zephyr LoRA files with added tokens once per test session."""
216 + import shutil
217 + from tempfile import TemporaryDirectory
218 +
219 + from transformers import AutoTokenizer
220 +
221 + tmp_dir = TemporaryDirectory()
222 + tmp_model_dir = f"{tmp_dir.name}/zephyr"
223 + shutil.copytree(zephyr_lora_files, tmp_model_dir)
224 + tokenizer = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta")
225 + # Copy tokenizer to adapter and add some unique tokens
226 + # 32000, 32001, 32002
227 + added = tokenizer.add_tokens(["vllm1", "vllm2", "vllm3"],
228 + special_tokens=True)
229 + assert added == 3
230 + tokenizer.save_pretrained(tmp_model_dir)
231 + yield tmp_model_dir
232 + tmp_dir.cleanup()
tests/entrypoints/openai/test_chat.py
-2
@@ -15,8 +15,6 @@ import torch
15 from openai import BadRequestError, OpenAI
16
17 from ...utils import RemoteOpenAIServer
18 -from .test_completion import zephyr_lora_added_tokens_files # noqa: F401
19 -from .test_completion import zephyr_lora_files # noqa: F401
18
19 # any model with a chat template should work here
20 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
tests/entrypoints/openai/test_completion.py
-26
@@ -3,8 +3,6 @@
3 # imports for guided decoding tests
4 import json
5 import os
6 -import shutil
7 -from tempfile import TemporaryDirectory
6 from typing import Optional
7
8 import jsonschema
@@ -14,9 +12,7 @@ import pytest_asyncio
12 import regex as re
13 import requests
14 # downloading lora to test lora requests
17 -from huggingface_hub import snapshot_download
15 from openai import BadRequestError
19 -from transformers import AutoTokenizer
16
17 from vllm.transformers_utils.tokenizer import get_tokenizer
18
@@ -26,32 +22,10 @@ from ...utils import RemoteOpenAIServer
22 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
23 # technically these adapters use a different base model,
24 # but we're not testing generation quality here
29 -LORA_NAME = "typeof/zephyr-7b-beta-lora"
25
26 GUIDED_DECODING_BACKENDS = ["outlines", "xgrammar", "guidance"]
27
28
34 -@pytest.fixture(scope="module")
35 -def zephyr_lora_files():
36 - return snapshot_download(repo_id=LORA_NAME)
37 -
38 -
39 -@pytest.fixture(scope="module")
40 -def zephyr_lora_added_tokens_files(zephyr_lora_files):
41 - tmp_dir = TemporaryDirectory()
42 - tmp_model_dir = f"{tmp_dir.name}/zephyr"
43 - shutil.copytree(zephyr_lora_files, tmp_model_dir)
44 - tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
45 - # Copy tokenizer to adapter and add some unique tokens
46 - # 32000, 32001, 32002
47 - added = tokenizer.add_tokens(["vllm1", "vllm2", "vllm3"],
48 - special_tokens=True)
49 - assert added == 3
50 - tokenizer.save_pretrained(tmp_model_dir)
51 - yield tmp_model_dir
52 - tmp_dir.cleanup()
53 -
54 -
29 @pytest.fixture(scope="module")
30 def default_server_args(zephyr_lora_files, zephyr_lora_added_tokens_files):
31 return [
tests/entrypoints/openai/test_completion_with_prompt_embeds.py
+1 -26
@@ -3,48 +3,23 @@
3
4 import base64
5 import io
6 -import shutil
7 -from tempfile import TemporaryDirectory
6
7 import openai # use the official client for correctness check
8 import pytest
9 import pytest_asyncio
10 import torch
11 # downloading lora to test lora requests
14 -from huggingface_hub import snapshot_download
12 from openai import BadRequestError
16 -from transformers import AutoConfig, AutoTokenizer
13 +from transformers import AutoConfig
14
15 from ...utils import RemoteOpenAIServer
16
17 # any model with a chat template should work here
18 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
22 -LORA_NAME = "typeof/zephyr-7b-beta-lora"
19
20 CONFIG = AutoConfig.from_pretrained(MODEL_NAME)
21
22
27 -@pytest.fixture(scope="module")
28 -def zephyr_lora_files():
29 - return snapshot_download(repo_id=LORA_NAME)
30 -
31 -
32 -@pytest.fixture(scope="module")
33 -def zephyr_lora_added_tokens_files(zephyr_lora_files):
34 - tmp_dir = TemporaryDirectory()
35 - tmp_model_dir = f"{tmp_dir.name}/zephyr"
36 - shutil.copytree(zephyr_lora_files, tmp_model_dir)
37 - tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
38 - # Copy tokenizer to adapter and add some unique tokens
39 - # 32000, 32001, 32002
40 - added = tokenizer.add_tokens(["vllm1", "vllm2", "vllm3"],
41 - special_tokens=True)
42 - assert added == 3
43 - tokenizer.save_pretrained(tmp_model_dir)
44 - yield tmp_model_dir
45 - tmp_dir.cleanup()
46 -
47 -
23 @pytest.fixture(scope="module")
24 def default_server_args(
25 zephyr_lora_files,
tests/entrypoints/openai/test_lora_adapters.py
-8
@@ -9,8 +9,6 @@ from contextlib import suppress
9 import openai # use the official client for correctness check
10 import pytest
11 import pytest_asyncio
12 -# downloading lora to test lora requests
13 -from huggingface_hub import snapshot_download
12
13 from ...utils import RemoteOpenAIServer
14
@@ -18,7 +16,6 @@ from ...utils import RemoteOpenAIServer
16 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
17 # technically this needs Mistral-7B-v0.1 as base, but we're not testing
18 # generation quality here
21 -LORA_NAME = "typeof/zephyr-7b-beta-lora"
19
20 BADREQUEST_CASES = [
21 (
@@ -48,11 +45,6 @@ BADREQUEST_CASES = [
45 ]
46
47
51 -@pytest.fixture(scope="module")
52 -def zephyr_lora_files():
53 - return snapshot_download(repo_id=LORA_NAME)
54 -
55 -
48 @pytest.fixture(scope="module")
49 def monkeypatch_module():
50 from _pytest.monkeypatch import MonkeyPatch
tests/entrypoints/openai/test_models.py
-8
@@ -4,8 +4,6 @@
4 import openai # use the official client for correctness check
5 import pytest
6 import pytest_asyncio
7 -# downloading lora to test lora requests
8 -from huggingface_hub import snapshot_download
7
8 from ...utils import RemoteOpenAIServer
9
@@ -13,12 +11,6 @@ from ...utils import RemoteOpenAIServer
11 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
12 # technically this needs Mistral-7B-v0.1 as base, but we're not testing
13 # generation quality here
16 -LORA_NAME = "typeof/zephyr-7b-beta-lora"
17 -
18 -
19 -@pytest.fixture(scope="module")
20 -def zephyr_lora_files():
21 - return snapshot_download(repo_id=LORA_NAME)
14
15
16 @pytest.fixture(scope="module")
tests/entrypoints/openai/test_return_tokens_as_ids.py
-2
@@ -11,8 +11,6 @@ from vllm.transformers_utils.tokenizer import get_tokenizer
11
12 from ...utils import RemoteOpenAIServer
13 from .test_completion import default_server_args # noqa: F401
14 -from .test_completion import zephyr_lora_added_tokens_files # noqa: F401
15 -from .test_completion import zephyr_lora_files # noqa: F401
14 from .test_completion import MODEL_NAME
15
16
tests/entrypoints/openai/test_tokenization.py
-2
@@ -8,8 +8,6 @@ import requests
8 from vllm.transformers_utils.tokenizer import get_tokenizer
9
10 from ...utils import RemoteOpenAIServer
11 -from .test_completion import zephyr_lora_added_tokens_files # noqa: F401
12 -from .test_completion import zephyr_lora_files # noqa: F401
11
12 # any model with a chat template should work here
13 MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"