Skip to content

Commit

Permalink
Merge branch 'branch-23.10' into cugraph-pyg-loader-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarghi-nv authored Sep 8, 2023
2 parents f600520 + 6779e89 commit 11009c6
Show file tree
Hide file tree
Showing 76 changed files with 1,252 additions and 498 deletions.
14 changes: 7 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ VALIDARGS="
cpp-mgtests
cugraph-pyg
cugraph-dgl
cugraph-nx
nx-cugraph
docs
-v
-g
Expand All @@ -54,7 +54,7 @@ HELP="$0 [<target> ...] [<flag> ...]
pylibcugraph - build the pylibcugraph Python package
cugraph-pyg - build the cugraph-pyg Python package
cugraph - build the cugraph Python package
cugraph-nx - build the cugraph-nx Python package
nx-cugraph - build the nx-cugraph Python package
cugraph-service - build the cugraph-service_client and cugraph-service_server Python package
cpp-mgtests - build libcugraph and libcugraph_etl MG tests. Builds MPI communicator, adding MPI as a dependency.
cugraph-dgl - build the cugraph-dgl extensions for DGL
Expand Down Expand Up @@ -209,7 +209,7 @@ if hasArg uninstall; then
# removes the latest one and leaves the others installed. build.sh uninstall
# can be run multiple times to remove all of them, but that is not obvious.
pip uninstall -y pylibcugraph cugraph cugraph-service-client cugraph-service-server \
cugraph-dgl cugraph-pyg cugraph-nx
cugraph-dgl cugraph-pyg nx-cugraph
fi

if hasArg clean; then
Expand Down Expand Up @@ -382,12 +382,12 @@ if hasArg cugraph-dgl; then
fi
fi

# Build and install the cugraph-nx Python package
if hasArg cugraph-nx; then
# Build and install the nx-cugraph Python package
if hasArg nx-cugraph; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-nx
cleanPythonDir ${REPODIR}/python/nx-cugraph
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-nx
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/nx-cugraph
fi
fi

Expand Down
4 changes: 2 additions & 2 deletions ci/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ rapids-mamba-retry mambabuild \
--channel "${RAPIDS_CONDA_BLD_OUTPUT_DIR}" \
conda/recipes/cugraph

# NOTE: nothing in cugraph-nx is CUDA-specific, but it is built on each CUDA
# NOTE: nothing in nx-cugraph is CUDA-specific, but it is built on each CUDA
# platform to ensure it is included in each set of artifacts, since test
# scripts only install from one set of artifacts based on the CUDA version used
# for the test run.
rapids-mamba-retry mambabuild \
--no-test \
--channel "${CPP_CHANNEL}" \
--channel "${RAPIDS_CONDA_BLD_OUTPUT_DIR}" \
conda/recipes/cugraph-nx
conda/recipes/nx-cugraph

# NOTE: nothing in the cugraph-service packages are CUDA-specific, but they are
# built on each CUDA platform to ensure they are included in each set of
Expand Down
4 changes: 2 additions & 2 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugr
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugraph-service/client/cugraph_service_client/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugraph-service/server/cugraph_service_server/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/pylibcugraph/pylibcugraph/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugraph-nx/cugraph_nx/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/nx-cugraph/nx_cugraph/__init__.py

# Python pyproject.toml updates
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph/pyproject.toml
Expand All @@ -70,7 +70,7 @@ sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph-pyg
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph-service/client/pyproject.toml
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph-service/server/pyproject.toml
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pylibcugraph/pyproject.toml
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph-nx/pyproject.toml
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/nx-cugraph/pyproject.toml

# Wheel testing script
sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" ci/test_wheel_cugraph.sh
Expand Down
20 changes: 10 additions & 10 deletions ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rapids-mamba-retry install \
libcugraph \
pylibcugraph \
cugraph \
cugraph-nx \
nx-cugraph \
cugraph-service-server \
cugraph-service-client

Expand Down Expand Up @@ -93,28 +93,28 @@ pytest \
cugraph/pytest-based/bench_algos.py
popd

rapids-logger "pytest cugraph-nx"
pushd python/cugraph-nx/cugraph_nx
rapids-logger "pytest nx-cugraph"
pushd python/nx-cugraph/nx_cugraph
pytest \
--capture=no \
--verbose \
--cache-clear \
--junitxml="${RAPIDS_TESTS_DIR}/junit-cugraph-nx.xml" \
--junitxml="${RAPIDS_TESTS_DIR}/junit-nx-cugraph.xml" \
--cov-config=../../.coveragerc \
--cov=cugraph_nx \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cugraph-nx-coverage.xml" \
--cov=nx_cugraph \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/nx-cugraph-coverage.xml" \
--cov-report=term \
--benchmark-disable \
tests
popd

