Sync from v0.13
This commit is contained in:
92
tools/ep_kernels/elastic_ep/eep_nvshmem.patch
Normal file
92
tools/ep_kernels/elastic_ep/eep_nvshmem.patch
Normal file
@@ -0,0 +1,92 @@
|
||||
From 18c0599c2f07ec965132efa25961dc8179c2dda3 Mon Sep 17 00:00:00 2001
|
||||
From: Yongji Wu <wuyongji317@gmail.com>
|
||||
Date: Tue, 20 May 2025 13:41:12 -0700
|
||||
Subject: [PATCH] fix reinit issues due to states not cleaned up
|
||||
|
||||
fix double free
|
||||
---
|
||||
src/host/init/init.cu | 10 ++++++++++
|
||||
.../internal/host/nvshmemi_mem_transport.hpp | 15 +++++++++++++++
|
||||
src/modules/bootstrap/uid/bootstrap_uid.cpp | 5 +++++
|
||||
3 files changed, 30 insertions(+)
|
||||
|
||||
diff --git a/src/host/init/init.cu b/src/host/init/init.cu
|
||||
index b1c5dbf..1fecb4b 100644
|
||||
--- a/src/host/init/init.cu
|
||||
+++ b/src/host/init/init.cu
|
||||
@@ -43,6 +43,8 @@
|
||||
#include "internal/host/nvshmemi_types.h"
|
||||
#include "internal/host/shared_memory.h"
|
||||
#include "internal/host/nvshmemi_symmetric_heap.hpp"
|
||||
+// eep-dev
|
||||
+#include "internal/host/nvshmemi_mem_transport.hpp"
|
||||
|
||||
extern __constant__ nvshmemi_device_host_state_t nvshmemi_device_state_d;
|
||||
static std::map<void *, int> registered_device_states;
|
||||
@@ -1293,6 +1295,14 @@ void nvshmemid_hostlib_finalize(void *device_ctx, void *transport_device_ctx) {
|
||||
/* Multi-init Multi-fini*/
|
||||
nvshmemi_state = NULL;
|
||||
nvshmemi_device_state.nvshmemi_is_nvshmem_initialized = 0;
|
||||
+
|
||||
+ // eep-dev
|
||||
+ nvshmemi_mem_p2p_transport::destroy_instance();
|
||||
+ nvshmemi_mem_remote_transport::destroy_instance();
|
||||
+ free(nvshmemi_default_session);
|
||||
+ nvshmemi_default_session = nullptr;
|
||||
+ nvshmemi_device_state.nvshmemi_is_nvshmem_bootstrapped = false;
|
||||
+
|
||||
nvshmemi_is_device_state_ready = false;
|
||||
} else
|
||||
nvshmemi_boot_handle.barrier(&nvshmemi_boot_handle);
|
||||
diff --git a/src/include/internal/host/nvshmemi_mem_transport.hpp b/src/include/internal/host/nvshmemi_mem_transport.hpp
|
||||
index 2495844..e4f408a 100644
|
||||
--- a/src/include/internal/host/nvshmemi_mem_transport.hpp
|
||||
+++ b/src/include/internal/host/nvshmemi_mem_transport.hpp
|
||||
@@ -36,6 +36,13 @@ class nvshmemi_mem_p2p_transport final {
|
||||
return p2p_objref_;
|
||||
}
|
||||
}
|
||||
+ // eep-dev
|
||||
+ static void destroy_instance(void) {
|
||||
+ if (p2p_objref_ != nullptr) {
|
||||
+ delete p2p_objref_;
|
||||
+ p2p_objref_ = nullptr;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
void print_mem_handle(int pe_id, int transport_idx, nvshmemi_symmetric_heap &obj);
|
||||
|
||||
@@ -87,6 +94,14 @@ class nvshmemi_mem_remote_transport final {
|
||||
}
|
||||
}
|
||||
|
||||
+ // eep-dev
|
||||
+ static void destroy_instance(void) {
|
||||
+ if (remote_objref_ != nullptr) {
|
||||
+ delete remote_objref_;
|
||||
+ remote_objref_ = nullptr;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
int gather_mem_handles(nvshmemi_symmetric_heap &obj, uint64_t heap_offset, size_t size);
|
||||
/* On-demand registration and release of memory */
|
||||
int register_mem_handle(nvshmem_mem_handle_t *local_handles, int transport_idx,
|
||||
diff --git a/src/modules/bootstrap/uid/bootstrap_uid.cpp b/src/modules/bootstrap/uid/bootstrap_uid.cpp
|
||||
index a1fa748..788fa96 100644
|
||||
--- a/src/modules/bootstrap/uid/bootstrap_uid.cpp
|
||||
+++ b/src/modules/bootstrap/uid/bootstrap_uid.cpp
|
||||
@@ -630,6 +630,11 @@ int nvshmemi_bootstrap_plugin_pre_init(bootstrap_handle_t* handle, const int abi
|
||||
// Discover the network for bootstrap, if not done previously.
|
||||
// This code needs to be stateful to be able to be called multiple times by the caller
|
||||
BOOTSTRAP_CHECK(bootstrap_net_init());
|
||||
+ // eep-dev
|
||||
+ if (handle->pre_init_ops != nullptr) {
|
||||
+ BOOTSTRAP_PTR_FREE(handle->pre_init_ops);
|
||||
+ handle->pre_init_ops = nullptr;
|
||||
+ }
|
||||
if (handle->pre_init_ops == nullptr) {
|
||||
BOOTSTRAP_CALLOC(&handle->pre_init_ops, 1);
|
||||
handle->pre_init_ops->get_unique_id = bootstrap_get_unique_id;
|
||||
--
|
||||
2.43.0
|
||||
|
||||
86
tools/ep_kernels/elastic_ep/install_eep_libraries.sh
Executable file
86
tools/ep_kernels/elastic_ep/install_eep_libraries.sh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# Default workspace directory
|
||||
WORKSPACE=$(pwd)/eep_kernels_workspace
|
||||
INSTALL_NVSHMEM=true
|
||||
|
||||
# Parse command line arguments
|
||||
while getopts "w:n" opt; do
|
||||
case $opt in
|
||||
w)
|
||||
WORKSPACE="$OPTARG"
|
||||
;;
|
||||
n)
|
||||
INSTALL_NVSHMEM=false
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -d "$WORKSPACE" ]; then
|
||||
mkdir -p $WORKSPACE
|
||||
fi
|
||||
|
||||
|
||||
# install dependencies if not installed
|
||||
pip3 install cmake torch ninja
|
||||
|
||||
# build nvshmem
|
||||
pushd $WORKSPACE
|
||||
# Reset NVSHMEM build if requested
|
||||
if [ "$INSTALL_NVSHMEM" = true ]; then
|
||||
mkdir -p nvshmem_src
|
||||
wget https://developer.download.nvidia.com/compute/redist/nvshmem/3.2.5/source/nvshmem_src_3.2.5-1.txz
|
||||
tar -xvf nvshmem_src_3.2.5-1.txz -C nvshmem_src --strip-components=1
|
||||
pushd nvshmem_src
|
||||
wget https://github.com/deepseek-ai/DeepEP/raw/main/third-party/nvshmem.patch
|
||||
git init
|
||||
git apply -vvv nvshmem.patch
|
||||
git apply --reject --whitespace=fix ../../eep_nvshmem.patch
|
||||
else
|
||||
pushd nvshmem_src
|
||||
fi
|
||||
|
||||
# assume CUDA_HOME is set correctly
|
||||
if [ -z "$CUDA_HOME" ]; then
|
||||
echo "CUDA_HOME is not set, please set it to your CUDA installation directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# disable all features except IBGDA
|
||||
export NVSHMEM_IBGDA_SUPPORT=1
|
||||
|
||||
export NVSHMEM_SHMEM_SUPPORT=0
|
||||
export NVSHMEM_UCX_SUPPORT=0
|
||||
export NVSHMEM_USE_NCCL=0
|
||||
export NVSHMEM_PMIX_SUPPORT=0
|
||||
export NVSHMEM_TIMEOUT_DEVICE_POLLING=0
|
||||
export NVSHMEM_USE_GDRCOPY=0
|
||||
export NVSHMEM_IBRC_SUPPORT=0
|
||||
export NVSHMEM_BUILD_TESTS=0
|
||||
export NVSHMEM_BUILD_EXAMPLES=0
|
||||
export NVSHMEM_MPI_SUPPORT=0
|
||||
export NVSHMEM_BUILD_HYDRA_LAUNCHER=0
|
||||
export NVSHMEM_BUILD_TXZ_PACKAGE=0
|
||||
export NVSHMEM_TIMEOUT_DEVICE_POLLING=0
|
||||
|
||||
cmake -G Ninja -S . -B $WORKSPACE/nvshmem_build/ -DCMAKE_INSTALL_PREFIX=$WORKSPACE/nvshmem_install
|
||||
cmake --build $WORKSPACE/nvshmem_build/ --target install
|
||||
|
||||
popd
|
||||
|
||||
export CMAKE_PREFIX_PATH=$WORKSPACE/nvshmem_install:$CMAKE_PREFIX_PATH
|
||||
|
||||
# build and install pplx, require pytorch installed
|
||||
pushd $WORKSPACE
|
||||
git clone https://github.com/ppl-ai/pplx-kernels
|
||||
cd pplx-kernels
|
||||
# see https://github.com/pypa/pip/issues/9955#issuecomment-838065925
|
||||
# PIP_NO_BUILD_ISOLATION=0 disables build isolation
|
||||
PIP_NO_BUILD_ISOLATION=0 TORCH_CUDA_ARCH_LIST=9.0a+PTX pip install . --no-deps -v
|
||||
|
||||
Reference in New Issue
Block a user