Skip to content

Commit 8642a41

Browse files
alexey-belyakovdbyoung18
authored andcommitted
check input length of sonnet samples (vllm-project#16423)
Signed-off-by: alexey-belyakov <[email protected]>
1 parent f2bc768 commit 8642a41

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

benchmarks/benchmark_dataset.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,21 +489,22 @@ def sample(
489489
prefix_lines = self.data[:num_prefix_lines]
490490

491491
samples = []
492-
for _ in range(num_requests):
492+
while len(samples) < num_requests:
493493
extra_lines = random.choices(self.data,
494494
k=num_input_lines - num_prefix_lines)
495495
prompt = f"{base_prompt}{''.join(prefix_lines + extra_lines)}"
496496
msg = [{"role": "user", "content": prompt}]
497497
prompt_formatted = tokenizer.apply_chat_template(
498498
msg, add_generation_prompt=True, tokenize=False)
499499
prompt_len = len(tokenizer(prompt_formatted).input_ids)
500-
samples.append(
501-
SampleRequest(
502-
prompt=prompt_formatted
503-
if return_prompt_formatted else prompt,
504-
prompt_len=prompt_len,
505-
expected_output_len=output_len,
506-
))
500+
if prompt_len <= input_len:
501+
samples.append(
502+
SampleRequest(
503+
prompt=prompt_formatted
504+
if return_prompt_formatted else prompt,
505+
prompt_len=prompt_len,
506+
expected_output_len=output_len,
507+
))
507508
return samples
508509

509510

0 commit comments

Comments
 (0)