[Core] Release NCCL communicator memory in sleep mode (#51485)
Signed-off-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: aoshen02 <aoshen02@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
aoshen02
Claude Fable 5
parent
ec32f669bb
commit
4ac452ad98
@@ -329,6 +329,10 @@ class NCCLLibrary:
|
||||
# shutdown when peer ranks may already be gone.
|
||||
# ncclResult_t ncclCommAbort(ncclComm_t comm);
|
||||
Function("ncclCommAbort", ncclResult_t, [ncclComm_t]),
|
||||
# ncclResult_t ncclCommSuspend(ncclComm_t comm, int flags);
|
||||
Function("ncclCommSuspend", ncclResult_t, [ncclComm_t, ctypes.c_int]),
|
||||
# ncclResult_t ncclCommResume(ncclComm_t comm);
|
||||
Function("ncclCommResume", ncclResult_t, [ncclComm_t]),
|
||||
# ncclResult_t ncclGroupStart();
|
||||
Function("ncclGroupStart", ncclResult_t, []),
|
||||
# ncclResult_t ncclGroupEnd();
|
||||
@@ -417,10 +421,21 @@ class NCCLLibrary:
|
||||
elif func.name == "ncclCommQueryProperties":
|
||||
# Optional on NCCL versions older than 2.29.
|
||||
continue
|
||||
elif func.name in ("ncclCommSuspend", "ncclCommResume"):
|
||||
# RCCL doesn't export these; NCCL >= 2.29.7 does, and
|
||||
# vLLM's CUDA path already requires that version.
|
||||
# PyNcclCommunicator checks has_symbol() before
|
||||
# calling either.
|
||||
if current_platform.is_rocm():
|
||||
continue
|
||||
raise
|
||||
NCCLLibrary.path_to_dict_mapping[so_file] = _funcs
|
||||
self._funcs = NCCLLibrary.path_to_dict_mapping[so_file]
|
||||
|
||||
def has_symbol(self, name: str) -> bool:
|
||||
"""Whether the loaded NCCL/RCCL library exports the given symbol."""
|
||||
return name in self._funcs
|
||||
|
||||
def ncclGetErrorString(self, result: ncclResult_t) -> str:
|
||||
return self._funcs["ncclGetErrorString"](result).decode("utf-8")
|
||||
|
||||
@@ -599,6 +614,12 @@ class NCCLLibrary:
|
||||
def ncclCommAbort(self, comm: ncclComm_t) -> None:
|
||||
self.NCCL_CHECK(self._funcs["ncclCommAbort"](comm))
|
||||
|
||||
def ncclCommSuspend(self, comm: ncclComm_t, flags: int) -> None:
|
||||
self.NCCL_CHECK(self._funcs["ncclCommSuspend"](comm, flags))
|
||||
|
||||
def ncclCommResume(self, comm: ncclComm_t) -> None:
|
||||
self.NCCL_CHECK(self._funcs["ncclCommResume"](comm))
|
||||
|
||||
def ncclGroupStart(self) -> None:
|
||||
self.NCCL_CHECK(self._funcs["ncclGroupStart"]())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user