diff --git a/vllm/distributed/device_communicators/flashinfer_all_reduce.py b/vllm/distributed/device_communicators/flashinfer_all_reduce.py index dd46f782b8..904bf2dae0 100644 --- a/vllm/distributed/device_communicators/flashinfer_all_reduce.py +++ b/vllm/distributed/device_communicators/flashinfer_all_reduce.py @@ -218,7 +218,7 @@ def get_fi_ar_workspace( f"with backend={backend}" ) else: - logger.warning_once( + logger.error_once( "Failed to initialize FlashInfer Allreduce norm fusion workspace " f"with backend={backend}" ) @@ -292,7 +292,7 @@ def get_fi_ar_quant_workspace( f"fusion workspace with backend={backend}" ) else: - logger.warning_once( + logger.error_once( "Failed to initialize FlashInfer Allreduce norm quantization " f"fusion workspace with backend={backend}" ) diff --git a/vllm/logger.py b/vllm/logger.py index fde95662f1..2d053f608b 100644 --- a/vllm/logger.py +++ b/vllm/logger.py @@ -90,6 +90,12 @@ def _print_warning_once(logger: Logger, msg: str, *args: Hashable) -> None: logger.warning(msg, *args, stacklevel=3) +@lru_cache +def _print_error_once(logger: Logger, msg: str, *args: Hashable) -> None: + # Set the stacklevel to 3 to print the original caller's line info + logger.error(msg, *args, stacklevel=3) + + LogScope = Literal["process", "global", "local"] @@ -144,12 +150,22 @@ class _VllmLogger(Logger): return _print_warning_once(self, msg, *args) + def error_once(self, msg: str, *args: Hashable, scope: LogScope = "local") -> None: + """ + As [`error`][logging.Logger.error], but subsequent calls with + the same message are silently dropped. + """ + if not _should_log_with_scope(scope): + return + _print_error_once(self, msg, *args) + # Pre-defined methods mapping to avoid repeated dictionary creation _METHODS_TO_PATCH = { "debug_once": _VllmLogger.debug_once, "info_once": _VllmLogger.info_once, "warning_once": _VllmLogger.warning_once, + "error_once": _VllmLogger.error_once, }