[Frontend] Warn if user max_model_len is greater than derived max_model_len (#7080)
Signed-off-by: Jefferson Fialho <jfialho@ibm.com> Co-authored-by: Nick Hill <nickhill@us.ibm.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, ClassVar, List, Optional, Tuple, Type, Union
|
||||
import torch
|
||||
from transformers import PretrainedConfig
|
||||
|
||||
import vllm.envs as envs
|
||||
from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.quantization import QUANTIZATION_METHODS
|
||||
from vllm.model_executor.models import ModelRegistry
|
||||
@@ -1541,15 +1542,21 @@ def _get_and_verify_max_len(
|
||||
"Disabling sliding window is not supported for models "
|
||||
"model_max_length in the config. Please raise an issue "
|
||||
"so we can investigate.")
|
||||
pass
|
||||
else:
|
||||
raise ValueError(
|
||||
msg = (
|
||||
f"User-specified max_model_len ({max_model_len}) is greater "
|
||||
"than the derived max_model_len "
|
||||
f"({max_len_key}={derived_max_model_len} or model_max_length="
|
||||
f"than the derived max_model_len ({max_len_key}="
|
||||
f"{derived_max_model_len} or model_max_length="
|
||||
f"{model_max_length} in model's config.json). This may lead "
|
||||
"to incorrect model outputs or CUDA errors. Make sure the "
|
||||
"value is correct and within the model context size.")
|
||||
"to incorrect model outputs or CUDA errors.")
|
||||
if envs.VLLM_ALLOW_LONG_MAX_MODEL_LEN:
|
||||
logger.warning(
|
||||
"%s Make sure the value is correct and within the "
|
||||
"model context size.", msg)
|
||||
else:
|
||||
raise ValueError(
|
||||
f"{msg} To allow overriding this maximum, set "
|
||||
"the env var VLLM_ALLOW_LONG_MAX_MODEL_LEN=1")
|
||||
return int(max_model_len)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user