Skip to content

Commit

Permalink
[Misc] Improve validation errors around best_of and n (vllm-project#9167
Browse files Browse the repository at this point in the history
)

Signed-off-by: Travis Johnson <[email protected]>
  • Loading branch information
tjohnson31415 authored Oct 9, 2024
1 parent f5389e7 commit 2f72195
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vllm/sampling_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def _verify_args(self) -> None:
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 '
f'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}.")
Expand Down Expand Up @@ -390,10 +390,13 @@ def _verify_args(self) -> None:
raise ValueError("best_of must equal n to use output_kind=DELTA")

def _verify_greedy_sampling(self) -> None:
if self.n > 1:
raise ValueError("n must be 1 when using greedy sampling, "
f"got {self.n}.")
assert isinstance(self.best_of, int)
if self.best_of > 1:
raise ValueError("best_of must be 1 when using greedy sampling."
f"Got {self.best_of}.")
raise ValueError("best_of must be 1 when using greedy sampling, "
f"got {self.best_of}.")

def update_from_generation_config(
self,
Expand Down

0 comments on commit 2f72195

Please sign in to comment.