Skip to content
Merged
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ if(${USE_TCP_OPENSSL_LINK} AND ${USE_TCP_OPENSSL_LOAD})
endif()
option(USE_CUDA "Build with CUDA support" OFF)
option(GLOO_USE_CUDA_TOOLKIT "Build CUDA with FindCUDATookit.cmake and enable_language(CUDA)" OFF)
option(GLOO_USE_TORCH_DTYPES "Build CUDA kernels with pytorch dtypes" 0)

if(MSVC)
message(STATUS "MSVC detected")
Expand Down
10 changes: 10 additions & 0 deletions gloo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,19 @@ target_link_libraries(gloo PRIVATE ${gloo_DEPENDENCY_LIBS})
target_include_directories(gloo INTERFACE $<INSTALL_INTERFACE:include>)
if(USE_CUDA)
target_include_directories(gloo_cuda INTERFACE $<INSTALL_INTERFACE:include>)

message(STATUS "GLOO_USE_TORCH_DTYPES : ${GLOO_USE_TORCH_DTYPES} ${GLOO_TORCH_DIR}")
if(GLOO_USE_TORCH_DTYPES)
target_include_directories(gloo_cuda PRIVATE ${GLOO_TORCH_DIR})
endif()
endif()
if(USE_ROCM)
target_include_directories(gloo_hip INTERFACE $<INSTALL_INTERFACE:include>)

message(STATUS "GLOO_USE_TORCH_DTYPES : ${GLOO_USE_TORCH_DTYPES} ${GLOO_TORCH_DIR}")
if(GLOO_USE_TORCH_DTYPES)
target_include_directories(gloo_hip PRIVATE ${GLOO_TORCH_DIR})
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting... Gloo also supports RCOM?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup -- it's a bit of a mess but yes. It uses HIP the same way pytorch does

endif()
endif()

# Install if necessary.
Expand Down
2 changes: 2 additions & 0 deletions gloo/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ static_assert(
#cmakedefine01 GLOO_HAVE_TRANSPORT_TCP_TLS
#cmakedefine01 GLOO_HAVE_TRANSPORT_IBVERBS
#cmakedefine01 GLOO_HAVE_TRANSPORT_UV

#cmakedefine01 GLOO_USE_TORCH_DTYPES
9 changes: 9 additions & 0 deletions gloo/cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,13 @@ DELEGATE_SIMPLE_CUDA_BINARY_COMPARE(double, cudaMax, >);
DELEGATE_HALF_PRECISION_CUDA_BINARY_COMPARE(cudaMin, <);
DELEGATE_HALF_PRECISION_CUDA_BINARY_COMPARE(cudaMax, >);

#if GLOO_USE_TORCH_DTYPES
using BFloat16 = c10::BFloat16;
INSTANTIATE_COPY_ASYNC(BFloat16);
DELEGATE_SIMPLE_CUDA_BINARY_OPERATOR(BFloat16, cudaSum, +);
DELEGATE_SIMPLE_CUDA_BINARY_OPERATOR(BFloat16, cudaProduct, *);
DELEGATE_SIMPLE_CUDA_BINARY_COMPARE(BFloat16, cudaMin, <);
DELEGATE_SIMPLE_CUDA_BINARY_COMPARE(BFloat16, cudaMax, >);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_allreduce_bcube.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_allreduce_halving_doubling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_allreduce_local.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_allreduce_ring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_allreduce_ring_chunked.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_broadcast_one_to_all.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ INSTANTIATE_TEMPLATE(float);
INSTANTIATE_TEMPLATE(double);
INSTANTIATE_TEMPLATE(float16);

#if GLOO_USE_TORCH_DTYPES
INSTANTIATE_TEMPLATE(c10::BFloat16);
#endif

} // namespace gloo
4 changes: 4 additions & 0 deletions gloo/cuda_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "gloo/cuda.h"
#include "gloo/transport/device.h"

#if GLOO_USE_TORCH_DTYPES
#include <c10/util/BFloat16.h>
#endif

namespace gloo {

#define CUDA_CHECK(condition) \
Expand Down
Loading