@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / de6889946b
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 12, 13:30 UTC

[Misc] Suppress log outputs when constructing the default vllm config. (#29291)

Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io> Signed-off-by: wang.yuqi <noooop@126.com> Signed-off-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Cyrus Leung <cyrus.tl.leung@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

wang.yuqi committed Nov 25, 2025 at 19:00 UTC de6889946bd10045f2ee79b252e75d8f3e323956
2 files changed +18 -7
vllm/engine/arg_utils.py
+8 -6
@@ -77,7 +77,7 @@ from vllm.config.observability import DetailedTraceModules
77 from vllm.config.parallel import DistributedExecutorBackend, ExpertPlacementStrategy
78 from vllm.config.scheduler import SchedulerPolicy
79 from vllm.config.utils import get_field
80 -from vllm.logger import init_logger
80 +from vllm.logger import init_logger, suppress_logging
81 from vllm.platforms import CpuArchEnum, current_platform
82 from vllm.plugins import load_general_plugins
83 from vllm.ray.lazy_utils import is_in_ray_actor, is_ray_initialized
@@ -247,11 +247,13 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, dict[str, Any]]:
247 default = field.default
248 # Handle pydantic.Field defaults
249 if isinstance(default, FieldInfo):
250 - default = (
251 - default.default
252 - if default.default_factory is None
253 - else default.default_factory()
254 - )
250 + if default.default_factory is None:
251 + default = default.default
252 + else:
253 + # VllmConfig's Fields have default_factory set to config classes.
254 + # These could emit logs on init, which would be confusing.
255 + with suppress_logging():
256 + default = default.default_factory()
257 elif field.default_factory is not MISSING:
258 default = field.default_factory()
259
vllm/logger.py
+10 -1
@@ -7,7 +7,8 @@ import json
7 import logging
8 import os
9 import sys
10 -from collections.abc import Hashable
10 +from collections.abc import Generator, Hashable
11 +from contextlib import contextmanager
12 from functools import lru_cache, partial
13 from logging import Logger
14 from logging.config import dictConfig
@@ -212,6 +213,14 @@ def init_logger(name: str) -> _VllmLogger:
213 return cast(_VllmLogger, logger)
214
215
216 +@contextmanager
217 +def suppress_logging(level: int = logging.INFO) -> Generator[None, Any, None]:
218 + current_level = logging.root.manager.disable
219 + logging.disable(level)
220 + yield
221 + logging.disable(current_level)
222 +
223 +
224 # The root logger is initialized when the module is imported.
225 # This is thread-safe as the module is only imported once,
226 # guaranteed by the Python GIL.