Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/entrypoints/openai/test_prompt_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ async def test_empty_prompt():
)


@pytest.mark.asyncio
async def test_empty_prompt_list():
model_name = "gpt2"
server_args = ["--enforce-eager"]
with RemoteOpenAIServer(model_name, server_args) as remote_server:
client = remote_server.get_async_client()

with pytest.raises(
openai.BadRequestError,
match="Either prompt or prompt_embeds must be provided and non-empty.",
):
await client.completions.create(
model=model_name,
prompt=[],
max_tokens=5,
temperature=0.0,
)


@pytest.mark.asyncio
async def test_out_of_vocab_token_ids():
model_name = "gpt2"
Expand Down
53 changes: 53 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from vllm.config.vllm import (
OPTIMIZATION_LEVEL_TO_CONFIG,
OptimizationLevel,
enable_allreduce_rms_fusion,
)
from vllm.platforms import current_platform

Expand Down Expand Up @@ -58,6 +59,58 @@ def test_async_scheduling_with_pipeline_parallelism_is_allowed():
assert cfg.scheduler_config.async_scheduling is True


@pytest.mark.parametrize(
("parallel_config", "should_be_enabled"),
[
(
ParallelConfig(
tensor_parallel_size=2,
pipeline_parallel_size=1,
data_parallel_size=1,
),
True,
),
(
ParallelConfig(
tensor_parallel_size=1,
pipeline_parallel_size=1,
data_parallel_size=1,
),
False,
),
(
ParallelConfig(
tensor_parallel_size=2,
pipeline_parallel_size=2,
data_parallel_size=1,
),
False,
),
(
ParallelConfig(
tensor_parallel_size=2,
pipeline_parallel_size=1,
data_parallel_size=2,
),
False,
),
],
ids=["TP-only", "No-TP", "With-PP", "With-DP"],
)
def test_enable_allreduce_rms_fusion_gating(
parallel_config: ParallelConfig,
should_be_enabled: bool,
):
cfg = VllmConfig(parallel_config=parallel_config)

with (
patch("vllm.utils.flashinfer.has_flashinfer", return_value=True),
patch.object(current_platform, "is_cuda", return_value=True),
patch.object(current_platform, "is_device_capability", return_value=True),
):
assert enable_allreduce_rms_fusion(cfg) is should_be_enabled


@dataclass
class _TestConfigFields:
a: int
Expand Down
4 changes: 3 additions & 1 deletion vllm/entrypoints/openai/completion/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ def validate_prompt_and_prompt_embeds(cls, data):
prompt = data.get("prompt")
prompt_embeds = data.get("prompt_embeds")

prompt_is_empty = prompt is None or (isinstance(prompt, str) and prompt == "")
prompt_is_empty = prompt is None or (
isinstance(prompt, (str, list)) and len(prompt) == 0
)
embeds_is_empty = prompt_embeds is None or (
isinstance(prompt_embeds, list) and len(prompt_embeds) == 0
)
Expand Down
Loading