A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 08:30 UTC
[Misc] refactor: simplify input validation and num_requests handling in _convert_v1_inputs (#18482)
Signed-off-by: googs1025 <googs1025@gmail.com>
CYJiang committed
May 23, 2025 at 10:15 UTC
fae453f8ce5cf6cb43f464068eb0e201669e11d7
1 file changed
+10
-12
vllm/entrypoints/llm.py
+10
-12
@@ -1306,27 +1306,25 @@ class LLM:
1306
):
1307
# skip_tokenizer_init is now checked in engine
1308
1309
+ if prompts is None and prompt_token_ids is None:
1310
+ raise ValueError(
1311
+ "Either prompts or prompt_token_ids must be provided.")
1312
+ if prompts is not None and prompt_token_ids is not None \
1313
+ and len(prompts) != len(prompt_token_ids):
1314
+ raise ValueError(
1315
+ "The lengths of prompts and prompt_token_ids must be the same."
1316
+ )
1317
+
1318
if prompts is not None:
1319
prompts = [p["content"] for p in parse_and_batch_prompt(prompts)]
1320
if prompt_token_ids is not None:
1321
prompt_token_ids = [
1322
p["content"] for p in parse_and_batch_prompt(prompt_token_ids)
1323
]
1315
-
1316
- num_requests = None
1324
if prompts is not None:
1325
num_requests = len(prompts)
1319
- if prompt_token_ids is not None:
1320
- if (num_requests is not None
1321
- and num_requests != len(prompt_token_ids)):
1322
- raise ValueError("The lengths of prompts and prompt_token_ids "
1323
- "must be the same.")
1324
-
1326
+ elif prompt_token_ids is not None:
1327
num_requests = len(prompt_token_ids)
1326
- if num_requests is None:
1327
- raise ValueError("Either prompts or prompt_token_ids must be "
1328
- "provided.")
1329
-
1328
parsed_prompts: list[PromptType] = []
1329
for i in range(num_requests):
1330
item: PromptType