From f202fa3924cd2c4617b074e6dfa9f0a158b8ccb7 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:57:18 -1000 Subject: [PATCH 1/2] Use public pandas and cudf APIs where possible (#4218) Avoiding `core` imports here as they tend to be "private" Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4218 --- python/cugraph/cugraph/structure/graph_classes.py | 6 +++--- python/cugraph/cugraph/structure/hypergraph.py | 6 ++---- python/cugraph/cugraph/tests/utils/test_dataset.py | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/python/cugraph/cugraph/structure/graph_classes.py b/python/cugraph/cugraph/structure/graph_classes.py index 03efcba0307..f48895c90b9 100644 --- a/python/cugraph/cugraph/structure/graph_classes.py +++ b/python/cugraph/cugraph/structure/graph_classes.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, 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 @@ -426,7 +426,7 @@ def from_pandas_edgelist( ... edge_attr='2', renumber=False) """ - if not isinstance(pdf, pd.core.frame.DataFrame): + if not isinstance(pdf, pd.DataFrame): raise TypeError("pdf input is not a Pandas DataFrame") gdf = cudf.DataFrame.from_pandas(pdf) @@ -450,7 +450,7 @@ def from_pandas_adjacency(self, pdf): pdf : pandas.DataFrame A DataFrame that contains adjacency information """ - if not isinstance(pdf, pd.core.frame.DataFrame): + if not isinstance(pdf, pd.DataFrame): raise TypeError("pdf input is not a Pandas DataFrame") np_array = pdf.to_numpy() diff --git a/python/cugraph/cugraph/structure/hypergraph.py b/python/cugraph/cugraph/structure/hypergraph.py index 4add74d6061..add68cb6dac 100644 --- a/python/cugraph/cugraph/structure/hypergraph.py +++ b/python/cugraph/cugraph/structure/hypergraph.py @@ -185,7 +185,7 @@ def hypergraph( events.reset_index(drop=True, inplace=True) if EVENTID not in events.columns: - events[EVENTID] = cudf.core.index.RangeIndex(len(events)) + events[EVENTID] = cudf.RangeIndex(len(events)) events[EVENTID] = _prepend_str(events[EVENTID], EVENTID + DELIM) events[NODETYPE] = ( @@ -596,6 +596,4 @@ def _prepend_str(col, val): # Make an empty categorical string dtype def _empty_cat_dt(): - return cudf.core.dtypes.CategoricalDtype( - categories=np.array([], dtype="str"), ordered=False - ) + return cudf.CategoricalDtype(categories=np.array([], dtype="str"), ordered=False) diff --git a/python/cugraph/cugraph/tests/utils/test_dataset.py b/python/cugraph/cugraph/tests/utils/test_dataset.py index 39f7ed8850b..9331cefcfda 100644 --- a/python/cugraph/cugraph/tests/utils/test_dataset.py +++ b/python/cugraph/cugraph/tests/utils/test_dataset.py @@ -171,14 +171,14 @@ def test_reader(dataset): E = dataset.get_edgelist(download=True) assert E is not None - assert isinstance(E, cudf.core.dataframe.DataFrame) + assert isinstance(E, cudf.DataFrame) dataset.unload() # using pandas E_pd = dataset.get_edgelist(download=True, reader="pandas") assert E_pd is not None - assert isinstance(E_pd, pandas.core.frame.DataFrame) + assert isinstance(E_pd, pandas.DataFrame) dataset.unload() with pytest.raises(ValueError): From ab9e4454231c2486e089374affcdd037264ec37e Mon Sep 17 00:00:00 2001 From: Seunghwa Kang <45857425+seunghwak@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:07:33 -0800 Subject: [PATCH 2/2] transform_e bug fix in edge masking (#4221) Bug fix. Authors: - Seunghwa Kang (https://github.com/seunghwak) - Ralph Liu (https://github.com/nv-rliu) Approvers: - Chuck Hastings (https://github.com/ChuckHastings) - Naim (https://github.com/naimnv) URL: https://github.com/rapidsai/cugraph/pull/4221 --- cpp/src/prims/transform_e.cuh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/src/prims/transform_e.cuh b/cpp/src/prims/transform_e.cuh index a34a5a04b49..2cb1a5358b0 100644 --- a/cpp/src/prims/transform_e.cuh +++ b/cpp/src/prims/transform_e.cuh @@ -85,7 +85,7 @@ __global__ void transform_e_packed_bool( if (local_edge_idx < num_edges) { bool compute_predicate = true; if constexpr (check_edge_mask) { - compute_predicate = (edge_mask & packed_bool_mask(lane_id) != packed_bool_empty_mask()); + compute_predicate = ((edge_mask & packed_bool_mask(lane_id)) != packed_bool_empty_mask()); } if (compute_predicate) { @@ -111,10 +111,10 @@ __global__ void transform_e_packed_bool( uint32_t new_val = __ballot_sync(raft::warp_full_mask(), predicate); if (lane_id == 0) { if constexpr (check_edge_mask) { - *(edge_partition_e_value_output.value_first() + idx) = new_val; - } else { auto old_val = *(edge_partition_e_value_output.value_first() + idx); *(edge_partition_e_value_output.value_first() + idx) = (old_val & ~edge_mask) | new_val; + } else { + *(edge_partition_e_value_output.value_first() + idx) = new_val; } } @@ -196,6 +196,9 @@ struct update_e_value_t { __device__ void operator()(typename GraphViewType::edge_type i) const { + if constexpr (check_edge_mask) { + if (!edge_partition_e_mask.get(i)) { return; } + } auto major_idx = edge_partition.major_idx_from_local_edge_idx_nocheck(i); auto major = edge_partition.major_from_major_idx_nocheck(major_idx); auto major_offset = edge_partition.major_offset_from_major_nocheck(major);