"vllm/v1/engine/input_processor.py" did not exist on "af4ee63e0e9d051e3f3756a2d33686e774503f4a"
test_ignore_eos.py 1000 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
"""Make sure ignore_eos works.

Run `pytest tests/samplers/test_ignore_eos.py`.
"""

import pytest

from vllm import SamplingParams

Simon Mo's avatar
Simon Mo committed
10
11
12
# We also test with llama because it has generation_config to specify EOS
# (past regression).
MODELS = ["facebook/opt-125m", "meta-llama/Llama-2-7b-hf"]
13
14
15
16


@pytest.mark.parametrize("model", MODELS)
@pytest.mark.parametrize("dtype", ["half"])
Simon Mo's avatar
Simon Mo committed
17
18
@pytest.mark.parametrize("max_tokens", [512])
def test_ignore_eos(
19
20
21
22
23
24
    vllm_runner,
    example_prompts,
    model: str,
    dtype: str,
    max_tokens: int,
) -> None:
25
26
27
    with vllm_runner(model, dtype=dtype) as vllm_model:
        sampling_params = SamplingParams(max_tokens=max_tokens,
                                         ignore_eos=True)
Simon Mo's avatar
Simon Mo committed
28

29
30
31
32
33
        for prompt in example_prompts:
            ignore_eos_output = vllm_model.model.generate(
                prompt, sampling_params=sampling_params)
            output_length = len(ignore_eos_output[0].outputs[0].token_ids)
            assert output_length == max_tokens