"vscode:/vscode.git/clone" did not exist on "38bf2ffb21d54eb67a68d4ba82125922f4a4c7ad"
test_accuracy.py 2.19 KB
Newer Older
1
# SPDX-License-Identifier: Apache-2.0
2
3
4
5
6
7
8
9
10
"""
This file test accuracy of the vLLM server via LMEval.
It uses local-completions, which interacts with vLLM
through the OAI API with N concurrent connections.
This simulates real work usage of the API and makes
sure that the zmq frontend mp RPC message passing and
AsyncLLMEngine are working correctly.
"""

zhuwenwen's avatar
zhuwenwen committed
11
import os
12
13
14
15
import lm_eval
import pytest

from vllm.platforms import current_platform
zhuwenwen's avatar
zhuwenwen committed
16
from ...utils import models_path_prefix
17

zhuwenwen's avatar
zhuwenwen committed
18
MODEL_NAME = os.path.join(models_path_prefix, "Qwen/Qwen2-1.5B-Instruct")
19
20
21
22
23
24
25
NUM_CONCURRENT = 500
TASK = "gsm8k"
FILTER = "exact_match,strict-match"
RTOL = 0.03
EXPECTED_VALUE = 0.58


26
def run_test(more_args=None):
27
28
    """Run the end to end accuracy test."""

29
30
31
32
    model_args = f"pretrained={MODEL_NAME},max_model_len=4096"

    if more_args is not None:
        model_args = "{},{}".format(model_args, more_args)
33
34
35
36
37
38
39
40
41
42
43
44
45
46

    results = lm_eval.simple_evaluate(
        model="vllm",
        model_args=model_args,
        tasks="gsm8k",
        batch_size="auto",
    )

    measured_value = results["results"][TASK][FILTER]
    assert (measured_value - RTOL < EXPECTED_VALUE
            and measured_value + RTOL > EXPECTED_VALUE
            ), f"Expected: {EXPECTED_VALUE} |  Measured: {measured_value}"


47
48
49
50
# TODO: [AlexM] Fix it with new CI/CD tests
TPU_TP_TEST_STR = ""  #"tensor_parallel_size=4"


51
52
53
@pytest.mark.skipif(not current_platform.is_cuda()
                    and not current_platform.is_tpu(),
                    reason="V1 is currently only supported on CUDA and TPU")
54
def test_lm_eval_accuracy_v1_engine(monkeypatch: pytest.MonkeyPatch):
55
56
57
58
    """Run with the V1 Engine."""

    with monkeypatch.context() as m:
        m.setenv("VLLM_USE_V1", "1")
59
60
61
62
63
64

        more_args = None
        if current_platform.is_tpu():
            # Limit compilation time for TPU V1
            more_args = "max_num_seqs=64"

65
66
67
68
            # Add TP test (if provided)
            if TPU_TP_TEST_STR:
                more_args += ",{}".format(TPU_TP_TEST_STR)

69
        run_test(more_args)
70
71


72
def test_lm_eval_accuracy_v0_engine(monkeypatch: pytest.MonkeyPatch):
73
74
75
76
77
    """Run with the V0 Engine."""

    with monkeypatch.context() as m:
        m.setenv("VLLM_USE_V1", "0")
        run_test()