-
Notifications
You must be signed in to change notification settings - Fork 311
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
[FEA] neighbor sampling in COO/CSR format #1982
Merged
rapids-bot
merged 14 commits into
rapidsai:branch-22.04
from
MatthiasKohl:fea_sampling_mfg_sg
Feb 22, 2022
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e2479de
added neighbor sampling API
MatthiasKohl dddbf07
improved neighbor sampling api according to suggestions
MatthiasKohl 983f0de
Merge branch 'branch-22.02' into fea_sampling_mfg_sg
MatthiasKohl 59e3c3c
added implementation of single-GPU neighborhood sampling based on cug…
MatthiasKohl e63787f
Merge branch 'branch-22.04' into fea_sampling_mfg_sg
MatthiasKohl 71329dc
add sg sampling: clang format/copyright fix
MatthiasKohl b75c8cc
Merge branch 'branch-22.04' into fea_sampling_mfg_sg
MatthiasKohl d60eb8d
using latest cugraph-ops internal RNG
MatthiasKohl 967ca79
libcugraphops added as run dependency (since shared library and inclu…
MatthiasKohl 3a7a785
updated copyright
MatthiasKohl 9d94156
cugraph-ops: added cmake dependency
MatthiasKohl 578e442
fixed no install build
MatthiasKohl b4e3122
added cugraph ops to cmake build and install exports
MatthiasKohl 96c00c8
added neighborhood sampling to Cmake and fixed compilation
MatthiasKohl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2021-2022, 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 <cugraph/algorithms.hpp> | ||
|
||
#include <utilities/cugraph_ops_utils.hpp> | ||
|
||
#include <cugraph-ops/graph/sampling.h> | ||
|
||
namespace cugraph { | ||
|
||
template std::tuple<rmm::device_uvector<int32_t>, rmm::device_uvector<int32_t>> | ||
sample_neighbors_adjacency_list(raft::handle_t const& handle, | ||
ops::gnn::graph::Rng& rng, | ||
graph_view_t<int32_t, int32_t, float, false, false> const& gview, | ||
int32_t const* ptr_d_start, | ||
size_t num_start_vertices, | ||
size_t sampling_size, | ||
ops::gnn::graph::SamplingAlgoT sampling_algo) | ||
{ | ||
const auto [graph, max_degree] = detail::get_graph_and_max_degree(gview); | ||
return ops::gnn::graph::uniform_sample_csr(rng, | ||
graph, | ||
ptr_d_start, | ||
num_start_vertices, | ||
sampling_size, | ||
sampling_algo, | ||
max_degree, | ||
handle.get_stream()); | ||
} | ||
|
||
template std::tuple<rmm::device_uvector<int32_t>, rmm::device_uvector<int32_t>> | ||
sample_neighbors_edgelist(raft::handle_t const& handle, | ||
ops::gnn::graph::Rng& rng, | ||
graph_view_t<int32_t, int32_t, float, false, false> const& gview, | ||
typename graph_t::vertex_type const* ptr_d_start, | ||
size_t num_start_vertices, | ||
size_t sampling_size, | ||
ops::gnn::graph::SamplingAlgoT sampling_algo) | ||
{ | ||
const auto [graph, max_degree] = detail::get_graph_and_max_degree(gview); | ||
return ops::gnn::graph::uniform_sample_csr(rng, | ||
graph, | ||
ptr_d_start, | ||
num_start_vertices, | ||
sampling_size, | ||
sampling_algo, | ||
max_degree, | ||
handle.get_stream()); | ||
} | ||
|
||
} // namespace cugraph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2021-2022, 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cugraph/graph_view.hpp> | ||
|
||
#include <cugraph-ops/graph/format.h> | ||
|
||
#include <tuple> | ||
|
||
namespace cugraph { | ||
namespace detail { | ||
|
||
template <typename IdxT, typename WeightT> | ||
ops::gnn::graph::fg_csr<IdxT> get_graph( | ||
graph_view_t<IdxT, IdxT, WeightT, false, false> const& gview) | ||
{ | ||
ops::gnn::graph::fg_csr<IdxT> graph; | ||
graph.n_nodes = gview.get_number_of_vertices(); | ||
graph.n_indices = gview.get_number_of_edges(); | ||
graph.offsets = gview.get_matrix_partition_view().get_offsets(); | ||
graph.indices = gview.get_matrix_partition_view().get_indices(); | ||
return graph; | ||
} | ||
|
||
template <typename IdxT, typename WeightT> | ||
std::tuple<ops::gnn::graph::fg_csr<IdxT>, IdxT> get_graph_and_max_degree( | ||
graph_view_t<IdxT, IdxT, WeightT, false, false> const& gview) | ||
{ | ||
// FIXME this is sufficient for now, but if there is a fast (cached) way | ||
// of getting max degree, use that instead | ||
int32_t max_degree = std::numeric_limits<int32_t>::max(); | ||
return std::make_tuple(get_graph(gview), max_degree); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace cugraph |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As cugraphops is part of the public api for cugraph, it needs to be properly exported.
This is causing the CI failures as consumers of the
cugraph-config.cmake
have no way of findingcugraphops::cugraphops
. This causes the below error:https://github.com/rapidsai/cugraph/blob/branch-22.04/cpp/cmake/thirdparty/get_libcugraphops.cmake
needs to add BUILD and INSTALL export set entries to the
rapids_find_generate_module
andrapids_find_package
lines (cugraph-exports
is the export set ).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.
@robertmaynard if you see the similar setup in cuML for the libcumlprims, it seems to not follow your suggestion, but that's working for cuML. Any ideas why?
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.
Because
cumlprims_mg
is a private dependency ofcuml
and therefore doesn't need to be found by consumers ofcuml
.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.
Got it. Thanks Robert.