Skip to content

Commit

Permalink
Remove edge renumber map from the homogeneous sampling API (#4775)
Browse files Browse the repository at this point in the history
edge renumbering is only supported in heterogeneous neighborhood sampling hence trying to extract it from the PLC API leads to a segmentation fault

This PR :

1. fixes a bug in homogeneous neighborhood sampling (both uniform and bias).
2. properly handle vertex_type_offsets when performing heterogeneous renumbering
3. fixes a typo in the homogeneous neighborhood sampling docstrings

Authors:
  - Joseph Nke (https://github.com/jnke2016)

Approvers:
  - Chuck Hastings (https://github.com/ChuckHastings)
  - Rick Ratzel (https://github.com/rlratzel)
  - Alex Barghi (https://github.com/alexbarghi-nv)
  - Seunghwa Kang (https://github.com/seunghwak)

URL: #4775
  • Loading branch information
jnke2016 authored Dec 4, 2024
1 parent 8035bb5 commit 50a11b1
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 254 deletions.
16 changes: 8 additions & 8 deletions cpp/include/cugraph/sampling_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ struct sampling_flags_t {
* @param edge_type_view Optional view object holding edge types for @p graph_view.
* @param starting_vertices Device span of starting vertex IDs for the sampling.
* In a multi-gpu context the starting vertices should be local to this GPU.
* @param starting_vertex_label_offsets Optional device span of labels associated with each starting
* @param starting_vertex_labels Optional device span of labels associated with each starting
* vertex for the sampling.
* @param label_to_output_comm_rank Optional device span identifying which rank should get sampling
* outputs of each vertex label. This should be the same on each rank.
Expand Down Expand Up @@ -340,7 +340,7 @@ homogeneous_uniform_neighbor_sample(
std::optional<edge_property_view_t<edge_t, edge_t const*>> edge_id_view,
std::optional<edge_property_view_t<edge_t, edge_type_t const*>> edge_type_view,
raft::device_span<vertex_t const> starting_vertices,
std::optional<raft::device_span<int32_t const>> starting_vertex_label_offsets,
std::optional<raft::device_span<int32_t const>> starting_vertex_labels,
std::optional<raft::device_span<int32_t const>> label_to_output_comm_rank,
raft::host_span<int32_t const> fan_out,
sampling_flags_t sampling_flags,
Expand Down Expand Up @@ -385,7 +385,7 @@ homogeneous_uniform_neighbor_sample(
* corresponding edge can never be selected.
* @param starting_vertices Device span of starting vertex IDs for the sampling.
* In a multi-gpu context the starting vertices should be local to this GPU.
* @param starting_vertex_label_offsets Optional device span of labels associated with each starting
* @param starting_vertex_labels Optional device span of labels associated with each starting
* vertex for the sampling.
* @param label_to_output_comm_rank Optional device span identifying which rank should get sampling
* outputs of each vertex label. This should be the same on each rank.
Expand Down Expand Up @@ -421,7 +421,7 @@ homogeneous_biased_neighbor_sample(
std::optional<edge_property_view_t<edge_t, edge_type_t const*>> edge_type_view,
edge_property_view_t<edge_t, bias_t const*> edge_bias_view,
raft::device_span<vertex_t const> starting_vertices,
std::optional<raft::device_span<int32_t const>> starting_vertex_label_offsets,
std::optional<raft::device_span<int32_t const>> starting_vertex_labels,
std::optional<raft::device_span<int32_t const>> label_to_output_comm_rank,
raft::host_span<int32_t const> fan_out,
sampling_flags_t sampling_flags,
Expand Down Expand Up @@ -462,7 +462,7 @@ homogeneous_biased_neighbor_sample(
* @param edge_type_view Optional view object holding edge types for @p graph_view.
* @param starting_vertices Device span of starting vertex IDs for the sampling.
* In a multi-gpu context the starting vertices should be local to this GPU.
* @param starting_vertex_label_offsets Optional device span of labels associated with each starting
* @param starting_vertex_labels Optional device span of labels associated with each starting
* vertex for the sampling.
* @param label_to_output_comm_rank Optional device span identifying which rank should get sampling
* outputs of each vertex label. This should be the same on each rank.
Expand Down Expand Up @@ -498,7 +498,7 @@ heterogeneous_uniform_neighbor_sample(
std::optional<edge_property_view_t<edge_t, edge_t const*>> edge_id_view,
std::optional<edge_property_view_t<edge_t, edge_type_t const*>> edge_type_view,
raft::device_span<vertex_t const> starting_vertices,
std::optional<raft::device_span<int32_t const>> starting_vertex_label_offsets,
std::optional<raft::device_span<int32_t const>> starting_vertex_labels,
std::optional<raft::device_span<int32_t const>> label_to_output_comm_rank,
raft::host_span<int32_t const> fan_out,
edge_type_t num_edge_types,
Expand Down Expand Up @@ -545,7 +545,7 @@ heterogeneous_uniform_neighbor_sample(
* corresponding edge can never be selected.
* @param starting_vertices Device span of starting vertex IDs for the sampling.
* In a multi-gpu context the starting vertices should be local to this GPU.
* @param starting_vertex_label_offsets Optional device span of labels associated with each starting
* @param starting_vertex_labels Optional device span of labels associated with each starting
* vertex for the sampling.
* @param label_to_output_comm_rank Optional device span identifying which rank should get sampling
* outputs of each vertex label. This should be the same on each rank.
Expand Down Expand Up @@ -583,7 +583,7 @@ heterogeneous_biased_neighbor_sample(
std::optional<edge_property_view_t<edge_t, edge_type_t const*>> edge_type_view,
edge_property_view_t<edge_t, bias_t const*> edge_bias_view,
raft::device_span<vertex_t const> starting_vertices,
std::optional<raft::device_span<int32_t const>> starting_vertex_label_offsets,
std::optional<raft::device_span<int32_t const>> starting_vertex_labels,
std::optional<raft::device_span<int32_t const>> label_to_output_comm_rank,
raft::host_span<int32_t const> fan_out,
edge_type_t num_edge_types,
Expand Down
16 changes: 16 additions & 0 deletions cpp/include/cugraph_c/sampling_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ cugraph_error_code_t cugraph_homogeneous_biased_neighbor_sample(
* @param [in] start_vertices Device array of start vertices for the sampling
* @param [in] starting_vertex_label_offsets Device array of the offsets for each label in
* the seed list. This parameter is only used with the retain_seeds option.
* @param [in] vertex_type_offsets Device array of the offsets for each vertex type in the
* graph.
* @param [in] fan_out Host array defining the fan out at each step in the sampling
* algorithm. We only support fan_out values of type INT32
* @param [in] num_edge_types Number of edge types where a value of 1 translates to homogeneous
Expand All @@ -570,6 +572,7 @@ cugraph_error_code_t cugraph_heterogeneous_uniform_neighbor_sample(
cugraph_graph_t* graph,
const cugraph_type_erased_device_array_view_t* start_vertices,
const cugraph_type_erased_device_array_view_t* starting_vertex_label_offsets,
const cugraph_type_erased_device_array_view_t* vertex_type_offsets,
const cugraph_type_erased_host_array_view_t* fan_out,
int num_edge_types,
const cugraph_sampling_options_t* options,
Expand Down Expand Up @@ -598,6 +601,8 @@ cugraph_error_code_t cugraph_heterogeneous_uniform_neighbor_sample(
* @param [in] start_vertices Device array of start vertices for the sampling
* @param [in] starting_vertex_label_offsets Device array of the offsets for each label in
* the seed list. This parameter is only used with the retain_seeds option.
* @param [in] vertex_type_offsets Device array of the offsets for each vertex type in the
* graph.
* @param [in] fan_out Host array defining the fan out at each step in the sampling
* algorithm. We only support fan_out values of type INT32
* @param [in] num_edge_types Number of edge types where a value of 1 translates to homogeneous
Expand All @@ -618,6 +623,7 @@ cugraph_error_code_t cugraph_heterogeneous_biased_neighbor_sample(
const cugraph_edge_property_view_t* edge_biases,
const cugraph_type_erased_device_array_view_t* start_vertices,
const cugraph_type_erased_device_array_view_t* starting_vertex_label_offsets,
const cugraph_type_erased_device_array_view_t* vertex_type_offsets,
const cugraph_type_erased_host_array_view_t* fan_out,
int num_edge_types,
const cugraph_sampling_options_t* options,
Expand Down Expand Up @@ -735,6 +741,16 @@ cugraph_type_erased_device_array_view_t* cugraph_sample_result_get_hop(
cugraph_type_erased_device_array_view_t* cugraph_sample_result_get_label_hop_offsets(
const cugraph_sample_result_t* result);

/**
* @ingroup samplingC
* @brief Get the label-type-hop offsets from the sampling algorithm result
*
* @param [in] result The result from a sampling algorithm
* @return type erased array pointing to the label-type-hop offsets
*/
cugraph_type_erased_device_array_view_t* cugraph_sample_result_get_label_type_hop_offsets(
const cugraph_sample_result_t* result);

/**
* @ingroup samplingC
* @brief Get the index from the sampling algorithm result
Expand Down
Loading

0 comments on commit 50a11b1

Please sign in to comment.