rapids-logger "pytest networkx using cugraph-nx backend"
pushd python/cugraph-nx
rapids-logger "pytest networkx using nx-cugraph backend"
pushd python/nx-cugraph
./run_nx_tests.sh
# run_nx_tests.sh outputs coverage data, so check that total coverage is >0.0%
# in case cugraph-nx failed to load but fallback mode allowed the run to pass.
# in case nx-cugraph failed to load but fallback mode allowed the run to pass.
_coverage=$(coverage report|grep "^TOTAL")
echo "cugraph-nx coverage from networkx tests: $_coverage"
echo "nx-cugraph coverage from networkx tests: $_coverage"
echo $_coverage | awk '{ if ($NF == "0.0%") exit 1 }'
popd

Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
- rapidsai-nightly
- dask/label/dev
- pytorch
- pyg
- dglteam/label/cu118
- conda-forge
- nvidia
Expand Down
1 change: 1 addition & 0 deletions conda/environments/all_cuda-120_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
- rapidsai-nightly
- dask/label/dev
- pytorch
- pyg
- dglteam/label/cu118
- conda-forge
- nvidia
Expand Down
1 change: 1 addition & 0 deletions conda/recipes/cugraph-pyg/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ requirements:
- pytorch >=2.0
- cupy >=12.0.0
- cugraph ={{ version }}
- pylibcugraphops ={{ version }}
- pyg >=2.3,<2.4

tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

# This assumes the script is executed from the root of the repo directory

./build.sh cugraph-nx
./build.sh nx-cugraph
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% set date_string = environ['RAPIDS_DATE_STRING'] %}

package:
name: cugraph-nx
name: nx-cugraph
version: {{ version }}

source:
Expand All @@ -29,7 +29,7 @@ requirements:

