Skip to content

Commit

Permalink
Merge branch 'branch-23.08' into fea/use_rapids_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard authored Jul 11, 2023
2 parents e27074a + 0372396 commit 8546c4f
Show file tree
Hide file tree
Showing 32 changed files with 2,815 additions and 323 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
with:
build_type: pull-request
package-name: pylibcugraph
test-unittest: "RAPIDS_DATASET_ROOT_DIR=./datasets pytest ./python/pylibcugraph/pylibcugraph/tests"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=./datasets python -m pytest ./python/pylibcugraph/pylibcugraph/tests"
test-smoketest: "python ci/wheel_smoke_test_pylibcugraph.py"
wheel-build-cugraph:
needs: wheel-tests-pylibcugraph
Expand All @@ -120,5 +120,5 @@ jobs:
test-before-amd64: "cd ./datasets && bash ./get_test_data.sh && cd - && RAPIDS_PY_WHEEL_NAME=pylibcugraph_${{ '${PIP_CU_VERSION}' }} rapids-download-wheels-from-s3 ./local-pylibcugraph-dep && pip install --no-deps ./local-pylibcugraph-dep/*.whl && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
# Skip dataset downloads on arm to save CI time -- arm only runs smoke tests.
test-before-arm64: "RAPIDS_PY_WHEEL_NAME=pylibcugraph_${{ '${PIP_CU_VERSION}' }} rapids-download-wheels-from-s3 ./local-pylibcugraph-dep && pip install --no-deps ./local-pylibcugraph-dep/*.whl && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=/__w/cugraph/cugraph/datasets pytest -m sg ./python/cugraph/cugraph/tests"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=/__w/cugraph/cugraph/datasets python -m pytest -m sg ./python/cugraph/cugraph/tests"
test-smoketest: "python ci/wheel_smoke_test_cugraph.py"
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
date: ${{ inputs.date }}
sha: ${{ inputs.sha }}
package-name: pylibcugraph
test-unittest: "RAPIDS_DATASET_ROOT_DIR=./datasets pytest ./python/pylibcugraph/pylibcugraph/tests"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=./datasets python -m pytest ./python/pylibcugraph/pylibcugraph/tests"
wheel-tests-cugraph:
secrets: inherit
uses: rapidsai/shared-action-workflows/.github/workflows/[email protected]
Expand All @@ -52,4 +52,4 @@ jobs:
# Always want to test against latest dask/distributed.
test-before-amd64: "cd ./datasets && bash ./get_test_data.sh && cd - && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
test-before-arm64: "cd ./datasets && bash ./get_test_data.sh && cd - && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=/__w/cugraph/cugraph/datasets pytest -m sg ./python/cugraph/cugraph/tests"
test-unittest: "RAPIDS_DATASET_ROOT_DIR=/__w/cugraph/cugraph/datasets python -m pytest -m sg ./python/cugraph/cugraph/tests"
1,860 changes: 1,860 additions & 0 deletions benchmarks/cugraph/standalone/bulk_sampling/benchmarking_script.ipynb

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions benchmarks/cugraph/standalone/bulk_sampling/bulk_sampling.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (c) 2023, 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

export RAPIDS_NO_INITIALIZE="1"
export CUDF_SPILL="1"
export LIBCUDF_CUFILE_POLICY=OFF


dataset_name=$1
dataset_root=$2
output_root=$3
batch_sizes=$4
fanouts=$5
reverse_edges=$6

rm -rf $output_root
mkdir -p $output_root

# Change to 2 in Selene
gpu_per_replica=4
#--add_edge_ids \

# Expand to 1, 4, 8 in Selene
for i in 1,2,3,4:
do
for replication in 2;
do
dataset_name_with_replication="${dataset_name}[${replication}]"
dask_worker_devices=$(seq -s, 0 $((gpu_per_replica*replication-1)))
echo "Sampling dataset = $dataset_name_with_replication on devices = $dask_worker_devices"
python3 cugraph_bulk_sampling.py --datasets $dataset_name_with_replication \
--dataset_root $dataset_root \
--batch_sizes $batch_sizes \
--output_root $output_root \
--dask_worker_devices $dask_worker_devices \
--fanouts $fanouts \
--batch_sizes $batch_sizes \
--reverse_edges
done
done
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

