test_compatibility.py 2.32 KB
Newer Older
1
2
# SPDX-License-Identifier: Apache-2.0

3
import pytest
4
import os
5
6
7
8

from vllm import SamplingParams

from .conftest import get_output_from_llm_generator
9
from ...utils import models_path_prefix
10
11


12
13
@pytest.mark.parametrize("common_llm_kwargs",
                         [{
zhuwenwen's avatar
zhuwenwen committed
14
                             "model": os.path.join(models_path_prefix, "meta-llama/Llama-3.2-1B-Instruct"),
15
                         }])
16
17
18
19
20
@pytest.mark.parametrize(
    "per_test_common_llm_kwargs",
    [
        {
            # Speculative max model len > overridden max model len should raise.
21
            "speculative_config": {
22
                "model": os.path.join(models_path_prefix, "JackFram/llama-68m"),
23
24
25
                "num_speculative_tokens": 5,
                "max_model_len": 129,
            },
26
27
28
29
30
            "max_model_len": 128,
        },
        {
            # Speculative max model len > draft max model len should raise.
            # https://huggingface.co/JackFram/llama-68m/blob/3b606af5198a0b26762d589a3ee3d26ee6fa6c85/config.json#L12
31
            "speculative_config": {
32
                "model": os.path.join(models_path_prefix, "JackFram/llama-68m"),
33
34
35
                "num_speculative_tokens": 5,
                "max_model_len": 2048 + 1,
            },
36
37
38
        },
        {
            # Speculative max model len > target max model len should raise.
39
40
            # https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct/blob/9213176726f574b556790deb65791e0c5aa438b6/config.json#L18
            "speculative_config": {
41
                "model": os.path.join(models_path_prefix, "JackFram/llama-68m"),
42
43
44
                "num_speculative_tokens": 5,
                "max_model_len": 131072 + 1,
            },
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
        },
    ])
@pytest.mark.parametrize("test_llm_kwargs", [{}])
@pytest.mark.parametrize("seed", [1])
def test_spec_decode_xfail_spec_max_model_len(test_llm_generator):
    """Verify that speculative decoding validates speculative_max_model_len.
    """
    output_len = 128
    temperature = 0.0

    prompts = [
        "Hello, my name is",
    ]

    sampling_params = SamplingParams(
        max_tokens=output_len,
        ignore_eos=True,
        temperature=temperature,
    )

    with pytest.raises(ValueError, match="cannot be larger than"):
        get_output_from_llm_generator(test_llm_generator, prompts,
67
                                      sampling_params)