Optimize the print info format when deprecated code is used in vllm-ascend (#5696)
### What this PR does / why we need it?
Optimize the warning print information format when detects depredated
code is used in vllm-ascend.
### Does this PR introduce _any_ user-facing change?
NA
- vLLM version: v0.13.0
- vLLM main:
2f4e6548ef
---------
Signed-off-by: leo-pony <nengjunma@outlook.com>
This commit is contained in:
@@ -47,6 +47,36 @@ else:
|
|||||||
_CUSTOM_OP_REGISTERED = False
|
_CUSTOM_OP_REGISTERED = False
|
||||||
|
|
||||||
|
|
||||||
|
def config_deprecated_logging():
|
||||||
|
"""Configure deprecated logging format, when used deprecated codes
|
||||||
|
in vllm-ascend.
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
# Customize warning format to be one line
|
||||||
|
def one_line_formatwarning(message, category, filename, lineno, line=None):
|
||||||
|
return f"{filename}:{lineno}: {category.__name__}: {message}"
|
||||||
|
|
||||||
|
warnings.formatwarning = one_line_formatwarning
|
||||||
|
|
||||||
|
logging.captureWarnings(True)
|
||||||
|
warnings.simplefilter("once", DeprecationWarning)
|
||||||
|
|
||||||
|
vllm_logger = logging.getLogger("vllm")
|
||||||
|
warnings_logger = logging.getLogger("py.warnings")
|
||||||
|
|
||||||
|
# Propagate vllm logger handlers to warnings logger, to keep the same
|
||||||
|
# format with vllm
|
||||||
|
if vllm_logger.handlers:
|
||||||
|
warnings_logger.handlers = []
|
||||||
|
|
||||||
|
for handler in vllm_logger.handlers:
|
||||||
|
warnings_logger.addHandler(handler)
|
||||||
|
|
||||||
|
warnings_logger.propagate = False
|
||||||
|
|
||||||
|
|
||||||
class NPUPlatform(Platform):
|
class NPUPlatform(Platform):
|
||||||
|
|
||||||
_enum = PlatformEnum.OOT
|
_enum = PlatformEnum.OOT
|
||||||
@@ -112,6 +142,8 @@ class NPUPlatform(Platform):
|
|||||||
from vllm_ascend.quantization.quant_config import \
|
from vllm_ascend.quantization.quant_config import \
|
||||||
AscendQuantConfig # noqa: F401
|
AscendQuantConfig # noqa: F401
|
||||||
|
|
||||||
|
config_deprecated_logging()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_device_capability(cls, device_id: int = 0):
|
def get_device_capability(cls, device_id: int = 0):
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user