Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/branch-24.12' into branch-24.1…
Browse files Browse the repository at this point in the history
…2_remove-edge-renumber-map
  • Loading branch information
jnke2016 committed Nov 27, 2024
2 parents 529955a + 1f1cace commit c3a58a0
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 113 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ repos:
meta[.]yaml$|
setup[.]cfg$
- id: verify-alpha-spec
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
- id: sphinx-lint
args: ["--enable=all", "--disable=line-too-long"]
- repo: https://github.com/rapidsai/dependency-file-generator
rev: v1.16.0
hooks:
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@

</div>

-----
## News

___NEW!___ _[nx-cugraph](https://rapids.ai/nx-cugraph/)_, a NetworkX backend that provides GPU acceleration to NetworkX with zero code change.
```
> pip install nx-cugraph-cu11 --extra-index-url https://pypi.nvidia.com
> export NETWORKX_AUTOMATIC_BACKENDS=cugraph
```
That's it. NetworkX now leverages cuGraph for accelerated graph algorithms.

-----

## Table of contents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,6 @@ rmm::device_uvector<edge_t> compute_uniform_sampling_index_without_replacement(
raft::random::RngState& rng_state,
size_t K)
{
assert(cugraph::invalid_edge_id_v<edge_t> == cugraph::ops::graph::INVALID_ID<edge_t>);

edge_t mid_partition_degree_range_last = static_cast<edge_t>(K * 10); // tuning parameter
assert(mid_partition_degree_range_last > K);
size_t high_partition_oversampling_K = K * 2; // tuning parameter
Expand Down Expand Up @@ -1567,10 +1565,7 @@ uniform_sample_and_compute_local_nbr_indices(
size_t K,
bool with_replacement)
{
using edge_t = typename GraphViewType::edge_type;

assert(cugraph::invalid_edge_id_v<edge_t> == cugraph::ops::graph::INVALID_ID<edge_t>);

using edge_t = typename GraphViewType::edge_type;
using vertex_t = typename GraphViewType::vertex_type;
using key_t = typename thrust::iterator_traits<KeyIterator>::value_type;

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/sampling/neighbor_sampling_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ neighbor_sample_impl(raft::handle_t const& handle,
std::vector<size_t> level_sizes{};
std::vector<size_t> level_sizes_edge_types{};

for (auto hop = 0; hop < num_hops; hop++) {
for (size_t hop = 0; hop < num_hops; ++hop) {
for (auto edge_type_id = 0; edge_type_id < num_edge_types; edge_type_id++) {
auto k_level = fan_out[(hop * num_edge_types) + edge_type_id];
rmm::device_uvector<vertex_t> srcs(0, handle.get_stream());
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/community/balanced_edge_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>

TEST(balanced_edge, DISABLED_success)
TEST(balanced_edge, success)
{
std::vector<int> off_h = {0, 16, 25, 35, 41, 44, 48, 52, 56, 61, 63, 66,
67, 69, 74, 76, 78, 80, 82, 84, 87, 89, 91, 93,
Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/api_docs/cugraph-ops/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cugraph-ops API reference
=========================

This page provides a list of all publicly accessible modules, methods and classes through `pylibcugraphops.*` namespace.
This page provides a list of all publicly accessible modules, methods and classes through ``pylibcugraphops.*`` namespace.

.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/api_docs/cugraph-ops/python/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cugraph-ops Python API reference
================================

This page provides a list of all publicly accessible modules, methods and classes through `pylibcugraphops.*` namespace.
This page provides a list of all publicly accessible modules, methods and classes through ``pylibcugraphops.*`` namespace.

.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/nx_cugraph/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ While NetworkX is a pure-Python implementation, backends may be written to use o

## Enabling nx-cugraph

It is recommended to use `networkx>=3.4` for optimal zero code change performance, but `nx-cugraph` will also work with `networkx 3.0+`.
It is recommended to use `networkx>=3.4` for optimal zero code change performance, but `nx-cugraph` will also work with `networkx 3.2+`.

NetworkX will use `nx-cugraph` as the backend if any of the following are used:

Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/nx_cugraph/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Users can have GPU-based, large-scale performance **without** changing their fam
+--------------------------------------------------------------------------------------------------------+
| **Run the same code on CPU or GPU** |
| |
| Nothing changes, not even your `import` statements, when going from CPU to GPU. |
| Nothing changes, not even your ``import`` statements, when going from CPU to GPU. |
+--------------------------------------------------------------------------------------------------------+


Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/nx_cugraph/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This guide describes how to install ``nx-cugraph`` and use it in your workflows.
- **Volta architecture or later NVIDIA GPU, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+**
- **[CUDA](https://docs.nvidia.com/cuda/index.html) 11.2, 11.4, 11.5, 11.8, 12.0, 12.2, or 12.5**
- **Python >= 3.10**
- **[NetworkX](https://networkx.org/documentation/stable/install.html#) >= 3.0 (version 3.4 or higher recommended)**
- **[NetworkX](https://networkx.org/documentation/stable/install.html#) >= 3.2 (version 3.4 or higher recommended)**

More details about system requirements can be found in the [RAPIDS System Requirements Documentation](https://docs.rapids.ai/install#system-req).

Expand Down
2 changes: 1 addition & 1 deletion docs/cugraph/source/nx_cugraph/supported-algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Algorithms
+---------------------------------------+

+---------------------------+
| **Traversal** |
| **Traversal** |
+===========================+
| bfs_edges |
+---------------------------+
Expand Down
4 changes: 2 additions & 2 deletions docs/cugraph/source/tutorials/cugraph_blogs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ Academic Papers

* Alex Fender, Brad Rees, Joe Eaton (2022) `Massive Graph Analytics <https://books.google.com/books?hl=en&lr=&id=QspxEAAAQBAJ&oi=fnd&pg=PT8&dq=book:%22Massive+Graph+Analytics%22&ots=3HAGJ0njKO&sig=8e4v0azmzA6LTQNUNgPw-uTLkoc#v=onepage&q&f=false>`_ Bader, D. (Editor) CRC Press

* S Kang, A. Fender, J. Eaton, B. Rees:`Computing PageRank Scores of Web Crawl Data Using DGX A100 Clusters`. In IEEE HPEC, Sep. 2020
* S Kang, A. Fender, J. Eaton, B. Rees. `Computing PageRank Scores of Web Crawl Data Using DGX A100 Clusters <https://ieeexplore.ieee.org/abstract/document/9286216>`_. In IEEE HPEC, Sep. 2020

* Hricik, T., Bader, D., & Green, O. (2020, September). `Using RAPIDS AI to accelerate graph data science workflows`. In 2020 IEEE High Performance Extreme Computing Conference (HPEC) (pp. 1-4). IEEE.
* Hricik, T., Bader, D., & Green, O. (2020, September). `Using RAPIDS AI to accelerate graph data science workflows <https://ieeexplore.ieee.org/abstract/document/9286224>`_. In 2020 IEEE High Performance Extreme Computing Conference (HPEC) (pp. 1-4). IEEE.

* Richardson, B., Rees, B., Drabas, T., Oldridge, E., Bader, D. A., & Allen, R. (2020, August). Accelerating and Expanding End-to-End Data Science Workflows with DL/ML Interoperability Using RAPIDS. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (pp. 3503-3504).

Expand Down
41 changes: 24 additions & 17 deletions python/cugraph/cugraph/cores/core_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,27 @@
def core_number(G, degree_type="bidirectional"):
"""
Compute the core numbers for the nodes of the graph G. A k-core of a graph
is a maximal subgraph that contains nodes of degree k or more.
A node has a core number of k if it belongs a k-core but not to k+1-core.
This call does not support a graph with self-loops and parallel
edges.
is a maximal subgraph that contains nodes of degree k or more. A node has
a core number of k if it belongs to a k-core but not to k+1-core. This
call does not support a graph with self-loops and parallel edges.
Parameters
----------
G : cuGraph.Graph or networkx.Graph
The graph should contain undirected edges where undirected edges are
represented as directed edges in both directions. While this graph
can contain edge weights, they don't participate in the calculation
The current implementation only supports undirected graphs. The graph
can contain edge weights, but they don't participate in the calculation
of the core numbers.
The current implementation only supports undirected graphs.
.. deprecated:: 24.12
Accepting a ``networkx.Graph`` is deprecated and will be removed in a
future version. For ``networkx.Graph`` use networkx directly with
the ``nx-cugraph`` backend. See: https://rapids.ai/nx-cugraph/
degree_type: str, (default="bidirectional")
This option determines if the core number computation should be based
on input, output, or both directed edges, with valid values being
"incoming", "outgoing", and "bidirectional" respectively.
This option is currently ignored. This option may eventually determine
if the core number computation should be based on input, output, or
both directed edges, with valid values being "incoming", "outgoing",
and "bidirectional" respectively.
Returns
-------
Expand All @@ -63,19 +61,28 @@ def core_number(G, degree_type="bidirectional"):
>>> from cugraph.datasets import karate
>>> G = karate.get_graph(download=True)
>>> df = cugraph.core_number(G)
>>> df.head()
vertex core_number
0 33 4
1 0 4
2 32 4
3 2 4
4 1 4
"""

G, isNx = ensure_cugraph_obj_for_nx(G)

if G.is_directed():
raise ValueError("input graph must be undirected")

if degree_type not in ["incoming", "outgoing", "bidirectional"]:
raise ValueError(
f"'degree_type' must be either incoming, "
f"outgoing or bidirectional, got: {degree_type}"
)
# degree_type is currently ignored until libcugraph supports directed
# graphs for core_number. Once supporteed, degree_type should be checked
# like so:
# if degree_type not in ["incoming", "outgoing", "bidirectional"]:
# raise ValueError(
# f"'degree_type' must be either incoming, "
# f"outgoing or bidirectional, got: {degree_type}"
# )

vertex, core_number = pylibcugraph_core_number(
resource_handle=ResourceHandle(),
Expand Down
29 changes: 16 additions & 13 deletions python/cugraph/cugraph/dask/cores/core_number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-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.
Expand Down Expand Up @@ -53,15 +53,15 @@ def core_number(input_graph, degree_type="bidirectional"):
Parameters
----------
input_graph : cugraph.graph
cuGraph graph descriptor, should contain the connectivity information,
(edge weights are not used in this algorithm).
The current implementation only supports undirected graphs.
The current implementation only supports undirected graphs. The graph
can contain edge weights, but they don't participate in the calculation
of the core numbers.
degree_type: str, (default="bidirectional")
This option determines if the core number computation should be based
on input, output, or both directed edges, with valid values being
"incoming", "outgoing", and "bidirectional" respectively.
This option is currently ignored. This option may eventually determine
if the core number computation should be based on input, output, or
both directed edges, with valid values being "incoming", "outgoing",
and "bidirectional" respectively.
Returns
-------
Expand All @@ -77,11 +77,14 @@ def core_number(input_graph, degree_type="bidirectional"):
if input_graph.is_directed():
raise ValueError("input graph must be undirected")

if degree_type not in ["incoming", "outgoing", "bidirectional"]:
raise ValueError(
f"'degree_type' must be either incoming, "
f"outgoing or bidirectional, got: {degree_type}"
)
# degree_type is currently ignored until libcugraph supports directed
# graphs for core_number. Once supporteed, degree_type should be checked
# like so:
# if degree_type not in ["incoming", "outgoing", "bidirectional"]:
# raise ValueError(
# f"'degree_type' must be either incoming, "
# f"outgoing or bidirectional, got: {degree_type}"
# )

# Initialize dask client
client = default_client()
Expand Down
4 changes: 3 additions & 1 deletion python/cugraph/cugraph/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ def get_dask_graph(
If True, stores the transpose of the adjacency matrix. Required
for certain algorithms.
"""
if self._edgelist is None:
if self._edgelist is None or not isinstance(
self._edgelist, dask_cudf.DataFrame
):
self.get_dask_edgelist(download=download)

if create_using is None:
Expand Down
24 changes: 13 additions & 11 deletions python/cugraph/cugraph/tests/core/test_core_number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-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
Expand Down Expand Up @@ -32,11 +32,15 @@ def setup_function():
# =============================================================================
# Pytest fixtures
# =============================================================================
degree_type = ["incoming", "outgoing"]
# FIXME: degree_type is currently unsupported (ignored)
# degree_type = ["incoming", "outgoing"]

# fixture_params = gen_fixture_params_product(
# (UNDIRECTED_DATASETS, "graph_file"),
# (degree_type, "degree_type"),
# )
fixture_params = gen_fixture_params_product(
(UNDIRECTED_DATASETS, "graph_file"),
(degree_type, "degree_type"),
)


Expand All @@ -46,7 +50,9 @@ def input_combo(request):
This fixture returns a dictionary containing all input params required to
run a Core number algo
"""
parameters = dict(zip(("graph_file", "degree_type"), request.param))
# FIXME: degree_type is not supported so do not test with different values
# parameters = dict(zip(("graph_file", "degree_type"), request.param))
parameters = {"graph_file": request.param[0]}

graph_file = parameters["graph_file"]
G = graph_file.get_graph()
Expand All @@ -69,7 +75,8 @@ def input_combo(request):
def test_core_number(input_combo):
G = input_combo["G"]
Gnx = input_combo["Gnx"]
degree_type = input_combo["degree_type"]
# FIXME: degree_type is currently unsupported (ignored)
# degree_type = input_combo["degree_type"]
nx_core_number_results = cudf.DataFrame()

dic_results = nx.core_number(Gnx)
Expand All @@ -80,7 +87,7 @@ def test_core_number(input_combo):
)

core_number_results = (
cugraph.core_number(G, degree_type)
cugraph.core_number(G)
.sort_values("vertex")
.reset_index(drop=True)
.rename(columns={"core_number": "cugraph_core_number"})
Expand Down Expand Up @@ -109,8 +116,3 @@ def test_core_number_invalid_input(input_combo):

with pytest.raises(ValueError):
cugraph.core_number(G)

invalid_degree_type = "invalid"
G = input_combo["G"]
with pytest.raises(ValueError):
cugraph.core_number(G, invalid_degree_type)
Loading

0 comments on commit c3a58a0

Please sign in to comment.