Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(NVFUSER_CUTLASS "${NVFUSER_ROOT}/cutlass")
set(NVFUSER_THIRD_PARTY_DIR "${NVFUSER_ROOT}/third_party")

option(NVFUSER_STANDALONE_BUILD_WITH_UCC "" OFF)
option(NVFUSER_STANDALONE_BUILD_WITH_NIXL "" OFF)
option(NVFUSER_EXPLICIT_ERROR_CHECK "" OFF)
option(NVFUSER_ENABLE_DEPENDENCY_REPORT "Enable Python-based dependency reporting and log capture" ON)

Expand Down Expand Up @@ -248,6 +249,7 @@ list(APPEND NVFUSER_SRCS
${NVFUSER_SRCS_DIR}/multidevice/ipc_utils.cpp
${NVFUSER_SRCS_DIR}/multidevice/device_mesh.cpp
${NVFUSER_SRCS_DIR}/multidevice/executor.cpp
${NVFUSER_SRCS_DIR}/multidevice/nixl.cpp
${NVFUSER_SRCS_DIR}/multidevice/execution_utils.cpp
${NVFUSER_SRCS_DIR}/multidevice/propagation.cpp
${NVFUSER_SRCS_DIR}/multidevice/resharding.cpp
Expand Down Expand Up @@ -583,6 +585,37 @@ if(NVFUSER_STANDALONE_BUILD_WITH_UCC)
target_compile_definitions(codegen_internal PRIVATE NVFUSER_BUILD_WITH_UCC)
endif()

if(NVFUSER_STANDALONE_BUILD_WITH_NIXL)
# User may need to set NIXL_PREFIX to the NIXL install directory.
find_path(NIXL_INCLUDE_DIR nixl.h
HINTS $ENV{NIXL_PREFIX}/include ENV CPATH
)
find_library(NIXL_LIBRARY nixl
HINTS $ENV{NIXL_PREFIX}/lib $ENV{NIXL_PREFIX}/lib64 $ENV{NIXL_PREFIX}/lib/x86_64-linux-gnu
)
find_library(NIXL_BUILD_LIBRARY nixl_build
HINTS $ENV{NIXL_PREFIX}/lib $ENV{NIXL_PREFIX}/lib64 $ENV{NIXL_PREFIX}/lib/x86_64-linux-gnu
)

if(NOT NIXL_INCLUDE_DIR OR NOT NIXL_LIBRARY)
message(FATAL_ERROR "NIXL not found. Set NIXL_PREFIX to the NIXL install directory.")
endif()

message(STATUS "Found NIXL: ${NIXL_LIBRARY} (include: ${NIXL_INCLUDE_DIR})")
if(NIXL_BUILD_LIBRARY)
message(STATUS "Found NIXL build lib: ${NIXL_BUILD_LIBRARY}")
endif()

add_library(__nvfuser_nixl INTERFACE)
target_include_directories(__nvfuser_nixl INTERFACE ${NIXL_INCLUDE_DIR})
target_link_libraries(__nvfuser_nixl INTERFACE ${NIXL_LIBRARY})
if(NIXL_BUILD_LIBRARY)
target_link_libraries(__nvfuser_nixl INTERFACE ${NIXL_BUILD_LIBRARY})
endif()
target_link_libraries(codegen_internal PRIVATE __nvfuser_nixl)
target_compile_definitions(codegen_internal PRIVATE USE_NIXL)
endif()

add_dependencies(codegen_internal flatc build_flatbuffer_config)

# installing nvfuser headers
Expand Down Expand Up @@ -1031,6 +1064,7 @@ if(BUILD_TEST)
${NVFUSER_ROOT}/tests/cpp/test_multidevice_lower_communication.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_lower_communication_cuda.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_matmul.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_nixl.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_pipeline.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_sharding.cpp
${NVFUSER_ROOT}/tests/cpp/test_multidevice_stream_parallel_type.cpp
Expand Down Expand Up @@ -1332,6 +1366,11 @@ if(NVFUSER_STANDALONE_BUILD_WITH_UCC)
message(STATUS " UCX_DIR : $ENV{UCX_DIR}")
endif()
message(STATUS " NVFUSER_STANDALONE_BUILD_WITH_UCC : ${NVFUSER_STANDALONE_BUILD_WITH_UCC}")
message(STATUS " NVFUSER_STANDALONE_BUILD_WITH_NIXL : ${NVFUSER_STANDALONE_BUILD_WITH_NIXL}")
if(NVFUSER_STANDALONE_BUILD_WITH_NIXL)
message(STATUS " NIXL_INCLUDE_DIR: ${NIXL_INCLUDE_DIR}")
message(STATUS " NIXL_LIBRARY : ${NIXL_LIBRARY}")
endif()
message(STATUS " NVFUSER_BUILD_WITH_ASAN : ${NVFUSER_BUILD_WITH_ASAN}")
message(STATUS " NVFUSER_DISTRIBUTED : ${NVFUSER_DISTRIBUTED}")
message(STATUS " NVFUSER_CPP_STANDARD : ${NVFUSER_CPP_STANDARD}")
Expand Down
10 changes: 9 additions & 1 deletion csrc/multidevice/communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ std::ostream& operator<<(std::ostream& out, const CommunicatorBackend& cb) {
case CommunicatorBackend::kCuda:
out << "CUDA";
break;
case CommunicatorBackend::kNixl:
out << "NIXL";
break;
}
return out;
}
Expand Down Expand Up @@ -183,7 +186,8 @@ Communicator::Communicator(
master_port_(
c10d::TCPStoreOptions::kDefaultPort + 42), // to avoid collision
ucc_available_(false),
nccl_available_(false) {
nccl_available_(false),
nixl_available_(false) {
if (isOptionDisabled(DisableOption::Multidevice)) {
TORCH_WARN(
"Multi-device support is disabled. All communication operations will "
Expand Down Expand Up @@ -236,6 +240,10 @@ Communicator::Communicator(
#ifdef USE_C10D_NCCL
nccl_available_ = true;
#endif

#ifdef USE_NIXL
nixl_available_ = true;
#endif
}

namespace {
Expand Down
8 changes: 7 additions & 1 deletion csrc/multidevice/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <ATen/core/ivalue.h>
#include <c10/util/intrusive_ptr.h>

#include <cstring>

#ifdef NVFUSER_DISTRIBUTED
#include <torch/csrc/distributed/c10d/Backend.hpp>
#include <torch/csrc/distributed/c10d/TCPStore.hpp>
Expand Down Expand Up @@ -116,13 +118,15 @@ class NVF_API Communicator {
return ucc_available_;
} else if (backend == CommunicatorBackend::kNccl) {
return nccl_available_;
} else if (backend == CommunicatorBackend::kNixl) {
return nixl_available_;
}
return false;
}

c10d::TCPStore* getTcpStore() {
return store_.get();
}
}
Comment on lines 127 to +129
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indentation on closing brace

The closing brace of getTcpStore() at line 129 has lost its 2-space class-body indentation, which is inconsistent with every other method in this class.

Suggested change
c10d::TCPStore* getTcpStore() {
return store_.get();
}
}
c10d::TCPStore* getTcpStore() {
return store_.get();
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


private:
Communicator(
Expand All @@ -149,10 +153,12 @@ class NVF_API Communicator {
int master_port_;
bool ucc_available_;
bool nccl_available_;
bool nixl_available_;
// stores the world's store used for the backend init
c10::intrusive_ptr<c10d::TCPStore> store_;
// cache for the created backends. The keys are strings generated from Teams
std::unordered_map<std::string, c10::intrusive_ptr<c10d::Backend>> backends_;
};


} // namespace nvfuser
2 changes: 1 addition & 1 deletion csrc/multidevice/multidevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ using DeviceType = c10::Device;
using Team = std::vector<DeviceIdxType>;

// Supported backends.
enum class CommunicatorBackend { kNccl, kUcc, kCuda };
enum class CommunicatorBackend { kNccl, kUcc, kCuda, kNixl };
} // namespace nvfuser
Loading
Loading