Skip to content

Commit b399814

Browse files
yewentao256lywa1998
authored andcommitted
[Bug] Add Assertion for random-input-len / random-output-len (vllm-project#26834)
Signed-off-by: yewentao256 <[email protected]>
1 parent 072abb8 commit b399814

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vllm/benchmarks/datasets.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,22 @@ def sample(
478478
batchsize: int = 1,
479479
**kwargs,
480480
) -> list[SampleRequest]:
481+
# validate total input tokens (prefix + sampled) is at least 1.
482+
num_special = int(tokenizer.num_special_tokens_to_add())
483+
real_input_len = max(0, int(input_len) - num_special)
484+
min_sampled_input = math.floor(real_input_len * (1.0 - float(range_ratio)))
485+
min_total_input = int(prefix_len) + min_sampled_input
486+
if min_total_input < 1:
487+
raise ValueError(
488+
"--random-input-len is too small: with tokenizer special "
489+
f"tokens {num_special} and --random-range-ratio {range_ratio}, "
490+
"the minimum possible total input tokens (prefix + sampled) is "
491+
f"{min_total_input}. Increase --random-input-len and/or "
492+
"--random-prefix-len, or decrease --random-range-ratio so that "
493+
"prefix_len + floor(max(0, random_input_len - num_special)) "
494+
"* (1 - range_ratio) >= 1."
495+
)
496+
481497
input_lens, output_lens, offsets = self.get_sampling_params(
482498
num_requests, range_ratio, input_len, output_len, tokenizer
483499
)

0 commit comments

Comments
 (0)