import cugraph

from datetime import datetime

import json
import re
import os
Expand All @@ -50,6 +48,7 @@
import dask_cudf
import dask.dataframe as ddf
from dask.distributed import default_client
from cugraph.dask import get_n_workers

from typing import Optional, Union, Dict

Expand Down Expand Up @@ -173,6 +172,7 @@ def sample_graph(G, label_df, output_path,seed=42, batch_size=500, seeds_per_cal
random_state=seed,
seeds_per_call=seeds_per_call,
batches_per_partition=batches_per_partition,
log_level = logging.INFO
)

n_workers = len(default_client().scheduler_info()['workers'])
Expand All @@ -182,10 +182,10 @@ def sample_graph(G, label_df, output_path,seed=42, batch_size=500, seeds_per_cal
'batch': cudf.Series(dtype='int32')
})


batch_df = label_df.map_partitions(_make_batch_ids, batch_size, n_workers, meta=meta)
#batch_df = batch_df.sort_values(by='node')

# should always persist the batch dataframe or performace may be suboptimal
# should always persist the batch dataframe or performance may be suboptimal
batch_df = batch_df.persist()

del label_df
Expand Down Expand Up @@ -278,6 +278,8 @@ def load_disk_dataset(dataset, dataset_dir='.', reverse_edges=True, replication_
path = Path(dataset_dir) / dataset
parquet_path = path / 'parquet'

n_workers = get_n_workers()

with open(os.path.join(path, 'meta.json')) as meta_file:
meta = json.load(meta_file)

Expand All @@ -289,7 +291,9 @@ def load_disk_dataset(dataset, dataset_dir='.', reverse_edges=True, replication_
print(f'Loading edge index for edge type {edge_type}')

can_edge_type = tuple(edge_type.split('__'))
edge_index_dict[can_edge_type] = dask_cudf.read_parquet(os.path.join(os.path.join(parquet_path, edge_type), 'edge_index.parquet'))
edge_index_dict[can_edge_type] = dask_cudf.read_parquet(
Path(parquet_path) / edge_type / 'edge_index.parquet'
).repartition(n_workers*2)

edge_index_dict[can_edge_type]['src'] += node_offsets_replicated[can_edge_type[0]]
edge_index_dict[can_edge_type]['dst'] += node_offsets_replicated[can_edge_type[-1]]
Expand Down Expand Up @@ -344,7 +348,7 @@ def load_disk_dataset(dataset, dataset_dir='.', reverse_edges=True, replication_
print(f'Loading node labels for node type {node_type} (offset={offset})')
node_label_path = os.path.join(os.path.join(parquet_path, node_type), 'node_label.parquet')
if os.path.exists(node_label_path):
node_labels[node_type] = dask_cudf.read_parquet(node_label_path).drop('label',axis=1).persist()
node_labels[node_type] = dask_cudf.read_parquet(node_label_path).repartition(n_workers).drop('label',axis=1).persist()
node_labels[node_type]['node'] += offset
node_labels[node_type] = node_labels[node_type].persist()

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/detail/graph_partition_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include <raft/core/device_span.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>
#include <thrust/binary_search.h>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_count_if_e.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_count_if_v.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <cugraph/graph_view.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_extract_transform_e.cu
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <cugraph/utilities/high_res_timer.hpp>
#include <cugraph/utilities/thrust_tuple_utils.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_reduce_v.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cugraph/graph_view.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_transform_e.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <cugraph/graph_view.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_transform_reduce_e.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/mg_transform_reduce_v.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <cugraph/graph_view.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/high_res_timer.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/comms/mpi_comms.hpp>
#include <raft/core/comms.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/prims/property_generator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cugraph/utilities/dataframe_buffer.hpp>
#include <cugraph/utilities/thrust_tuple_utils.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/core/handle.hpp>
#include <rmm/device_uvector.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/tests/sampling/detail/nbr_sampling_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <cugraph/utilities/high_res_timer.hpp>
#include <cugraph/utilities/host_scalar_comm.hpp>

#include <cuco/detail/hash_functions.cuh>
#include <cuco/hash_functions.cuh>

#include <raft/core/handle.hpp>

Expand Down
1 change: 1 addition & 0 deletions mg_utils/run-dask-process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function buildTcpArgs {
"

WORKER_ARGS="--rmm-pool-size=$WORKER_RMM_POOL_SIZE
--rmm-async
--local-directory=/tmp/$LOGNAME
--scheduler-file=$SCHEDULER_FILE
--memory-limit=$DASK_HOST_MEMORY_LIMIT
Expand Down
71 changes: 24 additions & 47 deletions python/cugraph-dgl/cugraph_dgl/nn/conv/gatconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from cugraph_dgl.nn.conv.base import BaseConv
from cugraph.utilities.utils import import_optional

from pylibcugraphops.pytorch import BipartiteCSC, SampledCSC, StaticCSC
from pylibcugraphops.pytorch.operators import mha_gat_n2n, mha_gat_n2n_bipartite
from pylibcugraphops.pytorch import CSC
from pylibcugraphops.pytorch.operators import mha_gat_n2n

dgl = import_optional("dgl")
torch = import_optional("torch")
Expand Down Expand Up @@ -173,9 +173,20 @@ def forward(
:math:`H` is the number of heads, and :math:`D_{out}` is size of
output feature.
"""
if max_in_degree is None:
max_in_degree = -1

bipartite = not isinstance(nfeat, torch.Tensor)
offsets, indices, _ = g.adj_tensors("csc")

graph = CSC(
offsets=offsets,
indices=indices,
num_src_nodes=g.num_src_nodes(),
dst_max_in_degree=max_in_degree,
is_bipartite=bipartite,
)

if efeat is not None:
if self.fc_edge is None:
raise RuntimeError(
Expand All @@ -191,60 +202,26 @@ def forward(
f"integers to allow bipartite node features, but got "
f"{self.in_feats}."
)
_graph = BipartiteCSC(
offsets=offsets, indices=indices, num_src_nodes=g.num_src_nodes()
)
nfeat_src = self.fc_src(nfeat[0])
nfeat_dst = self.fc_dst(nfeat[1])

out = mha_gat_n2n_bipartite(
src_feat=nfeat_src,
dst_feat=nfeat_dst,
attn_weights=self.attn_weights,
graph=_graph,
num_heads=self.num_heads,
activation="LeakyReLU",
negative_slope=self.negative_slope,
concat_heads=self.concat,
edge_feat=efeat,
)
else:
if not hasattr(self, "fc"):
raise RuntimeError(
f"{self.__class__.__name__}.in_feats is expected to be an "
f"integer, but got {self.in_feats}."
)
nfeat = self.fc(nfeat)
# Sampled primitive does not support edge features
if g.is_block and efeat is None:
if max_in_degree is None:
max_in_degree = g.in_degrees().max().item()

if max_in_degree < self.MAX_IN_DEGREE_MFG:
_graph = SampledCSC(
offsets=offsets,
indices=indices,
max_num_neighbors=max_in_degree,
num_src_nodes=g.num_src_nodes(),
)
else:
offsets = self.pad_offsets(offsets, g.num_src_nodes() + 1)
_graph = StaticCSC(offsets=offsets, indices=indices)
else:
if g.is_block:
offsets = self.pad_offsets(offsets, g.num_src_nodes() + 1)
_graph = StaticCSC(offsets=offsets, indices=indices)

out = mha_gat_n2n(
feat=nfeat,
attn_weights=self.attn_weights,
graph=_graph,
num_heads=self.num_heads,
activation="LeakyReLU",
negative_slope=self.negative_slope,
concat_heads=self.concat,
edge_feat=efeat,
)[: g.num_dst_nodes()]

out = mha_gat_n2n(
(nfeat_src, nfeat_dst) if bipartite else nfeat,
self.attn_weights,
graph,
num_heads=self.num_heads,
activation="LeakyReLU",
negative_slope=self.negative_slope,
concat_heads=self.concat,
edge_feat=efeat,
)[: g.num_dst_nodes()]

if self.concat:
out = out.view(-1, self.num_heads, self.out_feats)
Expand Down
Loading

0 comments on commit 8546c4f

Please sign in to comment.