Skip to content

Replace O(N*degree^2) CPU dedup with GPU warp-ballot kernel - #2437

Draft
jamxia155 wants to merge 1 commit into
NVIDIA:mainfrom
jamxia155:dedup-nn-descent-graph-on-gpu
Draft

Replace O(N*degree^2) CPU dedup with GPU warp-ballot kernel#2437
jamxia155 wants to merge 1 commit into
NVIDIA:mainfrom
jamxia155:dedup-nn-descent-graph-on-gpu

Conversation

@jamxia155

Copy link
Copy Markdown
Contributor

The graph shrink step in GNND::build() copied the NN-descent output while removing duplicate and self-referencing neighbor IDs using a nested scan: for each of the N nodes, each of the node_degree candidates was checked against all already-placed entries, giving O(N*degree^2) CPU work that scales poorly with graph degree and dataset size.

Replace with a GPU dedup_graph_kernel that runs one warp per node. The warp scans neighbors in original order, using __ballot_sync for O(warp-width) duplicate detection, and fills any remaining slots with xorshift64 random nodes. The H2D/D2H transfers are O(N*degree) -- the same order as a single pass over the graph -- while the replaced CPU work is O(N*degree^2), so the transfers are dominated by the savings at any practical degree.

Tested on 32-core AMD + H100 with n_rows=2.5M and graph_degree=56, this change reduces runtime by about 6 seconds.

The graph shrink step in GNND::build() copied the NN-descent output
while removing duplicate and self-referencing neighbor IDs using a
nested scan: for each of the N nodes, each of the `node_degree`
candidates was checked against all already-placed entries, giving
O(N*degree^2) CPU work that scales poorly with graph degree and dataset
size.

Replace with a GPU kernel (dedup_graph_kernel) that runs one warp per
node. The warp scans InternalID_t neighbors in original order, using
__ballot_sync for O(warp-width) duplicate detection, and fills any
remaining slots with xorshift64 random nodes. Original neighbor order
is preserved, avoiding the recall regression seen with sort-based
approaches. The H2D/D2H transfers are O(N*degree) -- the same order
as a single pass over the graph -- while the replaced CPU work is
O(N*degree^2), so the transfers are dominated by the savings at any
practical degree.
@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@jamxia155 jamxia155 self-assigned this Aug 12, 2026
@jamxia155 jamxia155 added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant