@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 634a14bd7d
Fork 0

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 11, 05:00 UTC

Strengthen input validation and tests for 'parse_raw_prompts’. (#30652)

Signed-off-by: Kayvan Mivehnejad <K.Mivehnejad@gmail.com>

Kayvan Mivehnejad committed Dec 18, 2025 at 14:51 UTC 634a14bd7d099442e338938cc2dc456266eedaa4
1 file changed +11 -10
vllm/inputs/parse.py
+11 -10
@@ -45,16 +45,17 @@ def parse_raw_prompts(
45
46 # case 4: array of token arrays
47 if is_list_of(prompt, list):
48 - first = prompt[0]
49 - if not isinstance(first, list):
50 - raise ValueError("prompt expected to be a list of lists")
51 -
52 - if len(first) == 0:
53 - raise ValueError("Please provide at least one prompt")
54 -
55 - # strict validation: every nested list must be list[int]
56 - if not all(is_list_of(elem, int) for elem in prompt):
57 - raise TypeError("Nested lists must contain only integers")
48 + if len(prompt) == 1 and isinstance(prompt[0], list) and len(prompt[0]) == 0:
49 + raise ValueError("please provide at least one prompt")
50 + for elem in prompt:
51 + if not isinstance(elem, list):
52 + raise TypeError(
53 + "prompt must be a list of lists, but found a non-list element."
54 + )
55 + if not is_list_of(elem, int):
56 + raise TypeError(
57 + "Nested lists of tokens must contain only integers."
58 + )
59
60 prompt = cast(list[list[int]], prompt)
61 return [TokensPrompt(prompt_token_ids=elem) for elem in prompt]