Skip to content

Commit

Permalink
Merge branch 'pyg-dist' of https://github.com/alexbarghi-nv/cugraph i…
Browse files Browse the repository at this point in the history
…nto pyg-dist
  • Loading branch information
alexbarghi-nv committed May 29, 2024
2 parents 0551718 + 94cc6d1 commit 0cb3d27
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 129 deletions.
12 changes: 11 additions & 1 deletion ci/test_wheel_cugraph-dgl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,18 @@ fi
PYTORCH_URL="https://download.pytorch.org/whl/cu${PYTORCH_CUDA_VER}"
DGL_URL="https://data.dgl.ai/wheels/cu${PYTORCH_CUDA_VER}/repo.html"

# Starting from 2.2, PyTorch wheels depend on nvidia-nccl-cuxx>=2.19 wheel and
# dynamically link to NCCL. RAPIDS CUDA 11 CI images have an older NCCL version that
# might shadow the newer NCCL required by PyTorch during import (when importing
# `cupy` before `torch`).
if [[ "${NCCL_VERSION}" < "2.19" ]]; then
PYTORCH_VER="2.1.0"
else
PYTORCH_VER="2.3.0"
fi

rapids-logger "Installing PyTorch and DGL"
rapids-retry python -m pip install torch --index-url ${PYTORCH_URL}
rapids-retry python -m pip install "torch==${PYTORCH_VER}" --index-url ${PYTORCH_URL}
rapids-retry python -m pip install dgl==2.0.0 --find-links ${DGL_URL}

python -m pytest python/cugraph-dgl/tests
159 changes: 31 additions & 128 deletions docs/cugraph/source/nx_cugraph/nx_cugraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,142 +24,45 @@ Each chart has three measurements.
![Single Source Shortest Path](../images/sssp.png)
![Weakly Connected Components](../images/wcc.png)

### Command line example
Open bc_demo.ipy and paste the code below.

The following algorithms are supported and automatically dispatched to nx-cuGraph for acceleration.
```
import pandas as pd
import networkx as nx
url = "https://data.rapids.ai/cugraph/datasets/cit-Patents.csv"
df = pd.read_csv(url, sep=" ", names=["src", "dst"], dtype="int32")
G = nx.from_pandas_edgelist(df, source="src", target="dst")
#### Algorithms
%time result = nx.betweenness_centrality(G, k=10)
```
Run the command:
```
bipartite
├─ basic
│ └─ is_bipartite
└─ generators
└─ complete_bipartite_graph
centrality
├─ betweenness
│ ├─ betweenness_centrality
│ └─ edge_betweenness_centrality
├─ degree_alg
│ ├─ degree_centrality
│ ├─ in_degree_centrality
│ └─ out_degree_centrality
├─ eigenvector
│ └─ eigenvector_centrality
└─ katz
└─ katz_centrality
cluster
├─ average_clustering
├─ clustering
├─ transitivity
└─ triangles
community
└─ louvain
└─ louvain_communities
components
├─ connected
│ ├─ connected_components
│ ├─ is_connected
│ ├─ node_connected_component
│ └─ number_connected_components
└─ weakly_connected
├─ is_weakly_connected
├─ number_weakly_connected_components
└─ weakly_connected_components
core
├─ core_number
└─ k_truss
dag
├─ ancestors
└─ descendants
isolate
├─ is_isolate
├─ isolates
└─ number_of_isolates
link_analysis
├─ hits_alg
│ └─ hits
└─ pagerank_alg
└─ pagerank
operators
└─ unary
├─ complement
└─ reverse
reciprocity
├─ overall_reciprocity
└─ reciprocity
shortest_paths
└─ unweighted
├─ single_source_shortest_path_length
└─ single_target_shortest_path_length
traversal
└─ breadth_first_search
├─ bfs_edges
├─ bfs_layers
├─ bfs_predecessors
├─ bfs_successors
├─ bfs_tree
├─ descendants_at_distance
└─ generic_bfs_edges
tree
└─ recognition
├─ is_arborescence
├─ is_branching
├─ is_forest
└─ is_tree
user@machine:/# ipython bc_demo.ipy
```

#### Generators
You will observe a run time of approximately 7 minutes...more or less depending on your cpu.

Run the command again, this time specifiying cugraph as the NetworkX backend of choice.
```
user@machine:/# NETWORKX_BACKEND_PRIORITY=cugraph ipython bc_demo.ipy
```
classic
├─ barbell_graph
├─ circular_ladder_graph
├─ complete_graph
├─ complete_multipartite_graph
├─ cycle_graph
├─ empty_graph
├─ ladder_graph
├─ lollipop_graph
├─ null_graph
├─ path_graph
├─ star_graph
├─ tadpole_graph
├─ trivial_graph
├─ turan_graph
└─ wheel_graph
community
└─ caveman_graph
small
├─ bull_graph
├─ chvatal_graph
├─ cubical_graph
├─ desargues_graph
├─ diamond_graph
├─ dodecahedral_graph
├─ frucht_graph
├─ heawood_graph
├─ house_graph
├─ house_x_graph
├─ icosahedral_graph
├─ krackhardt_kite_graph
├─ moebius_kantor_graph
├─ octahedral_graph
├─ pappus_graph
├─ petersen_graph
├─ sedgewick_maze_graph
├─ tetrahedral_graph
├─ truncated_cube_graph
├─ truncated_tetrahedron_graph
└─ tutte_graph
social
├─ davis_southern_women_graph
├─ florentine_families_graph
├─ karate_club_graph
└─ les_miserables_graph
This run will be much faster, typically around 20 seconds depending on your GPU.
```
user@machine:/# NETWORKX_BACKEND_PRIORITY=cugraph ipython bc_demo.ipy
```
There is also an option to add caching. This will dramatically help performance when running multiple algorithms on the same graph.
```
NETWORKX_BACKEND_PRIORITY=cugraph CACHE_CONVERTED_GRAPH=True ipython bc_demo.ipy
```

#### Other
When running Python interactively, cugraph backend can be specified as an argument in the algorithm call.

For example:
```
convert_matrix
├─ from_pandas_edgelist
└─ from_scipy_sparse_array
nx.betweenness_centrality(cit_patents_graph, k=k, backend="cugraph")
```


The latest list of algorithms that can be dispatched to nx-cuGraph for acceleration is found [here](https://github.com/rapidsai/cugraph/blob/main/python/nx-cugraph/README.md#algorithms).
Loading

0 comments on commit 0cb3d27

Please sign in to comment.