A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 07:15 UTC
[Misc] fix: add miss best_of param validation (#18555)
Signed-off-by: googs1025 <googs1025@gmail.com>
CYJiang committed
Jun 4, 2025 at 02:02 UTC
d054da1992175787f936d18aead51bef663a0399
1 file changed
+11
vllm/sampling_params.py
+11
@@ -389,6 +389,17 @@ class SamplingParams(
389
f"type {type(self.n)}")
390
if self.n < 1:
391
raise ValueError(f"n must be at least 1, got {self.n}.")
392
+ if self.best_of is not None:
393
+ if not isinstance(self.best_of, int):
394
+ raise ValueError(
395
+ f"best_of must be an integer, got {type(self.best_of)}")
396
+ if self.best_of < 1:
397
+ raise ValueError(
398
+ f"best_of must be at least 1, got {self.best_of}")
399
+ if self.best_of < self.n:
400
+ raise ValueError(
401
+ f"best_of must be greater than or equal to n, "
402
+ f"got n={self.n} and best_of={self.best_of}.")
403
if not -2.0 <= self.presence_penalty <= 2.0:
404
raise ValueError("presence_penalty must be in [-2, 2], got "
405
f"{self.presence_penalty}.")