"tests/vscode:/vscode.git/clone" did not exist on "f54f85129e4665c16f39b097463c3c350ef34210"
Unverified Commit b186149e authored by Junpu Fan's avatar Junpu Fan Committed by GitHub
Browse files

[Bugfix][Frontend] validate arg priority in frontend LLM class before add request (#27596)


Signed-off-by: default avatarJunpu Fan <junpufan@gmail.com>
parent 2abbd351
...@@ -71,6 +71,26 @@ def test_multiple_sampling_params(llm: LLM): ...@@ -71,6 +71,26 @@ def test_multiple_sampling_params(llm: LLM):
assert len(PROMPTS) == len(outputs) assert len(PROMPTS) == len(outputs)
def test_multiple_priority(llm: LLM):
# Generate works when priority is None
outputs = llm.generate(PROMPTS, sampling_params=None, priority=None)
assert len(PROMPTS) == len(outputs)
# Generate works when length of priority is same as the len(PROMPTS)
outputs = llm.generate(PROMPTS, sampling_params=None, priority=[0] * len(PROMPTS))
assert len(PROMPTS) == len(outputs)
# Exception raised, if the length of priority does not match the length of prompts
with pytest.raises(ValueError):
outputs = llm.generate(
PROMPTS, sampling_params=None, priority=[0] * (len(PROMPTS) - 1)
)
# Exception raised, if the priority list is empty
with pytest.raises(ValueError):
outputs = llm.generate(PROMPTS, sampling_params=None, priority=[])
def test_max_model_len(): def test_max_model_len():
max_model_len = 20 max_model_len = 20
llm = LLM( llm = LLM(
......
...@@ -1565,6 +1565,12 @@ class LLM: ...@@ -1565,6 +1565,12 @@ class LLM:
raise ValueError( raise ValueError(
"The lengths of prompts and lora_request must be the same." "The lengths of prompts and lora_request must be the same."
) )
if priority is not None and len(priority) != num_requests:
raise ValueError(
"The lengths of prompts "
f"({num_requests}) and priority ({len(priority)}) "
"must be the same."
)
for sp in params if isinstance(params, Sequence) else (params,): for sp in params if isinstance(params, Sequence) else (params,):
if isinstance(sp, SamplingParams): if isinstance(sp, SamplingParams):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment