Skip to content

[Frontend] Raise an extremely dangerous warning when using VLLM_ALLOW_LONG_MAX_MODEL_LEN #20904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 13 additions & 6 deletions vllm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3631,13 +3631,20 @@ def _get_and_verify_max_len(
f"{model_max_length} in model's config.json). This may lead "
"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)
logger.extremely_dangerous(
"Using VLLM_ALLOW_LONG_MAX_MODEL_LEN may lead"
" to the following exceptions:\n"
"- If the model uses rope position encoding, "
"positions exceeding derived_max_model_len "
"lead to nan.\n"
"- If the model uses absolute position encoding, "
"positions exceeding derived_max_model_len "
"will cause a CUDA array out-of-bounds error.\n"
"For testing purposes only, do not implement "
"any functionality relying "
"on VLLM_ALLOW_LONG_MAX_MODEL_LEN.")
else:
raise ValueError(
f"{msg} To allow overriding this maximum, set "
"the env var VLLM_ALLOW_LONG_MAX_MODEL_LEN=1")
raise ValueError(msg)
return int(max_model_len)


Expand Down
10 changes: 10 additions & 0 deletions vllm/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
logger.warning(msg, *args, stacklevel=2)


def _extremely_dangerous(logger: Logger, msg: str, *args: Hashable) -> None:
template = (f"\n===== EXTREMELY DANGEROUS =====\n"
f"{msg}\n===============================\n")
logger.warning(template, *args, stacklevel=2)


class _VllmLogger(Logger):
"""
Note:
Expand Down Expand Up @@ -101,6 +107,9 @@
"""
_print_warning_once(self, msg, *args)

def extremely_dangerous(self, param, *args):
_extremely_dangerous(param, *args)


def _configure_vllm_root_logger() -> None:
logging_config = dict[str, Any]()
Expand Down Expand Up @@ -148,10 +157,11 @@
"debug_once": _print_debug_once,
"info_once": _print_info_once,
"warning_once": _print_warning_once,
"extremely_dangerous": _extremely_dangerous
}

for method_name, method in methods_to_patch.items():
setattr(logger, method_name, MethodType(method, logger))

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

Check failure on line 164 in vllm/logger.py

View workflow job for this annotation

GitHub Actions / pre-commit

Argument 1 to "MethodType" has incompatible type "object"; expected "Callable[..., Any]" [arg-type]

return cast(_VllmLogger, logger)

Expand Down