Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions vllm/sampling_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,20 +575,32 @@ def _verify_args(self) -> None:
parameter="prompt_logprobs",
value=self.prompt_logprobs,
)
assert isinstance(self.stop_token_ids, list)
if not isinstance(self.stop_token_ids, list):
raise TypeError(
"stop_token_ids must be a list, got "
f"{type(self.stop_token_ids).__name__}."
)
if not all(isinstance(st_id, int) for st_id in self.stop_token_ids):
raise ValueError(
f"stop_token_ids must contain only integers, got {self.stop_token_ids}."
)
assert isinstance(self.stop, list)
if not isinstance(self.stop, list):
raise TypeError(
"stop must be a list, got "
f"{type(self.stop).__name__}."
)
if any(not stop_str for stop_str in self.stop):
raise ValueError("stop cannot contain an empty string.")
if self.stop and not self.detokenize:
raise ValueError(
"stop strings are only supported when detokenize is True. "
"Set detokenize=True to use stop."
)
assert isinstance(self.bad_words, list)
if not isinstance(self.bad_words, list):
raise TypeError(
"bad_words must be a list, got "
f"{type(self.bad_words).__name__}."
)
if any(not bad_word for bad_word in self.bad_words):
raise ValueError(
f"bad_words cannot contain an empty string. "
Expand Down Expand Up @@ -625,7 +637,11 @@ def update_from_generation_config(
if eos_ids:
self._all_stop_token_ids.update(eos_ids)
if not self.ignore_eos:
assert self.stop_token_ids is not None
if self.stop_token_ids is None:
raise ValueError(
"stop_token_ids should have been initialized "
"to a list in __post_init__, but is None."
)
eos_ids.update(self.stop_token_ids)
self.stop_token_ids = list(eos_ids)

Expand Down
Loading