[VLM] Disallow overflowing max_model_len for multimodal models (#7998)
This commit is contained in:
@@ -2010,7 +2010,22 @@ class LLMEngine:
|
||||
|
||||
def _validate_model_inputs(self, inputs: Union[LLMInputs,
|
||||
EncoderDecoderLLMInputs]):
|
||||
prompt_key = "encoder_prompt_token_ids" \
|
||||
if self.is_encoder_decoder_model() else "prompt_token_ids"
|
||||
if not inputs.get(prompt_key):
|
||||
if self.is_encoder_decoder_model():
|
||||
prompt_ids = inputs.get("encoder_prompt_token_ids")
|
||||
else:
|
||||
prompt_ids = inputs.get("prompt_token_ids")
|
||||
|
||||
if prompt_ids is None or len(prompt_ids) == 0:
|
||||
raise ValueError("Prompt cannot be empty")
|
||||
|
||||
if self.model_config.multimodal_config is not None:
|
||||
max_prompt_len = self.model_config.max_model_len
|
||||
|
||||
if len(prompt_ids) > max_prompt_len:
|
||||
raise ValueError(
|
||||
f"The prompt (total length {len(prompt_ids)}) is too long "
|
||||
f"to fit into the model (context length {max_prompt_len}). "
|
||||
"Make sure that `max_model_len` is no smaller than the "
|
||||
"number of text tokens plus multimodal tokens. For image "
|
||||
"inputs, the number of image tokens depends on the number "
|
||||
"of images, and possibly their aspect ratios as well.")
|
||||
|
||||
Reference in New Issue
Block a user