"vscode:/vscode.git/clone" did not exist on "dcaabcf7bcb0ea78ed31797208dbe9238bb27963"
test_skip_tokenizer_init.py 995 Bytes
Newer Older
1
2
# SPDX-License-Identifier: Apache-2.0

3
4
5
6
7
8
import pytest

from vllm.entrypoints.llm import LLM
from vllm.sampling_params import SamplingParams


9
@pytest.mark.parametrize("model", ["distilbert/distilgpt2"])
10
11
12
13
def test_skip_tokenizer_initialization(model: str):
    # This test checks if the flag skip_tokenizer_init skips the initialization
    # of tokenizer and detokenizer. The generated output is expected to contain
    # token ids.
14
15
16
17
    llm = LLM(
        model=model,
        skip_tokenizer_init=True,
    )
18
    sampling_params = SamplingParams(prompt_logprobs=True, detokenize=True)
19
20

    with pytest.raises(ValueError, match="cannot pass text prompts when"):
21
        llm.generate("abc", sampling_params)
22

23
    outputs = llm.generate({"prompt_token_ids": [1, 2, 3]},
24
25
26
27
28
29
                           sampling_params=sampling_params)
    assert len(outputs) > 0
    completions = outputs[0].outputs
    assert len(completions) > 0
    assert completions[0].text == ""
    assert completions[0].token_ids