Co-authored-by: HandH1998 <1335248067@qq.com>
This commit is contained in:
co-authored by
HandH1998
parent
33deca81b5
commit
85e1a6f3aa
+32
-25
@@ -430,16 +430,12 @@ def suppress_other_loggers():
|
||||
from vllm.logger import logger as vllm_default_logger
|
||||
|
||||
vllm_default_logger.setLevel(logging.WARN)
|
||||
logging.getLogger("vllm.config").setLevel(logging.ERROR)
|
||||
logging.getLogger("vllm.distributed.device_communicators.pynccl").setLevel(
|
||||
logging.WARN
|
||||
)
|
||||
logging.getLogger("vllm.distributed.device_communicators.shm_broadcast").setLevel(
|
||||
logging.WARN
|
||||
)
|
||||
logging.getLogger("vllm.selector").setLevel(logging.WARN)
|
||||
logging.getLogger("vllm.utils").setLevel(logging.ERROR)
|
||||
logging.getLogger("vllm.model_executor.model_loader.loader").setLevel(logging.ERROR)
|
||||
|
||||
warnings.filterwarnings(
|
||||
"ignore", category=UserWarning, message="The given NumPy array is not writable"
|
||||
@@ -492,27 +488,6 @@ def kill_process_tree(parent_pid, include_parent: bool = True, skip_pid: int = N
|
||||
pass
|
||||
|
||||
|
||||
def monkey_patch_vllm_model_config():
|
||||
from vllm.config import ModelConfig
|
||||
|
||||
if not hasattr(ModelConfig, "_resolve_task"):
|
||||
return
|
||||
|
||||
def _resolve_task(
|
||||
self,
|
||||
task_option,
|
||||
hf_config,
|
||||
):
|
||||
supported_tasks = {
|
||||
"generate": True,
|
||||
"embedding": False,
|
||||
}
|
||||
selected_task = "generate"
|
||||
return supported_tasks, selected_task
|
||||
|
||||
setattr(ModelConfig, "_resolve_task", _resolve_task)
|
||||
|
||||
|
||||
def monkey_patch_vllm_p2p_access_check(gpu_id: int):
|
||||
"""
|
||||
Monkey patch the slow p2p access check in vllm.
|
||||
@@ -1041,6 +1016,11 @@ def crash_on_warnings():
|
||||
return get_bool_env_var("SGLANG_IS_IN_CI")
|
||||
|
||||
|
||||
def print_warning_once(msg: str) -> None:
|
||||
# Set the stacklevel to 2 to print the caller's line info
|
||||
logger.warning(msg, stacklevel=2)
|
||||
|
||||
|
||||
def get_device_name(device_id: int = 0) -> str:
|
||||
if hasattr(torch, "cuda") and torch.cuda.is_available():
|
||||
return torch.cuda.get_device_name(device_id)
|
||||
@@ -1055,6 +1035,33 @@ def get_device_name(device_id: int = 0) -> str:
|
||||
return torch.hpu.get_device_name(device_id)
|
||||
|
||||
|
||||
def get_device_capability(device_id: int = 0) -> Tuple[int, int]:
|
||||
major, minor = None, None
|
||||
if hasattr(torch, "cuda") and torch.cuda.is_available():
|
||||
major, minor = torch.cuda.get_device_capability(device_id)
|
||||
|
||||
if hasattr(torch, "hip") and torch.hip.is_available():
|
||||
major, minor = torch.cuda.get_device_capability(device_id)
|
||||
|
||||
if hasattr(torch, "xpu") and torch.xpu.is_available():
|
||||
major, minor, *_ = torch.xpu.get_device_capability(device_id)["version"].split(
|
||||
"."
|
||||
)
|
||||
major, minor = int(major), int(minor)
|
||||
|
||||
# TODO(HandH1998): `get_device_capability` is not supported by `torch.hpu` for now.
|
||||
# Update this once the support is available.
|
||||
if hasattr(torch, "hpu") and torch.hpu.is_available():
|
||||
try:
|
||||
major, minor = torch.hpu.get_device_capability(device_id)
|
||||
except Exception as e:
|
||||
raise RuntimeError(
|
||||
f"An error occurred while getting device capability of hpu: {e}."
|
||||
) from e
|
||||
|
||||
return major, minor
|
||||
|
||||
|
||||
sglang_lib = Library("sglang", "FRAGMENT") # noqa
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user