Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
acf15bc
Merge pull request #37 from rapidsai/branch-0.17
aschaffer Nov 30, 2020
a584e0b
Merge pull request #38 from rapidsai/branch-0.18
aschaffer Dec 9, 2020
338b2d4
Merge pull request #39 from rapidsai/branch-0.18
aschaffer Dec 30, 2020
efd7e9a
Merge pull request #40 from rapidsai/branch-0.18
aschaffer Jan 12, 2021
a23ce0d
Merge pull request #41 from rapidsai/branch-0.19
aschaffer Feb 25, 2021
22b32d8
Merge pull request #42 from rapidsai/branch-0.19
aschaffer Mar 1, 2021
e5042fc
Merge pull request #43 from rapidsai/branch-0.19
aschaffer Mar 20, 2021
ca02ee4
Merge pull request #44 from rapidsai/branch-0.19
aschaffer Apr 7, 2021
79409e7
Merge pull request #45 from rapidsai/branch-0.20
aschaffer Apr 13, 2021
360c293
Merge pull request #46 from rapidsai/branch-0.20
aschaffer Apr 28, 2021
e57f261
Merge pull request #47 from rapidsai/branch-0.20
aschaffer May 6, 2021
a63cdea
Merge pull request #48 from rapidsai/branch-21.08
aschaffer Jun 9, 2021
7e6bf4c
Merge branch 'rapidsai:branch-21.08' into branch-21.08
aschaffer Jun 15, 2021
6f3b342
Merge branch 'rapidsai:branch-21.08' into branch-21.08
aschaffer Jul 19, 2021
fbf5f36
Merge branch 'rapidsai:branch-21.10' into branch-21.10
aschaffer Aug 5, 2021
ffacad0
Merge branch 'rapidsai:branch-21.10' into branch-21.10
aschaffer Aug 13, 2021
8db2e74
Merge branch 'rapidsai:branch-21.10' into branch-21.10
aschaffer Aug 17, 2021
e560fd8
Merge branch 'rapidsai:branch-21.12' into branch-21.12
aschaffer Oct 11, 2021
a80cec5
Preliminary node2vec selector skeleton.
aschaffer Oct 14, 2021
c73fab8
Simplified node2vec selector interface.
aschaffer Oct 14, 2021
55b32e9
Max out-degree computation for alpha scratchpad.
aschaffer Oct 15, 2021
02eb928
Core node2vec sampling algorithm preliminaries.
aschaffer Oct 15, 2021
e903322
Core node2vec sampling algorithm; the cached option.
aschaffer Oct 15, 2021
75412ec
Fixed alpha cache indexing.
aschaffer Oct 18, 2021
523e7b1
Functionality without alpha caching.
aschaffer Oct 18, 2021
06e6ac8
First step in path for node2vec.
aschaffer Oct 18, 2021
5ad4e82
Sampling interface change to accomodate node2vec.
aschaffer Oct 18, 2021
12bfcff
Testing node2vec: check logic.
aschaffer Oct 19, 2021
71c7e3c
Testing node2vec: low level test.
aschaffer Oct 20, 2021
0b94613
Testing node2vec: fix due to lack of structured bindings support for …
aschaffer Oct 20, 2021
63ae779
Testing node2vec: low level comparison against biased + alpha sclaed …
aschaffer Oct 20, 2021
46fbc87
Testing node2vec: fix for low level comparison against biased + alpha…
aschaffer Oct 20, 2021
66f90c1
Merge branch 'branch-21.12' of github.com:rapidsai/cugraph into fea_e…
aschaffer Oct 21, 2021
ffc12e8
Testing node2vec: alpha buffer.
aschaffer Oct 21, 2021
8326b0b
node2vec sampling exposed to RW.
aschaffer Oct 21, 2021
40f1e02
Added some pre-conditions for running RW with node2vec.
aschaffer Oct 21, 2021
16efb7a
Test RW with node2vec.
aschaffer Oct 21, 2021
5f7084b
Added node2vec constraint: requires floating point type for weights.
aschaffer Oct 22, 2021
fbc8898
Added node2vec profiling: alpha cache brings about 30% speed-up compa…
aschaffer Oct 22, 2021
ab235db
Added node2vec flag for selecting alpha cache.
aschaffer Oct 22, 2021
bee6048
Tests for node2vec with and without alpha cache.
aschaffer Oct 25, 2021
b80b759
Profiling for node2vec with and without alpha cache.
aschaffer Oct 25, 2021
8ff3cdf
Addressed review on compute_max_degree().
aschaffer Oct 27, 2021
a9abf93
Addressed review on unused args warnings.
aschaffer Oct 27, 2021
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
8 changes: 6 additions & 2 deletions cpp/include/cugraph/api_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ enum class sampling_strategy_t : int { UNIFORM = 0, BIASED, NODE2VEC };
struct sampling_params_t {
sampling_params_t(void) {}

sampling_params_t(int sampling_type, double p = 1.0, double q = 1.0)
: sampling_type_(static_cast<sampling_strategy_t>(sampling_type)), p_(p), q_(q)
sampling_params_t(int sampling_type, double p = 1.0, double q = 1.0, bool use_alpha_cache = false)
: sampling_type_(static_cast<sampling_strategy_t>(sampling_type)),
p_(p),
q_(q),
use_alpha_cache_(use_alpha_cache)
{
}

Expand All @@ -39,5 +42,6 @@ struct sampling_params_t {
//
double p_;
double q_;
bool use_alpha_cache_{false};
};
} // namespace cugraph
72 changes: 68 additions & 4 deletions cpp/src/sampling/random_walks.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include <cassert>
#include <cstdlib> // FIXME: requirement for temporary std::getenv()
#include <ctime>
#include <limits>
//
#include <optional>
#include <tuple>
#include <type_traits>
Expand Down Expand Up @@ -278,9 +280,19 @@ struct col_indx_extract_t<graph_t, index_t, std::enable_if_t<graph_t::is_multi_g
auto start_v_pos = chunk_offset + delta;
auto start_w_pos = chunk_offset - path_indx + delta;

