From 7bf973b46a283d1dc1ebe865aeef0ac595692a39 Mon Sep 17 00:00:00 2001 From: saumya-saran Date: Tue, 17 Sep 2024 18:58:07 +0000 Subject: [PATCH 1/4] Enforce SamplingParam 'n' is an int --- vllm/sampling_params.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vllm/sampling_params.py b/vllm/sampling_params.py index 5edbc8e424e8..6f23a96b2b4f 100644 --- a/vllm/sampling_params.py +++ b/vllm/sampling_params.py @@ -273,9 +273,11 @@ def __post_init__(self) -> None: self._all_stop_token_ids = set(self.stop_token_ids) def _verify_args(self) -> None: + assert isinstance(self.n, int) if self.n < 1: raise ValueError(f"n must be at least 1, got {self.n}.") assert isinstance(self.best_of, int) + if self.best_of < self.n: raise ValueError(f"best_of must be greater than or equal to n, " f"got n={self.n} and best_of={self.best_of}.") From 2f49b7283fe6b17cac398c0fc81489fc79db174e Mon Sep 17 00:00:00 2001 From: saumya-saran Date: Tue, 17 Sep 2024 21:06:56 +0000 Subject: [PATCH 2/4] Remove extra space --- vllm/sampling_params.py | 1 - 1 file changed, 1 deletion(-) diff --git a/vllm/sampling_params.py b/vllm/sampling_params.py index 6f23a96b2b4f..5838101d0177 100644 --- a/vllm/sampling_params.py +++ b/vllm/sampling_params.py @@ -277,7 +277,6 @@ def _verify_args(self) -> None: if self.n < 1: raise ValueError(f"n must be at least 1, got {self.n}.") assert isinstance(self.best_of, int) - if self.best_of < self.n: raise ValueError(f"best_of must be greater than or equal to n, " f"got n={self.n} and best_of={self.best_of}.") From 6c19a10f247ddd54040aac0d607c7493ecc38733 Mon Sep 17 00:00:00 2001 From: saumya-saran Date: Wed, 18 Sep 2024 23:39:24 +0000 Subject: [PATCH 3/4] Raise ValueError --- vllm/sampling_params.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vllm/sampling_params.py b/vllm/sampling_params.py index 5838101d0177..65f68aee60e4 100644 --- a/vllm/sampling_params.py +++ b/vllm/sampling_params.py @@ -273,10 +273,12 @@ def __post_init__(self) -> None: self._all_stop_token_ids = set(self.stop_token_ids) def _verify_args(self) -> None: - assert isinstance(self.n, int) + if not isinstance(self.n, int): + raise ValueError(f"n must be an int, but is of type {type(self.n)}") if self.n < 1: raise ValueError(f"n must be at least 1, got {self.n}.") - assert isinstance(self.best_of, int) + if not isinstance(self.best_of, int): + raise ValueError(f'best_of must be an int, but is of type {type(self.best_of)}') if self.best_of < self.n: raise ValueError(f"best_of must be greater than or equal to n, " f"got n={self.n} and best_of={self.best_of}.") From 386ac901bb95a8e109fa45e690d8cfdb83644ee8 Mon Sep 17 00:00:00 2001 From: saumya-saran Date: Thu, 19 Sep 2024 17:13:54 +0000 Subject: [PATCH 4/4] Line too long --- vllm/sampling_params.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vllm/sampling_params.py b/vllm/sampling_params.py index 65f68aee60e4..86e80ae5e224 100644 --- a/vllm/sampling_params.py +++ b/vllm/sampling_params.py @@ -274,11 +274,13 @@ def __post_init__(self) -> None: def _verify_args(self) -> None: if not isinstance(self.n, int): - raise ValueError(f"n must be an int, but is of type {type(self.n)}") + raise ValueError(f"n must be an int, but is of " + f"type {type(self.n)}") if self.n < 1: raise ValueError(f"n must be at least 1, got {self.n}.") if not isinstance(self.best_of, int): - raise ValueError(f'best_of must be an int, but is of type {type(self.best_of)}') + raise ValueError(f'best_of must be an int, but is of ' + f'type {type(self.best_of)}') if self.best_of < self.n: raise ValueError(f"best_of must be greater than or equal to n, " f"got n={self.n} and best_of={self.best_of}.")