@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 48e925fab5
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 15, 12:15 UTC

[Misc] Clean up test docstrings and names (#17521)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed May 1, 2025 at 20:19 UTC 48e925fab596f513b76e53e3061e897729ff0cb9
19 files changed +51 -115
.buildkite/test-pipeline.yaml
+8 -2
@@ -395,10 +395,8 @@ steps:
395 - csrc/
396 - vllm/model_executor/layers/quantization
397 - tests/quantization
398 - - tests/models/quantization
398 commands:
399 - VLLM_TEST_FORCE_LOAD_FORMAT=auto pytest -v -s quantization
401 - - pytest -v -s models/quantization
400
401 - label: LM Eval Small Models # 53min
402 working_dir: "/vllm-workspace/.buildkite/lm-eval-harness"
@@ -509,6 +507,14 @@ steps:
507 - pip install git+https://github.com/TIGER-AI-Lab/Mantis.git
508 - pytest -v -s models/multimodal/generation/test_common.py -m 'split(group=1) and not core_model'
509
510 +- label: Quantized Models Test
511 + #mirror_hardwares: [amd]
512 + source_file_dependencies:
513 + - vllm/model_executor/layers/quantization
514 + - tests/models/quantization
515 + commands:
516 + - pytest -v -s models/quantization
517 +
518 # This test is used only in PR development phase to test individual models and should never run on main
519 - label: Custom Models Test
520 mirror_hardwares: [amd]
tests/models/language/generation/test_common.py renamed
-5
@@ -1,9 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of HF and vLLM when using greedy sampling.
3 -
4 -Run `pytest tests/models/test_models.py`.
5 -"""
6 -
2 import pytest
3 import torch
4
tests/models/language/generation/test_granite.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of HF and vLLM for Granite models using greedy sampling.
3 -
4 -Run `pytest tests/models/test_granite.py`.
5 -"""
2 import pytest
3
4 from ...utils import check_logprobs_close
tests/models/language/generation/test_mistral.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of HF and vLLM for Mistral models using greedy sampling.
3 -
4 -Run `pytest tests/models/test_mistral.py`.
5 -"""
2 import copy
3 import json
4
tests/models/language/generation/test_phimoe.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of HF and vLLM for moe models using greedy sampling.
3 -
4 -Run `pytest tests/models/test_phimoe.py`.
5 -"""
2 import pytest
3 import torch
4
tests/models/language/pooling/test_classification.py renamed
+1 -5
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the classification outputs of HF and vLLM models.
3 -
4 -Run `pytest tests/models/test_cls_models.py`.
5 -"""
2 import pytest
3 import torch
4 from transformers import AutoModelForSequenceClassification
@@ -19,7 +15,7 @@ from vllm.platforms import current_platform
15 )
16 @pytest.mark.parametrize("dtype",
17 ["half"] if current_platform.is_rocm() else ["float"])
22 -def test_classification_models(
18 +def test_models(
19 hf_runner,
20 vllm_runner,
21 example_prompts,
tests/models/language/pooling/test_embedding.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the embedding outputs of HF and vLLM models.
3 -
4 -Run `pytest tests/models/embedding/language/test_embedding.py`.
5 -"""
2 import pytest
3
4 from vllm.config import PoolerConfig
tests/models/language/pooling/test_jina.py
+3 -8
@@ -1,9 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -# ruff: noqa: E501
3 -"""Compare the scoring outputs of HF and vLLM models.
4 -
5 -Run `pytest tests/models/embedding/language/test_jina.py`.
6 -"""
2 import math
3
4 import pytest
@@ -22,9 +17,9 @@ TEXTS_2 = [
17 "Organic skincare for sensitive skin with aloe vera and chamomile.",
18 "New makeup trends focus on bold colors and innovative techniques",
19 "Bio-Hautpflege für empfindliche Haut mit Aloe Vera und Kamille",
25 - "Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken",
26 - "Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla",
27 - "Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras",
20 + "Neue Make-up-Trends setzen auf kräftige Farben und innovative Techniken", # noqa: E501
21 + "Cuidado de la piel orgánico para piel sensible con aloe vera y manzanilla", # noqa: E501
22 + "Las nuevas tendencias de maquillaje se centran en colores vivos y técnicas innovadoras", # noqa: E501
23 "针对敏感肌专门设计的天然有机护肤产品",
24 "新的化妆趋势注重鲜艳的颜色和创新的技巧",
25 "敏感肌のために特別に設計された天然有機スキンケア製品",
tests/models/language/pooling/test_scoring.py
+22 -39
@@ -1,15 +1,11 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the scoring outputs of HF and vLLM models.
3 -
4 -Run `pytest tests/models/embedding/language/test_scoring.py`.
5 -"""
2 import math
3
4 import pytest
5 import torch
6 import torch.nn.functional as F
7
12 -MODELS = [
8 +CROSS_ENCODER_MODELS = [
9 "cross-encoder/ms-marco-MiniLM-L-6-v2", # Bert
10 "BAAI/bge-reranker-v2-m3", # Roberta
11 ]
@@ -28,21 +24,21 @@ TEXTS_2 = [
24 "The capital of Germany is Berlin.",
25 ]
26
27 +DTYPE = "half"
28 +
29
32 -@pytest.fixture(scope="module", params=MODELS)
30 +@pytest.fixture(scope="module", params=CROSS_ENCODER_MODELS)
31 def model_name(request):
32 yield request.param
33
34
37 -@pytest.mark.parametrize("dtype", ["half"])
38 -def test_llm_1_to_1(vllm_runner, hf_runner, model_name, dtype: str):
39 -
35 +def test_cross_encoder_1_to_1(vllm_runner, hf_runner, model_name):
36 text_pair = [TEXTS_1[0], TEXTS_2[0]]
37
42 - with hf_runner(model_name, dtype=dtype, is_cross_encoder=True) as hf_model:
38 + with hf_runner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
39 hf_outputs = hf_model.predict([text_pair]).tolist()
40
45 - with vllm_runner(model_name, task="score", dtype=dtype,
41 + with vllm_runner(model_name, task="score", dtype=DTYPE,
42 max_model_len=None) as vllm_model:
43 vllm_outputs = vllm_model.score(text_pair[0], text_pair[1])
44
@@ -52,18 +48,16 @@ def test_llm_1_to_1(vllm_runner, hf_runner, model_name, dtype: str):
48 assert math.isclose(hf_outputs[0], vllm_outputs[0], rel_tol=0.01)
49
50
55 -@pytest.mark.parametrize("dtype", ["half"])
56 -def test_llm_1_to_N(vllm_runner, hf_runner, model_name, dtype: str):
57 -
51 +def test_cross_encoder_1_to_N(vllm_runner, hf_runner, model_name):
52 text_pairs = [
53 [TEXTS_1[0], TEXTS_2[0]],
54 [TEXTS_1[0], TEXTS_2[1]],
55 ]
56
63 - with hf_runner(model_name, dtype=dtype, is_cross_encoder=True) as hf_model:
57 + with hf_runner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
58 hf_outputs = hf_model.predict(text_pairs).tolist()
59
66 - with vllm_runner(model_name, task="score", dtype=dtype,
60 + with vllm_runner(model_name, task="score", dtype=DTYPE,
61 max_model_len=None) as vllm_model:
62 vllm_outputs = vllm_model.score(TEXTS_1[0], TEXTS_2)
63
@@ -74,18 +68,16 @@ def test_llm_1_to_N(vllm_runner, hf_runner, model_name, dtype: str):
68 assert math.isclose(hf_outputs[1], vllm_outputs[1], rel_tol=0.01)
69
70
77 -@pytest.mark.parametrize("dtype", ["half"])
78 -def test_llm_N_to_N(vllm_runner, hf_runner, model_name, dtype: str):
79 -
71 +def test_cross_encoder_N_to_N(vllm_runner, hf_runner, model_name):
72 text_pairs = [
73 [TEXTS_1[0], TEXTS_2[0]],
74 [TEXTS_1[1], TEXTS_2[1]],
75 ]
76
85 - with hf_runner(model_name, dtype=dtype, is_cross_encoder=True) as hf_model:
77 + with hf_runner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
78 hf_outputs = hf_model.predict(text_pairs).tolist()
79
88 - with vllm_runner(model_name, task="score", dtype=dtype,
80 + with vllm_runner(model_name, task="score", dtype=DTYPE,
81 max_model_len=None) as vllm_model:
82 vllm_outputs = vllm_model.score(TEXTS_1, TEXTS_2)
83
@@ -101,13 +93,10 @@ def emb_model_name(request):
93 yield request.param
94
95
104 -@pytest.mark.parametrize("dtype", ["half"])
105 -def test_llm_1_to_1_embedding(vllm_runner, hf_runner, emb_model_name,
106 - dtype: str):
107 -
96 +def test_embedding_1_to_1(vllm_runner, hf_runner, emb_model_name):
97 text_pair = [TEXTS_1[0], TEXTS_2[0]]
98
110 - with hf_runner(emb_model_name, dtype=dtype,
99 + with hf_runner(emb_model_name, dtype=DTYPE,
100 is_sentence_transformer=True) as hf_model:
101 hf_embeddings = hf_model.encode(text_pair)
102 hf_outputs = [
@@ -116,7 +105,7 @@ def test_llm_1_to_1_embedding(vllm_runner, hf_runner, emb_model_name,
105
106 with vllm_runner(emb_model_name,
107 task="embed",
119 - dtype=dtype,
108 + dtype=DTYPE,
109 max_model_len=None) as vllm_model:
110 vllm_outputs = vllm_model.score(text_pair[0], text_pair[1])
111
@@ -126,16 +115,13 @@ def test_llm_1_to_1_embedding(vllm_runner, hf_runner, emb_model_name,
115 assert math.isclose(hf_outputs[0], vllm_outputs[0], rel_tol=0.01)
116
117
129 -@pytest.mark.parametrize("dtype", ["half"])
130 -def test_llm_1_to_N_embedding(vllm_runner, hf_runner, emb_model_name,
131 - dtype: str):
132 -
118 +def test_embedding_1_to_N(vllm_runner, hf_runner, emb_model_name):
119 text_pairs = [
120 [TEXTS_1[0], TEXTS_2[0]],
121 [TEXTS_1[0], TEXTS_2[1]],
122 ]
123
138 - with hf_runner(emb_model_name, dtype=dtype,
124 + with hf_runner(emb_model_name, dtype=DTYPE,
125 is_sentence_transformer=True) as hf_model:
126 hf_embeddings = [
127 hf_model.encode(text_pair) for text_pair in text_pairs
@@ -147,7 +133,7 @@ def test_llm_1_to_N_embedding(vllm_runner, hf_runner, emb_model_name,
133
134 with vllm_runner(emb_model_name,
135 task="embed",
150 - dtype=dtype,
136 + dtype=DTYPE,
137 max_model_len=None) as vllm_model:
138 vllm_outputs = vllm_model.score(TEXTS_1[0], TEXTS_2)
139
@@ -158,16 +144,13 @@ def test_llm_1_to_N_embedding(vllm_runner, hf_runner, emb_model_name,
144 assert math.isclose(hf_outputs[1], vllm_outputs[1], rel_tol=0.01)
145
146
161 -@pytest.mark.parametrize("dtype", ["half"])
162 -def test_llm_N_to_N_embedding(vllm_runner, hf_runner, emb_model_name,
163 - dtype: str):
164 -
147 +def test_embedding_N_to_N(vllm_runner, hf_runner, emb_model_name):
148 text_pairs = [
149 [TEXTS_1[0], TEXTS_2[0]],
150 [TEXTS_1[1], TEXTS_2[1]],
151 ]
152
170 - with hf_runner(emb_model_name, dtype=dtype,
153 + with hf_runner(emb_model_name, dtype=DTYPE,
154 is_sentence_transformer=True) as hf_model:
155 hf_embeddings = [
156 hf_model.encode(text_pair) for text_pair in text_pairs
@@ -179,7 +162,7 @@ def test_llm_N_to_N_embedding(vllm_runner, hf_runner, emb_model_name,
162
163 with vllm_runner(emb_model_name,
164 task="embed",
182 - dtype=dtype,
165 + dtype=DTYPE,
166 max_model_len=None) as vllm_model:
167 vllm_outputs = vllm_model.score(TEXTS_1, TEXTS_2)
168
tests/models/language/pooling/test_snowflake_arctic_embed.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the embedding outputs of HF and vLLM models.
3 -
4 -Run `pytest tests/models/embedding/language/test_snowflake_arctic_embed.py`.
5 -"""
2 import pytest
3
4 from ...utils import EmbedModelInfo, check_embeddings_close
tests/models/language/pooling/test_truncation_control.py
+12 -12
@@ -5,18 +5,18 @@ MODEL_NAME = "sentence-transformers/all-MiniLM-L12-v2"
5 max_model_len = 128
6
7 input_str = """Immerse yourself in the enchanting chronicle of calculus, a
8 - mathematical domain that has radically transformed our comprehension of
9 - change and motion. Despite its roots in ancient civilizations, the
10 - formal birth of calculus predominantly occurred in the 17th century,
11 - primarily under the influential guidance of Sir Isaac Newton and Gottfried
12 - Wilhelm Leibniz. The earliest traces of calculus concepts are found in
13 - ancient Greek mathematics,most notably in the works of Eudoxus and
14 - Archimedes, around 300 BCE. They utilized the 'method of exhaustion'—a
15 - technique for computing areas and volumes through the use of finite sums.
16 - This methodology laid crucial foundational work for integral calculus.
17 - In the 17th century, both Newton and Leibniz independently pioneered
18 - calculus, each contributing unique perspectives that would shape this new
19 - field."""
8 +mathematical domain that has radically transformed our comprehension of
9 +change and motion. Despite its roots in ancient civilizations, the
10 +formal birth of calculus predominantly occurred in the 17th century,
11 +primarily under the influential guidance of Sir Isaac Newton and Gottfried
12 +Wilhelm Leibniz. The earliest traces of calculus concepts are found in
13 +ancient Greek mathematics,most notably in the works of Eudoxus and
14 +Archimedes, around 300 BCE. They utilized the 'method of exhaustion'—a
15 +technique for computing areas and volumes through the use of finite sums.
16 +This methodology laid crucial foundational work for integral calculus.
17 +In the 17th century, both Newton and Leibniz independently pioneered
18 +calculus, each contributing unique perspectives that would shape this new
19 +field."""
20
21
22 def test_smaller_truncation_size(vllm_runner,
tests/models/multimodal/generation/test_pixtral.py
-4
@@ -1,8 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of HF and vLLM for Mistral models using greedy sampling.
3 -
4 -Run `pytest tests/models/test_mistral.py`.
5 -"""
2 import json
3 from dataclasses import asdict
4 from typing import TYPE_CHECKING, Any, Optional
tests/models/multimodal/generation/test_whisper.py
+2 -2
@@ -119,10 +119,10 @@ def run_test(
119 assert output.outputs[0].text == expected
120
121
122 -@create_new_process_for_each_test("spawn")
122 @pytest.mark.core_model
123 @pytest.mark.parametrize(
124 "model", ["openai/whisper-small", "openai/whisper-large-v3-turbo"])
125 +@create_new_process_for_each_test()
126 def test_models(vllm_runner, model) -> None:
127 run_test(
128 vllm_runner,
@@ -131,11 +131,11 @@ def test_models(vllm_runner, model) -> None:
131 )
132
133
134 -@create_new_process_for_each_test("spawn")
134 @multi_gpu_test(num_gpus=2)
135 @pytest.mark.core_model
136 @pytest.mark.parametrize("model", ["openai/whisper-large-v3-turbo"])
137 @pytest.mark.parametrize("distributed_executor_backend", ["ray", "mp"])
138 +@create_new_process_for_each_test()
139 def test_models_distributed(
140 vllm_runner,
141 model,
tests/models/quantization/test_aqlm.py
-5
@@ -1,9 +1,4 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compare the outputs of a AQLM model between vLLM and HF Transformers
3 -
4 -Run `pytest tests/models/test_aqlm.py`.
5 -"""
6 -
2 import pytest
3
4 from tests.quantization.utils import is_quant_method_supported
tests/models/quantization/test_bitblas.py
-2
@@ -8,8 +8,6 @@ bitblas/GPTQ models are in the top 3 selections of each other.
8 Note: bitblas internally uses locks to synchronize the threads. This can
9 result in very slight nondeterminism for bitblas. As a result, we re-run the
10 test up to 3 times to see if we pass.
11 -
12 -Run `pytest tests/models/test_bitblas.py`.
11 """
12 from dataclasses import dataclass
13
tests/models/quantization/test_gptq_bitblas.py
-2
@@ -8,8 +8,6 @@ bitblas/GPTQ models are in the top 3 selections of each other.
8 Note: bitblas internally uses locks to synchronize the threads. This can
9 result in very slight nondeterminism for bitblas. As a result, we re-run the
10 test up to 3 times to see if we pass.
11 -
12 -Run `pytest tests/models/test_bitblas.py`.
11 """
12 from dataclasses import dataclass
13
tests/models/quantization/test_gptq_marlin.py
+2 -3
@@ -1,13 +1,12 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Compares the outputs of gptq vs gptq_marlin
2 +"""Compares the outputs of gptq vs gptq_marlin.
3 +
4 Note: GPTQ and Marlin do not have bitwise correctness.
5 As a result, in this test, we just confirm that the top selected tokens of the
6 Marlin/GPTQ models are in the top 5 selections of each other.
7 Note: Marlin internally uses locks to synchronize the threads. This can
8 result in very slight nondeterminism for Marlin. As a result, we re-run the test
9 up to 3 times to see if we pass.
9 -
10 -Run `pytest tests/models/test_gptq_marlin.py`.
10 """
11 import os
12
tests/models/quantization/test_gptq_marlin_24.py
-2
@@ -4,8 +4,6 @@
4 Note: GPTQ and Marlin_24 do not have bitwise correctness.
5 As a result, in this test, we just confirm that the top selected tokens of the
6 Marlin/GPTQ models are in the top 3 selections of each other.
7 -
8 -Run `pytest tests/models/test_marlin_24.py`.
7 """
8 from dataclasses import dataclass
9
tests/models/test_transformers.py
+1 -4
@@ -1,8 +1,5 @@
1 # SPDX-License-Identifier: Apache-2.0
2 -"""Test the functionality of the Transformers backend.
3 -
4 -Run `pytest tests/models/test_transformers.py`.
5 -"""
2 +"""Test the functionality of the Transformers backend."""
3 import pytest
4
5 from ..conftest import HfRunner, VllmRunner