auto src_v = ptr_coalesced_v[start_v_pos];
auto rnd_val = ptr_d_random[path_indx];
auto opt_tpl_vn_wn = sampler(src_v, rnd_val);
auto src_v = ptr_coalesced_v[start_v_pos];
auto rnd_val = ptr_d_random[path_indx];

// `node2vec` info:
//
bool start_path = true;
auto prev_v = src_v;
if (delta > 0) {
start_path = false;
prev_v = ptr_coalesced_v[start_v_pos - 1];
}

auto opt_tpl_vn_wn = sampler(src_v, rnd_val, prev_v, path_indx, start_path);

if (opt_tpl_vn_wn.has_value()) {
auto src_vertex = thrust::get<0>(*opt_tpl_vn_wn);
Expand Down Expand Up @@ -1114,10 +1126,40 @@ random_walks(raft::handle_t const& handle,
int selector_type{0};
if (sampling_strategy) selector_type = static_cast<int>(sampling_strategy->sampling_type_);

// node2vec is only possible for weight_t being a floating-point type:
//
if constexpr (!std::is_floating_point_v<weight_t>) {
CUGRAPH_EXPECTS(selector_type != static_cast<int>(sampling_strategy_t::NODE2VEC),
"node2vec requires floating point type for weights.");
}

if (use_vertical_strategy) {
if (selector_type == static_cast<int>(sampling_strategy_t::BIASED)) {
detail::biased_selector_t<graph_t, real_t> selector{handle, graph, real_t{0}};

auto quad_tuple =
detail::random_walks_impl<graph_t, decltype(selector), detail::vertical_traversal_t>(
handle, graph, d_v_start, max_depth, selector, use_padding);
// ignore last element of the quad, seed,
// since it's meant for testing / debugging, only:
//
return std::make_tuple(std::move(std::get<0>(quad_tuple)),
std::move(std::get<1>(quad_tuple)),
std::move(std::get<2>(quad_tuple)));
} else if (selector_type == static_cast<int>(sampling_strategy_t::NODE2VEC)) {
weight_t p(sampling_strategy->p_);
weight_t q(sampling_strategy->q_);

edge_t alpha_num_paths = sampling_strategy->use_alpha_cache_ ? num_paths : 0;

weight_t roundoff = std::numeric_limits<weight_t>::epsilon();
CUGRAPH_EXPECTS(p > roundoff, "node2vec p parameter is too small.");

CUGRAPH_EXPECTS(q > roundoff, "node2vec q parameter is too small.");

detail::node2vec_selector_t<graph_t, real_t> selector{
handle, graph, real_t{0}, p, q, alpha_num_paths};

auto quad_tuple =
detail::random_walks_impl<graph_t, decltype(selector), detail::vertical_traversal_t>(
handle, graph, d_v_start, max_depth, selector, use_padding);
Expand All @@ -1140,10 +1182,32 @@ random_walks(raft::handle_t const& handle,
std::move(std::get<1>(quad_tuple)),
std::move(std::get<2>(quad_tuple)));
}
} else {
} else { // horizontal traversal strategy
if (selector_type == static_cast<int>(sampling_strategy_t::BIASED)) {
detail::biased_selector_t<graph_t, real_t> selector{handle, graph, real_t{0}};

auto quad_tuple =
detail::random_walks_impl(handle, graph, d_v_start, max_depth, selector, use_padding);
// ignore last element of the quad, seed,
// since it's meant for testing / debugging, only:
//
return std::make_tuple(std::move(std::get<0>(quad_tuple)),
std::move(std::get<1>(quad_tuple)),
std::move(std::get<2>(quad_tuple)));
} else if (selector_type == static_cast<int>(sampling_strategy_t::NODE2VEC)) {
weight_t p(sampling_strategy->p_);
weight_t q(sampling_strategy->q_);

edge_t alpha_num_paths = sampling_strategy->use_alpha_cache_ ? num_paths : 0;

weight_t roundoff = std::numeric_limits<weight_t>::epsilon();
CUGRAPH_EXPECTS(p > roundoff, "node2vec p parameter is too small.");

CUGRAPH_EXPECTS(q > roundoff, "node2vec q parameter is too small.");

detail::node2vec_selector_t<graph_t, real_t> selector{
handle, graph, real_t{0}, p, q, alpha_num_paths};

auto quad_tuple =
detail::random_walks_impl(handle, graph, d_v_start, max_depth, selector, use_padding);
// ignore last element of the quad, seed,
Expand Down
Loading