File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,26 @@ def test_multiple_sampling_params(llm: LLM):
7171 assert len (PROMPTS ) == len (outputs )
7272
7373
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+
7494def test_max_model_len ():
7595 max_model_len = 20
7696 llm = LLM (
Original file line number Diff line number Diff line change @@ -1565,6 +1565,12 @@ def _validate_and_add_requests(
15651565 raise ValueError (
15661566 "The lengths of prompts and lora_request must be the same."
15671567 )
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+ )
15681574
15691575 for sp in params if isinstance (params , Sequence ) else (params ,):
15701576 if isinstance (sp , SamplingParams ):
You can’t perform that action at this time.
0 commit comments