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/Build] Clean up LoRA test (#23890)
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
Jee Jee Li committed
Aug 29, 2025 at 14:28 UTC
b4f9e9631c84c73cbf05f18402074be1abf0471d
4 files changed
+40
-87
.buildkite/scripts/hardware_ci/run-amd-test.sh
-1
@@ -164,7 +164,6 @@ if [[ $commands == *" entrypoints/llm "* ]]; then
164
--ignore=entrypoints/llm/test_chat.py \
165
--ignore=entrypoints/llm/test_accuracy.py \
166
--ignore=entrypoints/llm/test_init.py \
167
- --ignore=entrypoints/llm/test_generate_multiple_loras.py \
167
--ignore=entrypoints/llm/test_prompt_validation.py "}
168
fi
169
.buildkite/test-pipeline.yaml
+4
-5
@@ -109,10 +109,9 @@ steps:
109
- tests/entrypoints/offline_mode
110
commands:
111
- export VLLM_WORKER_MULTIPROC_METHOD=spawn
112
- - pytest -v -s entrypoints/llm --ignore=entrypoints/llm/test_lazy_outlines.py --ignore=entrypoints/llm/test_generate.py --ignore=entrypoints/llm/test_generate_multiple_loras.py --ignore=entrypoints/llm/test_collective_rpc.py
112
+ - pytest -v -s entrypoints/llm --ignore=entrypoints/llm/test_lazy_outlines.py --ignore=entrypoints/llm/test_generate.py --ignore=entrypoints/llm/test_collective_rpc.py
113
- pytest -v -s entrypoints/llm/test_lazy_outlines.py # it needs a clean process
114
- pytest -v -s entrypoints/llm/test_generate.py # it needs a clean process
115
- - pytest -v -s entrypoints/llm/test_generate_multiple_loras.py # it needs a clean process
115
- VLLM_USE_V1=0 pytest -v -s entrypoints/offline_mode # Needs to avoid interference with other tests
116
117
- label: Entrypoints Test (API Server) # 40min
@@ -326,7 +325,7 @@ steps:
325
source_file_dependencies:
326
- vllm/lora
327
- tests/lora
329
- command: pytest -v -s lora --shard-id=$$BUILDKITE_PARALLEL_JOB --num-shards=$$BUILDKITE_PARALLEL_JOB_COUNT --ignore=lora/test_chatglm3_tp.py --ignore=lora/test_llama_tp.py
328
+ command: pytest -v -s lora --shard-id=$$BUILDKITE_PARALLEL_JOB --num-shards=$$BUILDKITE_PARALLEL_JOB_COUNT --ignore=lora/test_chatglm3_tp.py --ignore=lora/test_llama_tp.py --ignore=lora/test_llm_with_multi_loras.py
329
parallelism: 4
330
331
- label: PyTorch Compilation Unit Tests
@@ -807,13 +806,13 @@ steps:
806
# requires multi-GPU testing for validation.
807
- pytest -v -s -x lora/test_chatglm3_tp.py
808
- pytest -v -s -x lora/test_llama_tp.py
810
- - pytest -v -s -x lora/test_multi_loras_with_tp.py
809
+ - pytest -v -s -x lora/test_llm_with_multi_loras.py
810
811
812
- label: Weight Loading Multiple GPU Test # 33min
813
mirror_hardwares: [amdexperimental]
814
working_dir: "/vllm-workspace/tests"
816
- num_gpus: 2
815
+ num_gpus: 2
816
optional: true
817
source_file_dependencies:
818
- vllm/
tests/entrypoints/llm/test_generate_multiple_loras.py
deleted
-80
@@ -1,80 +0,0 @@
1
-# SPDX-License-Identifier: Apache-2.0
2
-# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-
4
-import weakref
5
-
6
-import pytest
7
-# downloading lora to test lora requests
8
-from huggingface_hub import snapshot_download
9
-
10
-from vllm import LLM
11
-from vllm.distributed import cleanup_dist_env_and_memory
12
-from vllm.lora.request import LoRARequest
13
-
14
-MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
15
-
16
-PROMPTS = [
17
- "Hello, my name is",
18
- "The president of the United States is",
19
- "The capital of France is",
20
- "The future of AI is",
21
-]
22
-
23
-LORA_NAME = "typeof/zephyr-7b-beta-lora"
24
-
25
-
26
-@pytest.fixture(scope="module")
27
-def monkeypatch_module():
28
- from _pytest.monkeypatch import MonkeyPatch
29
- mpatch = MonkeyPatch()
30
- yield mpatch
31
- mpatch.undo()
32
-
33
-
34
-@pytest.fixture(scope="module", params=[False, True])
35
-def llm(request, monkeypatch_module):
36
-
37
- use_v1 = request.param
38
- monkeypatch_module.setenv('VLLM_USE_V1', '1' if use_v1 else '0')
39
-
40
- # pytest caches the fixture so we use weakref.proxy to
41
- # enable garbage collection
42
- llm = LLM(model=MODEL_NAME,
43
- tensor_parallel_size=1,
44
- max_model_len=8192,
45
- enable_lora=True,
46
- max_loras=4,
47
- max_lora_rank=64,
48
- max_num_seqs=128,
49
- enforce_eager=True)
50
-
51
- yield weakref.proxy(llm)
52
-
53
- del llm
54
-
55
- cleanup_dist_env_and_memory()
56
-
57
-
58
-@pytest.fixture(scope="module")
59
-def zephyr_lora_files():
60
- return snapshot_download(repo_id=LORA_NAME)
61
-
62
-
63
-@pytest.mark.skip_global_cleanup
64
-def test_multiple_lora_requests(llm: LLM, zephyr_lora_files):
65
- lora_request = [
66
- LoRARequest(LORA_NAME + str(idx), idx + 1, zephyr_lora_files)
67
- for idx in range(len(PROMPTS))
68
- ]
69
- # Multiple SamplingParams should be matched with each prompt
70
- outputs = llm.generate(PROMPTS, lora_request=lora_request)
71
- assert len(PROMPTS) == len(outputs)
72
-
73
- # Exception raised, if the size of params does not match the size of prompts
74
- with pytest.raises(ValueError):
75
- outputs = llm.generate(PROMPTS, lora_request=lora_request[:1])
76
-
77
- # Single LoRARequest should be applied to every prompt
78
- single_lora_request = lora_request[0]
79
- outputs = llm.generate(PROMPTS, lora_request=single_lora_request)
80
- assert len(PROMPTS) == len(outputs)
tests/lora/test_llm_with_multi_loras.py
renamed
+36
-1
@@ -1,8 +1,12 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
"""
4
-Script to test multi loras service with tp >= 2
4
+This script contains:
5
+1. test multi loras service with tp >= 2
6
+2. test multi loras request
7
"""
8
+import pytest
9
+
10
from tests.utils import multi_gpu_test
11
from vllm import LLM, SamplingParams
12
from vllm.lora.request import LoRARequest
@@ -156,3 +160,34 @@ def test_multi_loras_with_tp_sync():
160
161
output_text = call_llm_get_outputs(prompt, "Alice")
162
check_outputs(output_text, expected_output)
163
+
164
+
165
+def test_multiple_lora_requests():
166
+ llm = LLM(
167
+ model=MODEL_PATH,
168
+ enable_lora=True,
169
+ max_loras=4,
170
+ max_lora_rank=LORA_RANK,
171
+ max_model_len=512,
172
+ gpu_memory_utilization=0.5,
173
+ enforce_eager=True,
174
+ )
175
+ PROMPTS = ["Hello, my name is"] * 2
176
+ LORA_NAME = "Alice"
177
+ lora_request = [
178
+ LoRARequest(LORA_NAME + str(idx), idx + 1,
179
+ LORA_NAME_PATH_MAP[LORA_NAME])
180
+ for idx in range(len(PROMPTS))
181
+ ]
182
+ # Multiple SamplingParams should be matched with each prompt
183
+ outputs = llm.generate(PROMPTS, lora_request=lora_request)
184
+ assert len(PROMPTS) == len(outputs)
185
+
186
+ # Exception raised, if the size of params does not match the size of prompts
187
+ with pytest.raises(ValueError):
188
+ outputs = llm.generate(PROMPTS, lora_request=lora_request[:1])
189
+
190
+ # Single LoRARequest should be applied to every prompt
191
+ single_lora_request = lora_request[0]
192
+ outputs = llm.generate(PROMPTS, lora_request=single_lora_request)
193
+ assert len(PROMPTS) == len(outputs)