-
Notifications
You must be signed in to change notification settings - Fork 310
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
Address Leiden numbering issue #4845
Merged
rapids-bot
merged 21 commits into
rapidsai:branch-25.02
from
jnke2016:branch-25.02_fix_leiden_numbering
Jan 11, 2025
Merged
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4d003a0
relabel clusters ids
jnke2016 3e06c06
leiden expects unique seed per GPU
jnke2016 0675c73
properly relabel cluster ids in multi_gpu case
jnke2016 2b1ac70
fix style
jnke2016 fdf09de
shuffle cluster IDs
jnke2016 ce22ea5
fix style
jnke2016 649ea7f
simplify code
jnke2016 cfdba93
add SG tests for Leiden's cluster IDs
jnke2016 9e24488
add MG tests for Leiden's cluster IDs
jnke2016 2f3a737
fix style
jnke2016 9489ea0
include utility functions
jnke2016 1ffe352
update mg tests
jnke2016 c70a229
fix style
jnke2016 7e4651f
Merge remote-tracking branch 'upstream/branch-25.02' into branch-25.0…
jnke2016 66bd69d
removed unused code
jnke2016 485ab35
fix copyright
jnke2016 d1d3687
fix copyright
jnke2016 2f00a89
update copyright
jnke2016 c9e2781
handle case when random_state has default value
jnke2016 c9945cd
add python tests for Leiden numbering
jnke2016 f4d811a
fix style
jnke2016 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2022-2024, NVIDIA CORPORATION. | ||
* Copyright (c) 2022-2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -604,26 +604,21 @@ void relabel_cluster_ids(raft::handle_t const& handle, | |
size_t num_nodes) | ||
{ | ||
vertex_t local_cluster_id_first{0}; | ||
|
||
// Get unique cluster id and shuffle | ||
remove_duplicates<vertex_t, multi_gpu>(handle, unique_cluster_ids); | ||
|
||
if constexpr (multi_gpu) { | ||
auto unique_cluster_range_lasts = cugraph::partition_manager::compute_partition_range_lasts( | ||
handle, static_cast<vertex_t>(unique_cluster_ids.size())); | ||
|
||
auto& comm = handle.get_comms(); | ||
auto const comm_size = comm.get_size(); | ||
auto const comm_rank = comm.get_rank(); | ||
auto& major_comm = handle.get_subcomm(cugraph::partition_manager::major_comm_name()); | ||
auto const major_comm_size = major_comm.get_size(); | ||
auto const major_comm_rank = major_comm.get_rank(); | ||
auto& minor_comm = handle.get_subcomm(cugraph::partition_manager::minor_comm_name()); | ||
auto const minor_comm_size = minor_comm.get_size(); | ||
auto const minor_comm_rank = minor_comm.get_rank(); | ||
|
||
auto vertex_partition_id = | ||
partition_manager::compute_vertex_partition_id_from_graph_subcomm_ranks( | ||
major_comm_size, minor_comm_size, major_comm_rank, minor_comm_rank); | ||
|
||
local_cluster_id_first = | ||
vertex_partition_id == 0 ? vertex_t{0} : unique_cluster_range_lasts[vertex_partition_id - 1]; | ||
auto cluster_ids_size_per_rank = cugraph::host_scalar_allgather( | ||
handle.get_comms(), unique_cluster_ids.size(), handle.get_stream()); | ||
|
||
std::vector<vertex_t> cluster_ids_starts(cluster_ids_size_per_rank.size()); | ||
std::exclusive_scan(cluster_ids_size_per_rank.begin(), | ||
cluster_ids_size_per_rank.end(), | ||
cluster_ids_starts.begin(), | ||
size_t{0}); | ||
auto& comm = handle.get_comms(); | ||
local_cluster_id_first = cluster_ids_starts[comm.get_rank()]; | ||
} | ||
|
||
rmm::device_uvector<vertex_t> numbering_indices(unique_cluster_ids.size(), handle.get_stream()); | ||
|
@@ -713,6 +708,17 @@ std::pair<size_t, weight_t> leiden( | |
|
||
detail::flatten_leiden_dendrogram(handle, graph_view, *dendrogram, clustering); | ||
|
||
size_t local_num_verts = (*dendrogram).get_level_size_nocheck(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dendrogram->get_level_size_nocheck(0); |
||
rmm::device_uvector<vertex_t> unique_cluster_ids(local_num_verts, handle.get_stream()); | ||
|
||
thrust::copy(handle.get_thrust_policy(), | ||
clustering, | ||
clustering + local_num_verts, | ||
unique_cluster_ids.begin()); | ||
|
||
detail::relabel_cluster_ids<vertex_t, multi_gpu>( | ||
handle, unique_cluster_ids, clustering, local_num_verts); | ||
|
||
return std::make_pair(dendrogram->num_levels(), modularity); | ||
} | ||
|
||
|
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
Oops, something went wrong.
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.
Looks good, functionally.
If you're going to pull out
&comm
from the handle, I'd do that at line 612 (right as you enter the if block and usecomm
also in the call tohost_scalar_allgather
. Otherwise I would just usehandle.get_comms().get_rank()
as the index in the next line.But that's purely cosmetic.