Skip to content

Commit f296d16

Browse files
ekagra-ranjanywang96
authored andcommitted
[Bug][Benchmark] Fix duplicate req in oversampling (vllm-project#26140)
Signed-off-by: Ekagra Ranjan <3116519+ekagra-ranjan@users.noreply.github.com> Co-authored-by: Roger Wang <hey@rogerw.io> Signed-off-by: Karan Goel <3261985+karan@users.noreply.github.com>
1 parent 39d9aaf commit f296d16

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

vllm/benchmarks/datasets.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,22 @@ def maybe_oversample_requests(
235235

236236
if len(requests) < num_requests:
237237
random.seed(self.random_seed)
238-
additional = deepcopy(
239-
random.choices(requests, k=num_requests - len(requests))
240-
)
241-
for i in range(len(additional)):
242-
req = additional[i]
238+
needed = num_requests - len(requests)
239+
additional = []
240+
for i in range(needed):
241+
req = deepcopy(random.choice(requests))
243242
req.request_id = request_id_prefix + str(len(requests) + i)
243+
additional.append(req)
244244
requests.extend(additional)
245245
logger.info("Oversampled requests to reach %d total samples.",
246246
num_requests)
247247

248+
ids = [req.request_id for req in requests]
249+
if len(ids) != len(set(ids)):
250+
raise ValueError("Duplicate request_id found in the sampled "
251+
"requests. Please ensure that each request_id "
252+
"is unique.")
253+
248254

249255
# -----------------------------------------------------------------------------
250256
# Utility Functions and Global Caches

0 commit comments

Comments
 (0)