Repository navigation
Add an NCCL/RCCL based device conduit #8234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
366b376
237714c
c58ee85
9f48f31
8695b62
f4e82ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright (c) 2026 Hartmut Kaiser | ||
| # | ||
| # SPDX-License-Identifier: BSL-1.0 | ||
| # Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
|
||
| # Find NVIDIA's NCCL library. Hints: NCCL_ROOT, NCCL_DIR, the environment | ||
| # variables NCCL_ROOT and NCCL_HOME, and the CUDA toolkit directory. Sets | ||
| # NCCL_FOUND, NCCL_VERSION (from nccl.h), NCCL_INCLUDE_DIR, NCCL_LIBRARY and | ||
| # defines the imported target NCCL::nccl. | ||
|
|
||
| if(NOT TARGET NCCL::nccl) | ||
|
|
||
| find_path( | ||
| NCCL_INCLUDE_DIR nccl.h | ||
| HINTS ${NCCL_ROOT} | ||
| ${NCCL_DIR} | ||
| ENV | ||
| NCCL_ROOT | ||
| ENV | ||
| NCCL_HOME | ||
| ${CUDAToolkit_INCLUDE_DIRS} | ||
| PATH_SUFFIXES include | ||
| ) | ||
|
|
||
| find_library( | ||
| NCCL_LIBRARY | ||
| NAMES nccl | ||
| HINTS ${NCCL_ROOT} | ||
| ${NCCL_DIR} | ||
| ENV | ||
| NCCL_ROOT | ||
| ENV | ||
| NCCL_HOME | ||
| ${CUDAToolkit_LIBRARY_DIR} | ||
| PATH_SUFFIXES lib lib64 | ||
| ) | ||
|
|
||
| if(NCCL_INCLUDE_DIR AND EXISTS "${NCCL_INCLUDE_DIR}/nccl.h") | ||
| file(STRINGS "${NCCL_INCLUDE_DIR}/nccl.h" _nccl_version_lines | ||
| REGEX "#define NCCL_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+" | ||
| ) | ||
| foreach(_part MAJOR MINOR PATCH) | ||
| string(REGEX MATCH "NCCL_${_part}[ \t]+([0-9]+)" _match | ||
| "${_nccl_version_lines}" | ||
| ) | ||
| set(NCCL_VERSION_${_part} "${CMAKE_MATCH_1}") | ||
| endforeach() | ||
| set(NCCL_VERSION | ||
| "${NCCL_VERSION_MAJOR}.${NCCL_VERSION_MINOR}.${NCCL_VERSION_PATCH}" | ||
| ) | ||
| unset(_nccl_version_lines) | ||
| unset(_match) | ||
| endif() | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args( | ||
| NCCL | ||
| REQUIRED_VARS NCCL_LIBRARY NCCL_INCLUDE_DIR | ||
| VERSION_VAR NCCL_VERSION | ||
| ) | ||
|
|
||
| if(NCCL_FOUND) | ||
| add_library(NCCL::nccl INTERFACE IMPORTED GLOBAL) | ||
| target_include_directories(NCCL::nccl SYSTEM INTERFACE ${NCCL_INCLUDE_DIR}) | ||
| target_link_libraries(NCCL::nccl INTERFACE ${NCCL_LIBRARY}) | ||
| endif() | ||
|
|
||
| mark_as_advanced(NCCL_INCLUDE_DIR NCCL_LIBRARY) | ||
|
|
||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) 2026 Hartmut Kaiser | ||
| # | ||
| # SPDX-License-Identifier: BSL-1.0 | ||
| # Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
|
||
| include(HPX_Message) | ||
|
|
||
| # Finds the library of the NCCL device conduit: NCCL with CUDA, RCCL (the same | ||
| # API) with HIP, and defines HPX::nccl for it. Non-blocking communicators and | ||
| # ncclGetLastError need NCCL 2.14 or newer (RCCL of ROCm 5.4 or newer). | ||
| macro(hpx_setup_nccl) | ||
| if(NOT TARGET HPX::nccl) | ||
| if(HPX_WITH_HIP) | ||
| # RCCL_ROOT (the module of the CI stack sets it) or the ROCm directory | ||
| find_package( | ||
| rccl | ||
| REQUIRED | ||
| CONFIG | ||
| HINTS | ||
| ${RCCL_ROOT} | ||
| $ENV{RCCL_ROOT} | ||
| ${ROCM_PATH} | ||
| $ENV{ROCM_PATH} | ||
| /opt/rocm | ||
| ) | ||
| add_library(HPX::nccl INTERFACE IMPORTED GLOBAL) | ||
| target_link_libraries(HPX::nccl INTERFACE roc::rccl) | ||
| hpx_info(" RCCL ${rccl_VERSION} for the device conduit") | ||
| elseif(HPX_WITH_CUDA) | ||
| find_package(CUDAToolkit REQUIRED) | ||
| find_package(NCCL 2.14 REQUIRED) | ||
| add_library(HPX::nccl INTERFACE IMPORTED GLOBAL) | ||
| target_link_libraries(HPX::nccl INTERFACE NCCL::nccl CUDA::cudart) | ||
| hpx_info( | ||
| " NCCL ${NCCL_VERSION} for the device conduit: ${NCCL_LIBRARY}" | ||
| ) | ||
| else() | ||
| hpx_error( | ||
| "The NCCL device conduit requires CUDA or HIP (HPX_WITH_CUDA=ON or HPX_WITH_HIP=ON)" | ||
| ) | ||
| endif() | ||
| endif() | ||
| endmacro() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,14 @@ if(HPX_WITH_NETWORKING AND HPX_WITH_DEVICE_CONDUIT_UCX) | |
| hpx_setup_ucx() | ||
| endif() | ||
|
|
||
| # NCCL or RCCL (device conduit) | ||
| if(HPX_WITH_NETWORKING AND HPX_WITH_DEVICE_CONDUIT_NCCL) | ||
| set(NCCL_ROOT "@NCCL_ROOT@") | ||
| set(RCCL_ROOT "@RCCL_ROOT@") | ||
|
Comment on lines
+85
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve dependency roots supplied by the consumer. If HPX was built against If the recorded installation is unavailable and no other discovery hint exists,
|
||
| include(HPX_SetupNCCL) | ||
| hpx_setup_nccl() | ||
| endif() | ||
|
|
||
| # LCW | ||
| if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCW) | ||
| if(HPX_WITH_FETCH_LCW) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| #include <hpx/serialization/detail/polymorphic_id_factory.hpp> | ||
| #include <hpx/serialization/detail/polymorphic_intrusive_factory.hpp> | ||
| #include <hpx/serialization/detail/polymorphic_nonintrusive_factory.hpp> | ||
| #include <hpx/serialization/detail/post_receive_actions.hpp> | ||
| #include <hpx/serialization/detail/preprocess_keep_alive.hpp> | ||
| #include <hpx/serialization/macros.hpp> | ||
| #include <hpx/serialization/serialization_fwd.hpp> | ||
|
|
@@ -408,6 +409,29 @@ namespace hpx::serialization { | |
| } | ||
| } | ||
|
|
||
| // The steps a received parcel waits for depend on whether it uses | ||
| // objects that earlier parcels of the message have loaded (see | ||
| // post_receive_actions::take_parcel_steps). | ||
| template <typename Archive> | ||
| void note_object_loaded(Archive& ar, std::uint64_t const pos) | ||
| { | ||
| if (auto* actions = | ||
| ar.template try_get_extra_data<post_receive_actions>()) | ||
|
Comment on lines
+418
to
+419
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Record tracked objects loaded before a parcel's first deferred step.
Record each tracked object loaded by a parcel, whether or not a step has been registered yet. Keep the existing rule that a parcel waits for earlier steps only when it uses an object those parcels loaded. The fix must not make a parcel wait for unrelated transfers. Add a test that loads a tracked child before the first deferred step, then back-references that child from the next parcel. The current tests create the tracking object before they call
|
||
| { | ||
| actions->object_loaded(pos); | ||
| } | ||
| } | ||
|
|
||
| template <typename Archive> | ||
| void note_back_reference(Archive& ar, std::uint64_t const pos) | ||
| { | ||
| if (auto* actions = | ||
| ar.template try_get_extra_data<post_receive_actions>()) | ||
| { | ||
| actions->back_reference(pos); | ||
| } | ||
| } | ||
|
|
||
| // forwarded serialize pointer functions | ||
| template <typename Pointer> | ||
| HPX_FORCEINLINE void serialize_pointer_tracked( | ||
|
|
@@ -453,13 +477,15 @@ namespace hpx::serialization { | |
| Pointer temp = | ||
| detail::pointer_input_dispatcher<Pointer>::type::call( | ||
| ar); | ||
| note_object_loaded(ar, pos); | ||
| register_pointer(ar, pos, | ||
| ptr_helper_ptr( //-V824 | ||
| new detail::erase_ptr_helper<Pointer>( | ||
| HPX_MOVE(temp), ptr))); | ||
| } | ||
| else | ||
| { | ||
| note_back_reference(ar, pos); | ||
| auto& tracked = tracked_pointer(ar, pos); | ||
| if (tracked.type() != typeid(Pointer)) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject RCCL versions without non-blocking communicator support.
With ROCm 5.4, this unversioned lookup accepts RCCL. Its header lacks
ncclConfig_t,NCCL_CONFIG_INITIALIZER,ncclCommInitRankConfig, andncclInProgress. The conduit uses these APIs, so compilation fails despite the stated ROCm 5.4 compatibility. (raw.githubusercontent.com)Require a compatible RCCL version or check these features during configuration. Update the minimum-version comment to match. Keep compatible RCCL installations accepted.