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 14, 05:30 UTC
[Bugfix][Frontend] validate arg priority in frontend LLM class before add request (#27596)
Signed-off-by: Junpu Fan <junpufan@gmail.com>
Junpu Fan committed
Oct 28, 2025 at 07:02 UTC
b186149e8e9d067c17b5067f73c420b2d8317580
2 files changed
+26
tests/entrypoints/llm/test_generate.py
+20
@@ -71,6 +71,26 @@ def test_multiple_sampling_params(llm: LLM):
71
assert len(PROMPTS) == len(outputs)
72
73
74
+def test_multiple_priority(llm: LLM):
75
+ # Generate works when priority is None
76
+ outputs = llm.generate(PROMPTS, sampling_params=None, priority=None)
77
+ assert len(PROMPTS) == len(outputs)
78
+
79
+ # Generate works when length of priority is same as the len(PROMPTS)
80
+ outputs = llm.generate(PROMPTS, sampling_params=None, priority=[0] * len(PROMPTS))
81
+ assert len(PROMPTS) == len(outputs)
82
+
83
+ # Exception raised, if the length of priority does not match the length of prompts
84
+ with pytest.raises(ValueError):
85
+ outputs = llm.generate(
86
+ PROMPTS, sampling_params=None, priority=[0] * (len(PROMPTS) - 1)
87
+ )
88
+
89
+ # Exception raised, if the priority list is empty
90
+ with pytest.raises(ValueError):
91
+ outputs = llm.generate(PROMPTS, sampling_params=None, priority=[])
92
+
93
+
94
def test_max_model_len():
95
max_model_len = 20
96
llm = LLM(
vllm/entrypoints/llm.py
+6
@@ -1565,6 +1565,12 @@ class LLM:
1565
raise ValueError(
1566
"The lengths of prompts and lora_request must be the same."
1567
)
1568
+ if priority is not None and len(priority) != num_requests:
1569
+ raise ValueError(
1570
+ "The lengths of prompts "
1571
+ f"({num_requests}) and priority ({len(priority)}) "
1572
+ "must be the same."
1573
+ )
1574
1575
for sp in params if isinstance(params, Sequence) else (params,):
1576
if isinstance(sp, SamplingParams):