Skip to content

Commit

Permalink
Removes unused benchmark infra: rapids-pytest-benchmark and asvdb
Browse files Browse the repository at this point in the history
  • Loading branch information
rlratzel committed Jan 14, 2025
1 parent 6b5db94 commit 674a699
Show file tree
Hide file tree
Showing 23 changed files with 128 additions and 403 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-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 All @@ -22,10 +22,6 @@
import numpy as np
import cupy as cp

# Facing issues with rapids-pytest-benchmark plugin
# pytest-benchmark.
import pytest_benchmark

from cugraph.generators import rmat
from cugraph.experimental import datasets
from cugraph_benchmarking import params
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-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 All @@ -18,18 +18,6 @@
import pytest
import numpy as np

# If the rapids-pytest-benchmark plugin is installed, the "gpubenchmark"
# fixture will be available automatically. Check that this fixture is available
# by trying to import rapids_pytest_benchmark, and if that fails, set
# "gpubenchmark" to the standard "benchmark" fixture provided by
# pytest-benchmark.
try:
import rapids_pytest_benchmark # noqa: F401
except ImportError:
import pytest_benchmark

gpubenchmark = pytest_benchmark.plugin.benchmark

from cugraph_service_client import CugraphServiceClient
from cugraph_service_client.exceptions import CugraphServiceError
from cugraph_service_client import RemoteGraph
Expand Down Expand Up @@ -178,7 +166,7 @@ def remote_graph_objs(request):
"with_replacement", [False], ids=lambda v: f"with_replacement={v}"
)
def bench_cgs_uniform_neighbor_sample(
gpubenchmark, remote_graph_objs, batch_size, fanout, with_replacement
benchmark, remote_graph_objs, batch_size, fanout, with_replacement
):
(G, num_verts, uniform_neighbor_sample_func) = remote_graph_objs

