Skip to content

Commit

Permalink
Merge branch 'branch-25.04' into one-pass-conda-test-env
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA committed Feb 18, 2025
2 parents 347da2a + b777261 commit 4a89590
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 26 deletions.
26 changes: 17 additions & 9 deletions cpp/src/community/legacy/spectral_clustering.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-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.
Expand Down Expand Up @@ -88,12 +88,14 @@ void balancedCutClustering_impl(legacy::GraphCSRView<vertex_t, edge_t, weight_t>

using index_type = vertex_t;
using value_type = weight_t;
using nnz_type = edge_t;

raft::spectral::matrix::sparse_matrix_t<index_type, value_type> const r_csr_m{handle, graph};
raft::spectral::matrix::sparse_matrix_t<index_type, value_type, nnz_type> const r_csr_m{handle,
graph};

raft::spectral::eigen_solver_config_t<index_type, value_type> eig_cfg{
raft::spectral::eigen_solver_config_t<index_type, value_type, nnz_type> eig_cfg{
n_eig_vects, evs_max_it, restartIter_lanczos, evs_tol, reorthog, seed1};
raft::spectral::lanczos_solver_t<index_type, value_type> eig_solver{eig_cfg};
raft::spectral::lanczos_solver_t<index_type, value_type, nnz_type> eig_solver{eig_cfg};

raft::spectral::cluster_solver_config_t<index_type, value_type> clust_cfg{
n_clusters, kmean_max_it, kmean_tol, seed2};
Expand Down Expand Up @@ -158,12 +160,14 @@ void spectralModularityMaximization_impl(

using index_type = vertex_t;
using value_type = weight_t;
using nnz_type = edge_t;

raft::spectral::matrix::sparse_matrix_t<index_type, value_type> const r_csr_m{handle, graph};
raft::spectral::matrix::sparse_matrix_t<index_type, value_type, nnz_type> const r_csr_m{handle,
graph};

raft::spectral::eigen_solver_config_t<index_type, value_type> eig_cfg{
raft::spectral::eigen_solver_config_t<index_type, value_type, nnz_type> eig_cfg{
n_eig_vects, evs_max_it, restartIter_lanczos, evs_tol, reorthog, seed1};
raft::spectral::lanczos_solver_t<index_type, value_type> eig_solver{eig_cfg};
raft::spectral::lanczos_solver_t<index_type, value_type, nnz_type> eig_solver{eig_cfg};

raft::spectral::cluster_solver_config_t<index_type, value_type> clust_cfg{
n_clusters, kmean_max_it, kmean_tol, seed2};
Expand All @@ -190,8 +194,10 @@ void analyzeModularityClustering_impl(legacy::GraphCSRView<vertex_t, edge_t, wei

using index_type = vertex_t;
using value_type = weight_t;
using nnz_type = edge_t;

raft::spectral::matrix::sparse_matrix_t<index_type, value_type> const r_csr_m{handle, graph};
raft::spectral::matrix::sparse_matrix_t<index_type, value_type, nnz_type> const r_csr_m{handle,
graph};

weight_t mod;
raft::spectral::analyzeModularity(handle, r_csr_m, n_clusters, clustering, mod);
Expand All @@ -216,8 +222,10 @@ void analyzeBalancedCut_impl(legacy::GraphCSRView<vertex_t, edge_t, weight_t> co

using index_type = vertex_t;
using value_type = weight_t;
using nnz_type = edge_t;

raft::spectral::matrix::sparse_matrix_t<index_type, value_type> const r_csr_m{handle, graph};
raft::spectral::matrix::sparse_matrix_t<index_type, value_type, nnz_type> const r_csr_m{handle,
graph};

raft::spectral::analyzePartition(handle, r_csr_m, n_clusters, clustering, edge_cut, cost);

Expand Down
4 changes: 2 additions & 2 deletions python/cugraph/cugraph/structure/graph_primtypes.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
# Copyright (c) 2020-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.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -36,7 +36,7 @@ cdef move_device_buffer_to_column(
buff = DeviceBuffer.c_from_unique_ptr(move(device_buffer_unique_ptr))
buff = as_buffer(buff)
if buff.nbytes != 0:
column = cudf.core.column.build_column(buff, dtype=dtype)
column = cudf.core.column.build_column(buff, dtype=cudf.dtype(dtype))
return column
return None

Expand Down
46 changes: 31 additions & 15 deletions python/cugraph/cugraph/structure/hypergraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
# Copyright (c) 2020-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.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -40,6 +40,9 @@
from cugraph.structure.symmetrize import symmetrize


_str_dtype = np.dtype("str")


def hypergraph(
values,
columns=None,
Expand Down Expand Up @@ -328,17 +331,19 @@ def _create_entity_nodes(
cudf.DataFrame(
dict(
[
(NODEID, cudf.core.column.column_empty(0, "str")),
(NODEID, cudf.core.column.column_empty(0, _str_dtype)),
(
CATEGORY,
cudf.core.column.column_empty(
0, "str" if not categorical_metadata else _empty_cat_dt()
0,
_str_dtype if not categorical_metadata else _empty_cat_dt(),
),
),
(
NODETYPE,
cudf.core.column.column_empty(
0, "str" if not categorical_metadata else _empty_cat_dt()
0,
_str_dtype if not categorical_metadata else _empty_cat_dt(),
),
),
]
Expand Down Expand Up @@ -428,13 +433,15 @@ def _create_hyper_edges(
dict(
(
[
(EVENTID, cudf.core.column.column_empty(0, "str")),
(ATTRIBID, cudf.core.column.column_empty(0, "str")),
(EVENTID, cudf.core.column.column_empty(0, _str_dtype)),
(ATTRIBID, cudf.core.column.column_empty(0, _str_dtype)),
(
EDGETYPE,
cudf.core.column.column_empty(
0,
"str" if not categorical_metadata else _empty_cat_dt(),
_str_dtype
if not categorical_metadata
else _empty_cat_dt(),
),
),
]
Expand All @@ -447,7 +454,9 @@ def _create_hyper_edges(
CATEGORY,
cudf.core.column.column_empty(
0,
"str" if not categorical_metadata else _empty_cat_dt(),
_str_dtype
if not categorical_metadata
else _empty_cat_dt(),
),
)
]
Expand Down Expand Up @@ -523,14 +532,16 @@ def _create_direct_edges(
dict(
(
[
(EVENTID, cudf.core.column.column_empty(0, "str")),
(SOURCE, cudf.core.column.column_empty(0, "str")),
(TARGET, cudf.core.column.column_empty(0, "str")),
(EVENTID, cudf.core.column.column_empty(0, _str_dtype)),
(SOURCE, cudf.core.column.column_empty(0, _str_dtype)),
(TARGET, cudf.core.column.column_empty(0, _str_dtype)),
(
EDGETYPE,
cudf.core.column.column_empty(
0,
"str" if not categorical_metadata else _empty_cat_dt(),
_str_dtype
if not categorical_metadata
else _empty_cat_dt(),
),
),
]
Expand All @@ -543,7 +554,9 @@ def _create_direct_edges(
CATEGORY,
cudf.core.column.column_empty(
0,
"str" if not categorical_metadata else _empty_cat_dt(),
_str_dtype
if not categorical_metadata
else _empty_cat_dt(),
),
)
]
Expand Down Expand Up @@ -611,7 +624,8 @@ def _str_scalar_to_category(size, val):
data=None,
size=size,
dtype=cudf.CategoricalDtype(
categories=cudf.core.column.as_column([val], dtype="str"), ordered=False
categories=cudf.core.column.as_column([val], dtype=_str_dtype),
ordered=False,
),
mask=None,
offset=0,
Expand All @@ -626,4 +640,6 @@ def _prepend_str(col, val):

# Make an empty categorical string dtype
def _empty_cat_dt():
return cudf.CategoricalDtype(categories=np.array([], dtype="str"), ordered=False)
return cudf.CategoricalDtype(
categories=np.array([], dtype=_str_dtype), ordered=False
)

0 comments on commit 4a89590

Please sign in to comment.