"vllm/vscode:/vscode.git/clone" did not exist on "24a03915f525b88ebc4c36127c3e9ccf56dc21ee"
test_mistral.py 1.22 KB
Newer Older
1
2
"""Compare the outputs of HF and vLLM for Mistral models using greedy sampling.

3
Run `pytest tests/models/test_mistral.py`.
4
5
6
"""
import pytest

7
8
from tests.models.utils import check_logprobs_close

9
10
11
12
13
14
15
MODELS = [
    "mistralai/Mistral-7B-Instruct-v0.1",
]


@pytest.mark.parametrize("model", MODELS)
@pytest.mark.parametrize("dtype", ["bfloat16"])
16
17
@pytest.mark.parametrize("max_tokens", [64])
@pytest.mark.parametrize("num_logprobs", [5])
18
19
20
def test_models(
    hf_runner,
    vllm_runner,
21
    example_prompts,
22
23
24
    model: str,
    dtype: str,
    max_tokens: int,
25
    num_logprobs: int,
26
) -> None:
27
    # TODO(sang): Sliding window should be tested separately.
28
    hf_model = hf_runner(model, dtype=dtype)
29
30
    hf_outputs = hf_model.generate_greedy_logprobs_limit(
        example_prompts, max_tokens, num_logprobs)
31
32
33
    del hf_model

    vllm_model = vllm_runner(model, dtype=dtype)
34
35
36
    vllm_outputs = vllm_model.generate_greedy_logprobs(example_prompts,
                                                       max_tokens,
                                                       num_logprobs)
37
    del vllm_model
38
39
40
41
42
43
    check_logprobs_close(
        outputs_0_lst=hf_outputs,
        outputs_1_lst=vllm_outputs,
        name_0="hf",
        name_1="vllm",
    )