2024-08-23 21:12:44 +08:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from vllm import LLM
|
|
|
|
|
|
|
|
|
|
|
2024-11-07 03:57:35 +08:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def v1(run_with_both_engines):
|
|
|
|
|
# Simple autouse wrapper to run both engines for each test
|
|
|
|
|
# This can be promoted up to conftest.py to run for every
|
|
|
|
|
# test in a package
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2024-08-23 21:12:44 +08:00
|
|
|
def test_empty_prompt():
|
2024-10-30 05:13:20 +08:00
|
|
|
llm = LLM(model="gpt2", enforce_eager=True)
|
2024-08-23 21:12:44 +08:00
|
|
|
with pytest.raises(ValueError, match='Prompt cannot be empty'):
|
|
|
|
|
llm.generate([""])
|
2024-10-30 05:13:20 +08:00
|
|
|
|
|
|
|
|
|
2024-11-07 03:57:35 +08:00
|
|
|
@pytest.mark.skip_v1
|
2024-10-30 05:13:20 +08:00
|
|
|
def test_out_of_vocab_token():
|
|
|
|
|
llm = LLM(model="gpt2", enforce_eager=True)
|
|
|
|
|
with pytest.raises(ValueError, match='out of vocabulary'):
|
|
|
|
|
llm.generate({"prompt_token_ids": [999999]})
|