Skip to content

Add per-edge triplet neighbor-intersection transform-reduce primitive - #5551

Draft
jnke2016 wants to merge 38 commits into
rapidsai:mainfrom
jnke2016:fea_triplet_nbr_intersection_by_e
Draft

Add per-edge triplet neighbor-intersection transform-reduce primitive#5551
jnke2016 wants to merge 38 commits into
rapidsai:mainfrom
jnke2016:fea_triplet_nbr_intersection_by_e

Conversation

@jnke2016

@jnke2016 jnke2016 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

seunghwak and others added 30 commits May 14, 2026 13:05
…nts_by_e invoke the operator once per common neighbor r
@copy-pr-bot

copy-pr-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Comment on lines +1239 to +1240
VertexPairIterator vertex_pair_first,
VertexPairIterator vertex_pair_last,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are performing reduction "by_e", this means vertex pairs should be edges. Then, we should better use an edge bucket than general vertex pairs.

See

https://github.com/rapidsai/cugraph/blob/main/cpp/include/cugraph/prims/transform_gather_e.cuh#L151

Comment on lines +427 to +428
edge_t& nbr_offset,
edge_t& nbr_degree)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better return cuda::std::tuple<vertex_t const*, edge_t, edge_t> rather than taking nbr_indices, nbr_offset and nbr_degree as L-value references. Returning a value is more functional and generally preferable unless there is a strong reason to take L-value references.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can actually return just nbr_indices + nbr_offset and nbr_degree.

// whole function k times and emit k times over.
if (s > edge_t{0} && short_indices[p - 1] == w) { return; }

// Binary search for w in the longer list. Could equivalently use the sequential thrust version:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you using thrust::lower_bound(thrust::seq, ...)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And first, you can skip all the complexity if the graph is not a multi-graph (graph_view.is_multigraph()), and you may be able to update the caller site to call this only once per unique v in the shorter neighbor list (assuming that there is very few edges with a huge multiplicity value).

You can run thrust::lower_bound first and just scan from there.

v1_off,
v1_deg);

// Scan the shorter neighbor list, binary-search the longer one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may use

__ballot_sync (set to 1 if its the first in the run) followed by __popc then __fns to find n'th unique neighbor in the short neighbor list.

There can be a trade-off. If multi-edges are infrequent, you may just let few threads in a warp. If multi-edges are common, we may allow few edges to process more than one neighbor in the short neighbor list.

Or if we assume that invoking intersection_op is expensive, we can separate finding common neighbor indices in the long and short arrays (each thread may process more than one neighbor in the short neighbor list) and calling intersection_op.

We use all threads in a warp to update the array indices. Then, for the identified indices, call intersection_op in the second round. This may lead to faster & simpler code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants