| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import pytest |
| 5 | import torch |
| 6 | |
| 7 | from vllm.exceptions import VLLMValidationError |
| 8 | |
| 9 | |
| 10 | def test_empty_prompt(vllm_runner): |
| 11 | with ( |
| 12 | vllm_runner("openai-community/gpt2", enforce_eager=True) as runner, |
| 13 | pytest.raises(VLLMValidationError, match="decoder prompt cannot be empty"), |
| 14 | ): |
| 15 | runner.llm.generate([""]) |
| 16 | |
| 17 | |
| 18 | def test_out_of_vocab_token(vllm_runner): |
| 19 | with ( |
| 20 | vllm_runner("openai-community/gpt2", enforce_eager=True) as runner, |
| 21 | pytest.raises(VLLMValidationError, match="out of vocabulary"), |
| 22 | ): |
| 23 | runner.llm.generate({"prompt_token_ids": [999999]}) |
| 24 | |
| 25 | |
| 26 | def test_require_mm_embeds(vllm_runner): |
| 27 | with ( |
| 28 | vllm_runner( |
| 29 | "llava-hf/llava-1.5-7b-hf", |
| 30 | enforce_eager=True, |
| 31 | enable_mm_embeds=False, |
| 32 | ) as runner, |
| 33 | pytest.raises(ValueError, match="--enable-mm-embeds"), |
| 34 | ): |
| 35 | runner.llm.generate( |
| 36 | { |
| 37 | "prompt": "<image>", |
| 38 | "multi_modal_data": {"image": torch.empty(1, 1, 1)}, |
| 39 | } |
| 40 | ) |