[Core][Optimization] remove vllm-nccl (#5091)
This commit is contained in:
+8
-35
@@ -2,7 +2,6 @@ import asyncio
|
||||
import datetime
|
||||
import enum
|
||||
import gc
|
||||
import glob
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
@@ -565,28 +564,6 @@ def init_cached_hf_modules():
|
||||
init_hf_modules()
|
||||
|
||||
|
||||
def nccl_integrity_check(filepath):
|
||||
"""
|
||||
when the library is corrupted, we cannot catch
|
||||
the exception in python. it will crash the process.
|
||||
instead, we use the exit code of `ldd` to check
|
||||
if the library is corrupted. if not, we will return
|
||||
the version of the library.
|
||||
"""
|
||||
exit_code = os.system(f"ldd {filepath} 2>&1 > /dev/null")
|
||||
if exit_code != 0:
|
||||
raise RuntimeError(f"Failed to load NCCL library from {filepath} .")
|
||||
import ctypes
|
||||
|
||||
nccl = ctypes.CDLL(filepath)
|
||||
version = ctypes.c_int()
|
||||
nccl.ncclGetVersion.restype = ctypes.c_int
|
||||
nccl.ncclGetVersion.argtypes = [ctypes.POINTER(ctypes.c_int)]
|
||||
result = nccl.ncclGetVersion(ctypes.byref(version))
|
||||
assert result == 0
|
||||
return version.value
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def find_library(lib_name: str) -> str:
|
||||
"""
|
||||
@@ -616,17 +593,13 @@ def find_library(lib_name: str) -> str:
|
||||
|
||||
|
||||
def find_nccl_library():
|
||||
"""
|
||||
We either use the library file specified by the `VLLM_NCCL_SO_PATH`
|
||||
environment variable, or we find the library file brought by PyTorch.
|
||||
After importing `torch`, `libnccl.so.2` or `librccl.so.1` can be
|
||||
found by `ctypes` automatically.
|
||||
"""
|
||||
so_file = envs.VLLM_NCCL_SO_PATH
|
||||
VLLM_CONFIG_ROOT = envs.VLLM_CONFIG_ROOT
|
||||
|
||||
# check if we have vllm-managed nccl
|
||||
vllm_nccl_path = None
|
||||
if torch.version.cuda is not None:
|
||||
cuda_major = torch.version.cuda.split(".")[0]
|
||||
path = os.path.expanduser(
|
||||
f"{VLLM_CONFIG_ROOT}/vllm/nccl/cu{cuda_major}/libnccl.so.*")
|
||||
files = glob.glob(path)
|
||||
vllm_nccl_path = files[0] if files else None
|
||||
|
||||
# manually load the nccl library
|
||||
if so_file:
|
||||
@@ -635,9 +608,9 @@ def find_nccl_library():
|
||||
so_file)
|
||||
else:
|
||||
if torch.version.cuda is not None:
|
||||
so_file = vllm_nccl_path or find_library("libnccl.so.2")
|
||||
so_file = "libnccl.so.2"
|
||||
elif torch.version.hip is not None:
|
||||
so_file = find_library("librccl.so.1")
|
||||
so_file = "librccl.so.1"
|
||||
else:
|
||||
raise ValueError("NCCL only supports CUDA and ROCm backends.")
|
||||
logger.info("Found nccl from library %s", so_file)
|
||||
|
||||
Reference in New Issue
Block a user