rapidsai / cugraph

cuGraph - RAPIDS Graph Analytics Library
https://docs.rapids.ai/api/cugraph/stable/
Apache License 2.0
1.77k stars 304 forks source link

[BUG]: Nx-cuGraph caching not working with documentation example #4466

Closed beckernick closed 5 months ago

beckernick commented 6 months ago

Version

24.06

Which installation method(s) does this occur on?

Conda

Describe the bug.

When I ran the documentation example multiple times, I expected performance to be significantly better the second time with caching enabled. Instead, performance was the same and the CPU to GPU conversion was happening every time.

Minimum reproducible example

%env NETWORKX_BACKEND_PRIORITY=cugraph
%env CACHE_CONVERTED_GRAPH=True

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")
env: NETWORKX_BACKEND_PRIORITY=cugraph
env: CACHE_CONVERTED_GRAPH=True

%time result = nx.betweenness_centrality(G, k=10)
CPU times: user 18.1 s, sys: 1.69 s, total: 19.8 s
Wall time: 20.7 s

%time result = nx.betweenness_centrality(G, k=10)
CPU times: user 19.6 s, sys: 859 ms, total: 20.4 s
Wall time: 20.6 s
%%snakeviz

result = nx.betweenness_centrality(G, k=10)
Screenshot 2024-06-05 at 5 36 54 PM

Relevant log output

No response

Environment details

!conda list | grep "cugraph\|networkx"

cugraph                   24.06.00a94     cuda12_py310_240604_g1667f7a43_94    rapidsai-nightly
libcugraph                24.06.00a94     cuda12_240604_g1667f7a43_94    rapidsai-nightly
libcugraph_etl            24.06.00a94     cuda12_240604_g1667f7a43_94    rapidsai-nightly
libcugraphops             24.06.00a24     cuda12_240603_gac69d0a6_24    rapidsai-nightly
networkx                  3.3                pyhd8ed1ab_1    conda-forge
nx-cugraph                24.06.00a94            py310_94    rapidsai-nightly
pylibcugraph              24.06.00a94     cuda12_py310_240604_g1667f7a43_94    rapidsai-nightly

Other/Misc.

No response

Code of Conduct

beckernick commented 6 months ago

It looks like our docs are wrong (screenshot below). We should be using NETWORKX_CACHE_CONVERTED_GRAPHS not CACHE_CONVERTED_GRAPH to configure caching behavior.

Screenshot 2024-06-05 at 6 22 25 PM
rlratzel commented 5 months ago

Thanks @beckernick for finding this. I've submitted this PR to fix those docs.