@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 8262a3e23b
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 13:30 UTC

[Misc] Validate `stop_token_ids` contents (#17268)

Signed-off-by: Nick Hill <nhill@redhat.com>

Nick Hill committed Apr 27, 2025 at 20:54 UTC 8262a3e23b4dc8a29793dff0329ca0743373c85f
1 file changed +4
vllm/sampling_params.py
+4
@@ -437,6 +437,10 @@ class SamplingParams(
437 and self.truncate_prompt_tokens < 1):
438 raise ValueError(f"truncate_prompt_tokens must be >= 1, "
439 f"got {self.truncate_prompt_tokens}")
440 + assert isinstance(self.stop_token_ids, list)
441 + if not all(isinstance(st_id, int) for st_id in self.stop_token_ids):
442 + raise ValueError(f"stop_token_ids must contain only integers, "
443 + f"got {self.stop_token_ids}.")
444 assert isinstance(self.stop, list)
445 if any(not stop_str for stop_str in self.stop):
446 raise ValueError("stop cannot contain an empty string.")