tests:
imports:
- cugraph_nx
- nx_cugraph
commands:
- pip check
requires:
Expand Down
4 changes: 4 additions & 0 deletions cpp/include/cugraph/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ weight_t hungarian(raft::handle_t const& handle,
* @param[in] graph input graph object
* @param[out] clustering Pointer to device array where the clustering should be stored
* @param[in] max_level (optional) maximum number of levels to run (default 100)
* @param[in] threshold (optional) threshold for convergence at each level (default
* 1e-7)
* @param[in] resolution (optional) The value of the resolution parameter to use.
* Called gamma in the modularity formula, this changes the size
* of the communities. Higher resolutions lead to more smaller
Expand All @@ -607,6 +609,7 @@ std::pair<size_t, weight_t> louvain(
std::optional<edge_property_view_t<edge_t, weight_t const*>> edge_weight_view,
vertex_t* clustering,
size_t max_level = 100,
weight_t threshold = weight_t{1e-7},
weight_t resolution = weight_t{1});

template <typename vertex_t, typename edge_t, typename weight_t>
Expand Down Expand Up @@ -652,6 +655,7 @@ std::pair<std::unique_ptr<Dendrogram<vertex_t>>, weight_t> louvain(
graph_view_t<vertex_t, edge_t, false, multi_gpu> const& graph_view,
std::optional<edge_property_view_t<edge_t, weight_t const*>> edge_weight_view,
size_t max_level = 100,
weight_t threshold = weight_t{1e-7},
weight_t resolution = weight_t{1});

/**
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/cugraph_c/community_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ typedef struct {
* @param [in] graph Pointer to graph. NOTE: Graph might be modified if the storage
* needs to be transposed
* @param [in] max_level Maximum level in hierarchy
* @param [in] threshold Threshold parameter, defines convergence at each level of hierarchy
* @param [in] resolution Resolution parameter (gamma) in modularity formula.
* This changes the size of the communities. Higher resolutions
* lead to more smaller communities, lower resolutions lead to
Expand All @@ -107,6 +108,7 @@ typedef struct {
cugraph_error_code_t cugraph_louvain(const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
size_t max_level,
double threshold,
double resolution,
bool_t do_expensive_check,
cugraph_hierarchical_clustering_result_t** result,
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/c_api/louvain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ struct louvain_functor : public cugraph::c_api::abstract_functor {
raft::handle_t const& handle_;
cugraph::c_api::cugraph_graph_t* graph_;
size_t max_level_;
double threshold_;
double resolution_;
bool do_expensive_check_;
cugraph::c_api::cugraph_hierarchical_clustering_result_t* result_{};

louvain_functor(::cugraph_resource_handle_t const* handle,
::cugraph_graph_t* graph,
size_t max_level,
double threshold,
double resolution,
bool do_expensive_check)
: abstract_functor(),
handle_(*reinterpret_cast<cugraph::c_api::cugraph_resource_handle_t const*>(handle)->handle_),
graph_(reinterpret_cast<cugraph::c_api::cugraph_graph_t*>(graph)),
max_level_(max_level),
threshold_(threshold),
resolution_(resolution),
do_expensive_check_(do_expensive_check)
{
Expand Down Expand Up @@ -102,6 +105,7 @@ struct louvain_functor : public cugraph::c_api::abstract_functor {
.view()),
clusters.data(),
max_level_,
static_cast<weight_t>(threshold_),
static_cast<weight_t>(resolution_));

rmm::device_uvector<vertex_t> vertices(graph_view.local_vertex_partition_range_size(),
Expand All @@ -121,12 +125,13 @@ struct louvain_functor : public cugraph::c_api::abstract_functor {
extern "C" cugraph_error_code_t cugraph_louvain(const cugraph_resource_handle_t* handle,
cugraph_graph_t* graph,
size_t max_level,
double threshold,
double resolution,
bool_t do_expensive_check,
cugraph_hierarchical_clustering_result_t** result,
cugraph_error_t** error)
{
louvain_functor functor(handle, graph, max_level, resolution, do_expensive_check);
louvain_functor functor(handle, graph, max_level, threshold, resolution, do_expensive_check);

return cugraph::c_api::run_algorithm(graph, functor, result, error);
}
9 changes: 6 additions & 3 deletions cpp/src/community/louvain_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ std::pair<std::unique_ptr<Dendrogram<vertex_t>>, weight_t> louvain(
graph_view_t<vertex_t, edge_t, false, multi_gpu> const& graph_view,
std::optional<edge_property_view_t<edge_t, weight_t const*>> edge_weight_view,
size_t max_level,
weight_t threshold,
weight_t resolution)
{
using graph_t = cugraph::graph_t<vertex_t, edge_t, false, multi_gpu>;
Expand Down Expand Up @@ -169,7 +170,7 @@ std::pair<std::unique_ptr<Dendrogram<vertex_t>>, weight_t> louvain(
// during each iteration of the loop
bool up_down = true;

while (new_Q > (cur_Q + 0.0001)) {
while (new_Q > (cur_Q + threshold)) {
cur_Q = new_Q;

next_clusters_v = detail::update_clustering_by_delta_modularity(handle,
Expand Down Expand Up @@ -291,12 +292,13 @@ std::pair<std::unique_ptr<Dendrogram<vertex_t>>, weight_t> louvain(
graph_view_t<vertex_t, edge_t, false, multi_gpu> const& graph_view,
std::optional<edge_property_view_t<edge_t, weight_t const*>> edge_weight_view,
size_t max_level,
weight_t threshold,
weight_t resolution)
{
CUGRAPH_EXPECTS(!graph_view.has_edge_mask(), "unimplemented.");

CUGRAPH_EXPECTS(edge_weight_view.has_value(), "Graph must be weighted");
return detail::louvain(handle, graph_view, edge_weight_view, max_level, resolution);
return detail::louvain(handle, graph_view, edge_weight_view, max_level, threshold, resolution);
}

template <typename vertex_t, typename edge_t, bool multi_gpu>
Expand All @@ -317,6 +319,7 @@ std::pair<size_t, weight_t> louvain(
std::optional<edge_property_view_t<edge_t, weight_t const*>> edge_weight_view,
vertex_t* clustering,
size_t max_level,
weight_t threshold,
weight_t resolution)
{
CUGRAPH_EXPECTS(!graph_view.has_edge_mask(), "unimplemented.");
Expand All @@ -328,7 +331,7 @@ std::pair<size_t, weight_t> louvain(
weight_t modularity;

std::tie(dendrogram, modularity) =
detail::louvain(handle, graph_view, edge_weight_view, max_level, resolution);
detail::louvain(handle, graph_view, edge_weight_view, max_level, threshold, resolution);

detail::flatten_dendrogram(handle, graph_view, *dendrogram, clustering);

Expand Down
Loading

0 comments on commit 11009c6

Please sign in to comment.