Skip to content

Commit

Permalink
Merge branch 'branch-25.02' into drop_thrust_null_type
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco authored Feb 4, 2025
2 parents 9e5d6da + dcc2cfd commit 55074ea
Show file tree
Hide file tree
Showing 16 changed files with 959 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"context": "${localWorkspaceFolder}/.devcontainer",
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
"args": {
"CUDA": "12.5",
"CUDA": "12.8",
"PYTHON_PACKAGE_MANAGER": "conda",
"BASE": "rapidsai/devcontainers:25.02-cpp-mambaforge-ubuntu22.04"
}
},
"runArgs": [
"--rm",
"--name",
"${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-conda"
"${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.8-conda"
],
"hostRequirements": {"gpu": "optional"},
"features": {
Expand All @@ -20,7 +20,7 @@
"overrideFeatureInstallOrder": [
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
],
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.5-envs}"],
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.8-envs}"],
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
"workspaceFolder": "/home/coder",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/cugraph,type=bind,consistency=consistent",
Expand All @@ -29,7 +29,7 @@
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.5-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent"
"source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent"
],
"customizations": {
"vscode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
"context": "${localWorkspaceFolder}/.devcontainer",
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
"args": {
"CUDA": "12.5",
"CUDA": "12.8",
"PYTHON_PACKAGE_MANAGER": "pip",
"BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.5-ucx1.18.0-openmpi-ubuntu22.04"
"BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.8-ucx1.18.0-openmpi-ubuntu22.04"
}
},
"runArgs": [
"--rm",
"--name",
"${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-pip"
"${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.8-pip"
],
"hostRequirements": {"gpu": "optional"},
"features": {
"ghcr.io/rapidsai/devcontainers/features/cuda:25.2": {
"version": "12.5",
"version": "12.8",
"installcuBLAS": true,
"installcuSOLVER": true,
"installcuRAND": true,
Expand All @@ -28,15 +28,15 @@
"ghcr.io/rapidsai/devcontainers/features/cuda",
"ghcr.io/rapidsai/devcontainers/features/rapids-build-utils"
],
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs}"],
"initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs}"],
"postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"],
"workspaceFolder": "/home/coder",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/cugraph,type=bind,consistency=consistent",
"mounts": [
"source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent",
"source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent"
"source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent"
],
"customizations": {
"vscode": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
arch: '["amd64"]'
cuda: '["12.5"]'
cuda: '["12.8"]'
node_type: cpu32
build_command: |
sccache -z;
Expand Down
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ The [cugraph-docs repository](https://github.com/rapidsai/cugraph-docs) contains

## Table of contents
- Installation
- [Getting cuGraph Packages](./docs/cugraph/source/installation/getting_cugraph.md)
- [Building from Source](./docs/cugraph/source/installation/source_build.md)
- [Contributing to cuGraph](./readme_pages/CONTRIBUTING.md)
- [Getting cuGraph Packages](https://docs.rapids.ai/api/cugraph/stable/installation/getting_cugraph/)
- [Building from Source](https://docs.rapids.ai/api/cugraph/stable/installation/source_build/)
- [Contributing to cuGraph](https://docs.rapids.ai/contributing/)
- General
- [Latest News](./readme_pages/news.md)
- [Current list of algorithms](./docs/cugraph/source/graph_support/algorithms.md)
- [Blogs and Presentation](./docs/cugraph/source/tutorials/cugraph_blogs.rst)
- [Performance](./readme_pages/performance/performance.md)
- [Latest News](https://docs.rapids.ai/api/cugraph/nightly/)
- [Current list of algorithms](https://docs.rapids.ai/api/cugraph/stable/graph_support/algorithms/)
- [Blogs and Presentation](https://docs.rapids.ai/api/cugraph/nightly/tutorials/cugraph_blogs/)
- Packages
- [cuGraph Python](./readme_pages/cugraph_python.md)
- [Property Graph](./readme_pages/property_graph.md)
Expand All @@ -69,11 +68,14 @@ The [cugraph-docs repository](https://github.com/rapidsai/cugraph-docs) contains
- [cugraph-service](./readme_pages/cugraph_service.md)
- API Docs
- Python
- [Python Nightly](https://docs.rapids.ai/api/cugraph/nightly/)
- [Python Stable](https://docs.rapids.ai/api/cugraph/stable/)
- [Python Nightly](https://docs.rapids.ai/api/cugraph/nightly/api_docs/cugraph/)
- [Python Stable](https://docs.rapids.ai/api/cugraph/stable/api_docs/cugraph/)
- C
- [C Nightly](https://docs.rapids.ai/api/cugraph/nightly/api_docs/cugraph_c/)
- [C Stable](https://docs.rapids.ai/api/cugraph/stable/api_docs/cugraph_c/)
- C++
- [C++ Nightly](https://docs.rapids.ai/api/libcugraph/nightly/)
- [C++ Stable](https://docs.rapids.ai/api/libcugraph/stable/)
- [C++ Nightly](https://docs.rapids.ai/api/cugraph/nightly/api_docs/cugraph_cpp/)
- (Will be available when 25.02 is released)[C++ Stable](https://docs.rapids.ai/api/cugraph/stable/api_docs/cugraph_cpp/)
- References
- [RAPIDS](https://rapids.ai/)
- [ARROW](https://arrow.apache.org/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
- cuda-nvtx-dev
- cuda-profiler-api
- cuda-python>=12.6.2,<13.0a0
- cuda-version=12.5
- cuda-version=12.8
- cudf==25.2.*,>=0.0.0a0
- cupy>=12.0.0
- cxx-compiler
Expand Down Expand Up @@ -77,4 +77,4 @@ dependencies:
- torchmetrics
- ucx-py==0.42.*,>=0.0.0a0
- wheel
name: all_cuda-125_arch-x86_64
name: all_cuda-128_arch-x86_64
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ add_library(cugraph_c
src/c_api/allgather.cpp
src/c_api/decompress_to_edgelist.cpp
src/c_api/edgelist.cpp
src/c_api/renumber_arbitrary_edgelist.cu
)
add_library(cugraph::cugraph_c ALIAS cugraph_c)

Expand Down
23 changes: 22 additions & 1 deletion cpp/include/cugraph_c/graph_functions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
* Copyright (c) 2022-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -463,6 +463,27 @@ cugraph_error_code_t cugraph_decompress_to_edgelist(const cugraph_resource_handl
cugraph_edgelist_t** result,
cugraph_error_t** error);

/**
* @brief Renumber arbitrary edgelist
*
* This function is designed to assist renumbering graph vertices in the case where the
* the global vertex id list exceeds the GPU memory. Renumbering is done in-place in the
* supplied @p src and @p dst parameters.
*
* @param [in] handle Handle for accessing resources
* @param [in] renumber_map Host array with the renumber map
* @param [in/out] srcs Device array of src vertices to renumber
* @param [in/out] dsts Device array of dst vertices to renumber
* @param [out] error Pointer to an error object storing details of any error. Will
* be populated if error code is not CUGRAPH_SUCCESS
*/
cugraph_error_code_t cugraph_renumber_arbitrary_edgelist(
const cugraph_resource_handle_t* handle,
const cugraph_type_erased_host_array_view_t* renumber_map,
cugraph_type_erased_device_array_view_t* srcs,
cugraph_type_erased_device_array_view_t* dsts,
cugraph_error_t** error);

#ifdef __cplusplus
}
#endif
190 changes: 190 additions & 0 deletions cpp/src/c_api/renumber_arbitrary_edgelist.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* Copyright (c) 2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "c_api/resource_handle.hpp"
#include "c_api/utils.hpp"

#include <cugraph_c/error.h>
#include <cugraph_c/graph_functions.h>

#include <cugraph/graph.hpp>
#include <cugraph/utilities/error.hpp>

#include <thrust/binary_search.h>
#include <thrust/iterator/counting_iterator.h>

namespace {

template <typename vertex_t>
cugraph_error_code_t renumber_arbitrary_edgelist(
raft::handle_t const& handle,
cugraph::c_api::cugraph_type_erased_host_array_view_t const* renumber_map,
cugraph::c_api::cugraph_type_erased_device_array_view_t* srcs,
cugraph::c_api::cugraph_type_erased_device_array_view_t* dsts)
{
rmm::device_uvector<vertex_t> vertices(2 * srcs->size_, handle.get_stream());

thrust::copy_n(
handle.get_thrust_policy(), srcs->as_type<vertex_t>(), srcs->size_, vertices.data());
thrust::copy_n(handle.get_thrust_policy(),
dsts->as_type<vertex_t>(),
dsts->size_,
vertices.data() + srcs->size_);

thrust::sort(handle.get_thrust_policy(), vertices.begin(), vertices.end());
vertices.resize(
thrust::distance(vertices.begin(),
thrust::unique(handle.get_thrust_policy(), vertices.begin(), vertices.end())),
handle.get_stream());

vertices.shrink_to_fit(handle.get_stream());
rmm::device_uvector<vertex_t> ids(vertices.size(), handle.get_stream());
thrust::fill(handle.get_thrust_policy(),
ids.begin(),
ids.end(),
cugraph::invalid_vertex_id<vertex_t>::value);

raft::device_span<vertex_t const> vertices_span{vertices.data(), vertices.size()};
raft::device_span<vertex_t> ids_span{ids.data(), ids.size()};

// Read chunk of renumber_map in a loop, updating base offset to compute vertex id
// FIXME: Compute this as a function of free memory? Or some value that keeps a
// particular GPU saturated?
size_t chunk_size = size_t{1} << 20;

rmm::device_uvector<vertex_t> renumber_chunk(chunk_size, handle.get_stream());

for (size_t chunk_base_offset = 0; chunk_base_offset < renumber_map->size_;
chunk_base_offset += chunk_size) {
size_t size = std::min(chunk_size, renumber_map->size_ - chunk_base_offset);
if (size < chunk_size) renumber_chunk.resize(size, handle.get_stream());

raft::update_device(renumber_chunk.data(),
renumber_map->as_type<vertex_t>() + chunk_base_offset,
size,
handle.get_stream());

thrust::for_each(
handle.get_thrust_policy(),
thrust::make_counting_iterator<size_t>(0),
thrust::make_counting_iterator<size_t>(renumber_chunk.size()),
[chunk_base_offset,
renumber_chunk_span =
raft::device_span<vertex_t const>{renumber_chunk.data(), renumber_chunk.size()},
vertices_span,
ids_span] __device__(size_t idx) {
auto pos = thrust::lower_bound(
thrust::seq, vertices_span.begin(), vertices_span.end(), renumber_chunk_span[idx]);
if ((pos != vertices_span.end()) && (*pos == renumber_chunk_span[idx])) {
ids_span[thrust::distance(vertices_span.begin(), pos)] =
static_cast<vertex_t>(chunk_base_offset + idx);
}
});
}

CUGRAPH_EXPECTS(thrust::count(handle.get_thrust_policy(),
ids.begin(),
ids.end(),
cugraph::invalid_vertex_id<vertex_t>::value) == 0,
"some vertices were not renumbered");

thrust::transform(
handle.get_thrust_policy(),
srcs->as_type<vertex_t>(),
srcs->as_type<vertex_t>() + srcs->size_,
srcs->as_type<vertex_t>(),
[vertices_span, ids_span] __device__(vertex_t v) {
return ids_span[thrust::distance(
vertices_span.begin(),
thrust::lower_bound(thrust::seq, vertices_span.begin(), vertices_span.end(), v))];
});

thrust::transform(
handle.get_thrust_policy(),
dsts->as_type<vertex_t>(),
dsts->as_type<vertex_t>() + srcs->size_,
dsts->as_type<vertex_t>(),
[vertices_span, ids_span] __device__(vertex_t v) {
return ids_span[thrust::distance(
vertices_span.begin(),
thrust::lower_bound(thrust::seq, vertices_span.begin(), vertices_span.end(), v))];
});

return CUGRAPH_SUCCESS;
}

} // namespace

extern "C" cugraph_error_code_t cugraph_renumber_arbitrary_edgelist(
const cugraph_resource_handle_t* handle,
const cugraph_type_erased_host_array_view_t* renumber_map,
cugraph_type_erased_device_array_view_t* srcs,
cugraph_type_erased_device_array_view_t* dsts,
cugraph_error_t** error)
{
cugraph::c_api::cugraph_type_erased_host_array_view_t const* h_renumber_map =
reinterpret_cast<cugraph::c_api::cugraph_type_erased_host_array_view_t const*>(renumber_map);
cugraph::c_api::cugraph_type_erased_device_array_view_t* d_srcs =
reinterpret_cast<cugraph::c_api::cugraph_type_erased_device_array_view_t*>(srcs);
cugraph::c_api::cugraph_type_erased_device_array_view_t* d_dsts =
reinterpret_cast<cugraph::c_api::cugraph_type_erased_device_array_view_t*>(dsts);

CAPI_EXPECTS(h_renumber_map->type_ == d_srcs->type_,
CUGRAPH_INVALID_INPUT,
"type of renumber map and src vertices must match",
*error);

CAPI_EXPECTS(h_renumber_map->type_ == d_dsts->type_,
CUGRAPH_INVALID_INPUT,
"type of renumber map and dst vertices must match",
*error);

CAPI_EXPECTS(
d_srcs->size_ == d_dsts->size_, CUGRAPH_INVALID_INPUT, "src and dst sizes must match", *error);

*error = nullptr;

try {
switch (h_renumber_map->type_) {
case cugraph_data_type_id_t::INT32: {
return renumber_arbitrary_edgelist<int32_t>(
*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_,
h_renumber_map,
d_srcs,
d_dsts);
} break;
case cugraph_data_type_id_t::INT64: {
return renumber_arbitrary_edgelist<int64_t>(
*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_,
h_renumber_map,
d_srcs,
d_dsts);
} break;
default: {
std::stringstream ss;
ss << "ERROR: Unsupported data type enum:" << static_cast<int>(h_renumber_map->type_);
*error =
reinterpret_cast<cugraph_error_t*>(new cugraph::c_api::cugraph_error_t{ss.str().c_str()});
return CUGRAPH_INVALID_INPUT;
}
}
} catch (std::exception const& ex) {
*error = reinterpret_cast<::cugraph_error_t*>(new cugraph::c_api::cugraph_error_t{ex.what()});
return CUGRAPH_UNKNOWN_ERROR;
}

return CUGRAPH_SUCCESS;
}
Loading

0 comments on commit 55074ea

Please sign in to comment.