Skip to content

Commit a464c50

Browse files
saumya-saranAlvant
authored andcommitted
[Bugfix] Validate SamplingParam n is an int (vllm-project#8548)
Signed-off-by: Alvant <alvasian@yandex.ru>
1 parent c07bd6b commit a464c50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/sampling_params.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,14 @@ def __post_init__(self) -> None:
270270
self._all_stop_token_ids = set(self.stop_token_ids)
271271

272272
def _verify_args(self) -> None:
273+
if not isinstance(self.n, int):
274+
raise ValueError(f"n must be an int, but is of "
275+
f"type {type(self.n)}")
273276
if self.n < 1:
274277
raise ValueError(f"n must be at least 1, got {self.n}.")
275-
assert isinstance(self.best_of, int)
278+
if not isinstance(self.best_of, int):
279+
raise ValueError(f'best_of must be an int, but is of '
280+
f'type {type(self.best_of)}')
276281
if self.best_of < self.n:
277282
raise ValueError(f"best_of must be greater than or equal to n, "
278283
f"got n={self.n} and best_of={self.best_of}.")

0 commit comments

Comments
 (0)