[V1] Bugfix: Validate Model Input Length (#12600)

SUMMARY:
* avoid crashing the engine when we get an input longer than
max_model_len

FIX #12567(*link existing issues this PR will resolve*)
This commit is contained in:
Robert Shaw 2025-01-31 21:32:04 -05:00 committed by GitHub
parent 44bbca78d7
commit b1340f9d55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -206,6 +206,11 @@ class Processor:
if prompt_ids is None or len(prompt_ids) == 0: if prompt_ids is None or len(prompt_ids) == 0:
raise ValueError("Prompt cannot be empty") raise ValueError("Prompt cannot be empty")
if len(prompt_ids) >= self.model_config.max_model_len:
raise ValueError(
f"Prompt length of {len(prompt_ids)} is longer than the "
f"maximum model length of {self.model_config.max_model_len}.")
if self.model_config.is_multimodal_model: if self.model_config.is_multimodal_model:
max_prompt_len = self.model_config.max_model_len max_prompt_len = self.model_config.max_model_len