Skip to content

Commit 7508e80

Browse files
saumya-saranLeiWang1999
authored andcommitted
[Bugfix] Validate SamplingParam n is an int (vllm-project#8548)
Signed-off-by: LeiWang1999 <[email protected]>
1 parent ef7bc97 commit 7508e80

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/sampling_params.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,14 @@ def __post_init__(self) -> None:
273273
self._all_stop_token_ids = set(self.stop_token_ids)
274274

275275
def _verify_args(self) -> None:
276+
if not isinstance(self.n, int):
277+
raise ValueError(f"n must be an int, but is of "
278+
f"type {type(self.n)}")
276279
if self.n < 1:
277280
raise ValueError(f"n must be at least 1, got {self.n}.")
278-
assert isinstance(self.best_of, int)
281+
if not isinstance(self.best_of, int):
282+
raise ValueError(f'best_of must be an int, but is of '
283+
f'type {type(self.best_of)}')
279284
if self.best_of < self.n:
280285
raise ValueError(f"best_of must be greater than or equal to n, "
281286
f"got n={self.n} and best_of={self.best_of}.")

0 commit comments

Comments
 (0)