Expand All @@ -188,7 +176,7 @@ def bench_cgs_uniform_neighbor_sample(
)
# print(f"\n{uns_args}")
# FIXME: uniform_neighbor_sample cannot take a np.ndarray for start_list
result = gpubenchmark(
result = benchmark(
uniform_neighbor_sample_func,
G,
start_list=uns_args["start_list"],
Expand Down
10 changes: 3 additions & 7 deletions benchmarks/cugraph/pytest-based/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ directory under the root of the `cuGraph` source tree.
* cugraph built and installed (or `cugraph` sources and built C++ extensions
available on `PYTHONPATH`)

* rapids-pytest-benchmark pytest plugin (`conda install -c rapidsai
rapids-pytest-benchmark`)

* The benchmark datasets downloaded and installed in <cugraph>/datasets. Run the
script below from the <cugraph>/datasets directory:
```
Expand All @@ -25,8 +22,7 @@ cd <cugraph>/datasets

## Usage (Python)
### Python
* Run `pytest --help` (with the rapids-pytest-benchmark plugin installed) for
the full list of options
* Run `pytest --help` for the full list of options

* See also the `pytest.ini` file in this directory for examples of how to enable
options by default and define marks
Expand All @@ -44,9 +40,9 @@ _**NOTE: these commands must be run from the `<cugraph_root>/benchmarks` directo
(rapids) user@machine:/cugraph/benchmarks> pytest -x
```

* Run all the benchmarks but do not reinit RMM with different configurations
* Run all the benchmarks and allow RMM to reinit with different configurations
```
(rapids) user@machine:/cugraph/benchmarks> pytest --no-rmm-reinit
(rapids) user@machine:/cugraph/benchmarks> pytest --allow-rmm-reinit
```

* Show what benchmarks would be run with the given options, but do not run them
Expand Down
99 changes: 40 additions & 59 deletions benchmarks/cugraph/pytest-based/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@

import pytest
import numpy as np
import pytest_benchmark

# FIXME: Remove this when rapids_pytest_benchmark.gpubenchmark is available
# everywhere
try:
from rapids_pytest_benchmark import setFixtureParamNames
except ImportError:
print(
"\n\nWARNING: rapids_pytest_benchmark is not installed, "
"falling back to pytest_benchmark fixtures.\n"
)

# if rapids_pytest_benchmark is not available, just perfrom time-only
# benchmarking and replace the util functions with nops
gpubenchmark = pytest_benchmark.plugin.benchmark

def setFixtureParamNames(*args, **kwargs):
pass


import rmm
import dask_cudf
Expand Down Expand Up @@ -283,8 +264,8 @@ def get_vertex_pairs(G, num_vertices=10):

###############################################################################
# Benchmarks
def bench_create_graph(gpubenchmark, edgelist):
gpubenchmark(
def bench_create_graph(benchmark, edgelist):
benchmark(
cugraph.from_cudf_edgelist,
edgelist,
source="src",
Expand All @@ -298,8 +279,8 @@ def bench_create_graph(gpubenchmark, edgelist):
# results in thousands of rounds before the default threshold is met, so lower
# the max_time for this benchmark.
@pytest.mark.benchmark(warmup=True, warmup_iterations=10, max_time=0.005)
def bench_create_digraph(gpubenchmark, edgelist):
gpubenchmark(
def bench_create_digraph(benchmark, edgelist):
benchmark(
cugraph.from_cudf_edgelist,
edgelist,
source="src",
Expand All @@ -309,26 +290,26 @@ def bench_create_digraph(gpubenchmark, edgelist):
)


def bench_renumber(gpubenchmark, edgelist):
gpubenchmark(NumberMap.renumber, edgelist, "src", "dst")
def bench_renumber(benchmark, edgelist):
benchmark(NumberMap.renumber, edgelist, "src", "dst")


def bench_pagerank(gpubenchmark, transposed_graph):
def bench_pagerank(benchmark, transposed_graph):
pagerank = (
dask_cugraph.pagerank
if is_graph_distributed(transposed_graph)
else cugraph.pagerank
)
gpubenchmark(pagerank, transposed_graph)
benchmark(pagerank, transposed_graph)


def bench_bfs(gpubenchmark, graph):
def bench_bfs(benchmark, graph):
bfs = dask_cugraph.bfs if is_graph_distributed(graph) else cugraph.bfs
start = graph.edgelist.edgelist_df["src"][0]
gpubenchmark(bfs, graph, start)
benchmark(bfs, graph, start)


def bench_sssp(gpubenchmark, graph):
def bench_sssp(benchmark, graph):
if not graph.is_weighted():
pytest.skip("Skipping: Unweighted Graphs are not supported by SSSP")

Expand All @@ -340,102 +321,102 @@ def bench_sssp(gpubenchmark, graph):

start = start_col.to_arrow().to_pylist()[0]

gpubenchmark(sssp, graph, start)
benchmark(sssp, graph, start)


def bench_jaccard(gpubenchmark, unweighted_graph):
def bench_jaccard(benchmark, unweighted_graph):
G = unweighted_graph
# algo cannot compute neighbors on all nodes without running into OOM
# this is why we will call jaccard on a subset of nodes
vert_pairs = get_vertex_pairs(G)
jaccard = dask_cugraph.jaccard if is_graph_distributed(G) else cugraph.jaccard
gpubenchmark(jaccard, G, vert_pairs)
benchmark(jaccard, G, vert_pairs)


def bench_sorensen(gpubenchmark, unweighted_graph):
def bench_sorensen(benchmark, unweighted_graph):
G = unweighted_graph
# algo cannot compute neighbors on all nodes without running into OOM
# this is why we will call sorensen on a subset of nodes
vert_pairs = get_vertex_pairs(G)
sorensen = dask_cugraph.sorensen if is_graph_distributed(G) else cugraph.sorensen
gpubenchmark(sorensen, G, vert_pairs)
benchmark(sorensen, G, vert_pairs)


def bench_louvain(gpubenchmark, graph):
def bench_louvain(benchmark, graph):
louvain = dask_cugraph.louvain if is_graph_distributed(graph) else cugraph.louvain
gpubenchmark(louvain, graph)
benchmark(louvain, graph)


def bench_weakly_connected_components(gpubenchmark, graph):
def bench_weakly_connected_components(benchmark, graph):
if is_graph_distributed(graph):
pytest.skip("distributed graphs are not supported")
if graph.is_directed():
G = graph.to_undirected()
else:
G = graph
gpubenchmark(cugraph.weakly_connected_components, G)
benchmark(cugraph.weakly_connected_components, G)


def bench_overlap(gpubenchmark, unweighted_graph):
def bench_overlap(benchmark, unweighted_graph):
G = unweighted_graph
# algo cannot compute neighbors on all nodes without running into OOM
# this is why we will call sorensen on a subset of nodes
vertex_pairs = get_vertex_pairs(G)
overlap = dask_cugraph.overlap if is_graph_distributed(G) else cugraph.overlap
gpubenchmark(overlap, G, vertex_pairs)
benchmark(overlap, G, vertex_pairs)


def bench_triangle_count(gpubenchmark, graph):
def bench_triangle_count(benchmark, graph):
tc = (
dask_cugraph.triangle_count
if is_graph_distributed(graph)
else cugraph.triangle_count
)
gpubenchmark(tc, graph)
benchmark(tc, graph)


def bench_spectralBalancedCutClustering(gpubenchmark, graph):
def bench_spectralBalancedCutClustering(benchmark, graph):
if is_graph_distributed(graph):
pytest.skip("distributed graphs are not supported")
gpubenchmark(cugraph.spectralBalancedCutClustering, graph, 2)
benchmark(cugraph.spectralBalancedCutClustering, graph, 2)


@pytest.mark.skip(reason="Need to guarantee graph has weights, " "not doing that yet")
def bench_spectralModularityMaximizationClustering(gpubenchmark, graph):
def bench_spectralModularityMaximizationClustering(benchmark, graph):
smmc = (
dask_cugraph.spectralModularityMaximizationClustering
if is_graph_distributed(graph)
else cugraph.spectralModularityMaximizationClustering
)
gpubenchmark(smmc, graph, 2)
benchmark(smmc, graph, 2)


def bench_graph_degree(gpubenchmark, graph):
gpubenchmark(graph.degree)
def bench_graph_degree(benchmark, graph):
benchmark(graph.degree)


def bench_graph_degrees(gpubenchmark, graph):
def bench_graph_degrees(benchmark, graph):
if is_graph_distributed(graph):
pytest.skip("distributed graphs are not supported")
gpubenchmark(graph.degrees)
benchmark(graph.degrees)


def bench_betweenness_centrality(gpubenchmark, graph):
def bench_betweenness_centrality(benchmark, graph):
bc = (
dask_cugraph.betweenness_centrality
if is_graph_distributed(graph)
else cugraph.betweenness_centrality
)
gpubenchmark(bc, graph, k=10, random_state=123)
benchmark(bc, graph, k=10, random_state=123)


def bench_edge_betweenness_centrality(gpubenchmark, graph):
def bench_edge_betweenness_centrality(benchmark, graph):
if is_graph_distributed(graph):
pytest.skip("distributed graphs are not supported")
gpubenchmark(cugraph.edge_betweenness_centrality, graph, k=10, seed=123)
benchmark(cugraph.edge_betweenness_centrality, graph, k=10, seed=123)


def bench_uniform_neighbor_sample(gpubenchmark, graph):
def bench_uniform_neighbor_sample(benchmark, graph):
uns = (
dask_cugraph.uniform_neighbor_sample
if is_graph_distributed(graph)
Expand All @@ -455,13 +436,13 @@ def bench_uniform_neighbor_sample(gpubenchmark, graph):
start_list = start_list.compute()

fanout_vals = [5, 5, 5]
gpubenchmark(uns, graph, start_list=start_list, fanout_vals=fanout_vals)
benchmark(uns, graph, start_list=start_list, fanout_vals=fanout_vals)


def bench_egonet(gpubenchmark, graph):
def bench_egonet(benchmark, graph):
egonet = (
dask_cugraph.ego_graph if is_graph_distributed(graph) else cugraph.ego_graph
)
n = 1
radius = 2
gpubenchmark(egonet, graph, n, radius=radius)
benchmark(egonet, graph, n, radius=radius)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
# Copyright (c) 2022-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 All @@ -22,18 +22,6 @@
import dask_cudf
import rmm

# If the rapids-pytest-benchmark plugin is installed, the "gpubenchmark"
# fixture will be available automatically. Check that this fixture is available
# by trying to import rapids_pytest_benchmark, and if that fails, set
# "gpubenchmark" to the standard "benchmark" fixture provided by
# pytest-benchmark.
try:
import rapids_pytest_benchmark # noqa: F401
except ImportError:
import pytest_benchmark

gpubenchmark = pytest_benchmark.plugin.benchmark

from cugraph import (
MultiGraph,
uniform_neighbor_sample,
Expand Down Expand Up @@ -271,7 +259,7 @@ def uns_func(*args, **kwargs):
"with_replacement", [False], ids=lambda v: f"with_replacement={v}"
)
def bench_cugraph_uniform_neighbor_sample(
gpubenchmark, graph_objs, batch_size, fanout, with_replacement
benchmark, graph_objs, batch_size, fanout, with_replacement
):
(G, num_verts, uniform_neighbor_sample_func) = graph_objs

Expand All @@ -281,7 +269,7 @@ def bench_cugraph_uniform_neighbor_sample(
)
# print(f"\n{uns_args}")
# FIXME: uniform_neighbor_sample cannot take a np.ndarray for start_list
result = gpubenchmark(
result = benchmark(
uniform_neighbor_sample_func,
G,
start_list=uns_args["start_list"],
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/dgl/pytest-based/dgl_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-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 All @@ -13,7 +13,6 @@

import pandas as pd
import os
import pytest_benchmark
import pytest
import torch
import dgl
Expand Down
2 changes: 0 additions & 2 deletions python/cugraph-service/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ addopts = --benchmark-warmup=off
--benchmark-min-rounds=1
--benchmark-columns="min, max, mean, rounds"
--tb=native
## for use with rapids-pytest-benchmark plugin
#--benchmark-gpu-disable
## for use with pytest-cov plugin
#--cov=cugraph
#--cov-report term-missing:skip-covered
Expand Down
Loading

0 comments on commit 674a699

Please sign in to comment.