Skip to content
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

Introduce VLLM_VERBOSITY environment variable #1165

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion vllm/entrypoints/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ async def stream_results() -> AsyncGenerator[bytes, None]:
uvicorn.run(app,
host=args.host,
port=args.port,
log_level="debug",
log_level="warning",
Copy link
Contributor Author

@danilopeixoto danilopeixoto Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we log only warnings and critical errors for uvicorn dependency (internal).

Copy link

@sd109 sd109 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to omit this argument completely so that the uvicorn log level can be set with its own environment variable? See https://www.uvicorn.org/settings/

timeout_keep_alive=TIMEOUT_KEEP_ALIVE)
2 changes: 1 addition & 1 deletion vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,5 +623,5 @@ async def fake_stream_generator() -> AsyncGenerator[str, None]:
uvicorn.run(app,
host=args.host,
port=args.port,
log_level="info",
log_level="warning",
timeout_keep_alive=TIMEOUT_KEEP_ALIVE)
26 changes: 22 additions & 4 deletions vllm/logger.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Adapted from
# https://github.com/skypilot-org/skypilot/blob/86dc0f6283a335e4aa37b3c10716f90999f48ab6/sky/sky_logging.py
"""Logging configuration for vLLM."""
import os
import logging
import sys


log_levels = {
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"critical": logging.CRITICAL,
}

_FORMAT = "%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s"
_DATE_FORMAT = "%m-%d %H:%M:%S"


class NewLineFormatter(logging.Formatter):
class _NewLineFormatter(logging.Formatter):
"""Adds logging prefix to newlines to align multi-line messages."""

def __init__(self, fmt, datefmt=None):
Expand All @@ -26,15 +36,23 @@ def format(self, record):
_default_handler = None


def _get_default_logging_level():
verbosity = os.getenv("VLLM_VERBOSITY", "info").lower()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For vLLM logs, we allow debug, info, warning, error and critical levels.
The default is info. The default can be overridden by VLLM_VERBOSITY variable.

Users may want to set it to warning in production.


try:
return log_levels[verbosity]
except KeyError:
raise ValueError(f"Unknown log level: {verbosity}")

def _setup_logger():
_root_logger.setLevel(logging.DEBUG)
_root_logger.setLevel(_get_default_logging_level())
global _default_handler
if _default_handler is None:
_default_handler = logging.StreamHandler(sys.stdout)
_default_handler.flush = sys.stdout.flush # type: ignore
_default_handler.setLevel(logging.INFO)
_default_handler.setLevel(logging.DEBUG)
Copy link
Contributor Author

@danilopeixoto danilopeixoto Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default handler goes down to debug level, however, the root is defining the effective level from user selection (VLLM_VERBOSITY) or default.

_root_logger.addHandler(_default_handler)
fmt = NewLineFormatter(_FORMAT, datefmt=_DATE_FORMAT)
fmt = _NewLineFormatter(_FORMAT, datefmt=_DATE_FORMAT)
_default_handler.setFormatter(fmt)
# Setting this will avoid the message
# being propagated to the parent logger.
Expand Down