Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] New Graph Interface and Loaders for Distributed Sampling in DGL #4486

Merged
merged 51 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b5915ff
merge
alexbarghi-nv Jun 3, 2024
4e3045f
c
alexbarghi-nv Jun 6, 2024
f243351
pull in dependency fixes
alexbarghi-nv Jun 6, 2024
b1adcd3
merge
alexbarghi-nv Jun 6, 2024
4c29329
w
alexbarghi-nv Jun 7, 2024
265f546
basic graph/fs
alexbarghi-nv Jun 7, 2024
b51eda4
dist sampling
alexbarghi-nv Jun 10, 2024
9943260
graph data views
alexbarghi-nv Jun 12, 2024
055db0a
remove unwanted file
alexbarghi-nv Jun 12, 2024
020bf67
Merge branch 'branch-24.08' of https://github.com/rapidsai/cugraph in…
alexbarghi-nv Jun 13, 2024
1f76898
revert devcontainer change
alexbarghi-nv Jun 13, 2024
927ee09
tests, bugfixes, resolve indexing problem (sort of)
alexbarghi-nv Jun 14, 2024
ffdb2fa
Merge branch 'branch-24.08' into dgl-dist-sampling
nv-rliu Jun 24, 2024
68129d9
add heteogeneous tests
alexbarghi-nv Jun 25, 2024
20450a3
testing, fixing graph API
alexbarghi-nv Jun 26, 2024
58ec793
Merge branch 'dgl-dist-sampling' of https://github.com/alexbarghi-nv/…
alexbarghi-nv Jun 26, 2024
557d9aa
Loaders
alexbarghi-nv Jun 27, 2024
a8c0848
add todo
alexbarghi-nv Jun 27, 2024
913b8cd
fix block issue, typing
alexbarghi-nv Jun 28, 2024
79c8f78
reorganize tests
alexbarghi-nv Jul 1, 2024
b25128b
Merge branch 'branch-24.08' of https://github.com/rapidsai/cugraph in…
alexbarghi-nv Jul 1, 2024
a56b56d
sampling
alexbarghi-nv Jul 2, 2024
8f14f88
revert dependencies.yaml
alexbarghi-nv Jul 2, 2024
5f74252
update tensordict dependency
alexbarghi-nv Jul 2, 2024
ad120ac
Merge branch 'branch-24.08' into dgl-dist-sampling
alexbarghi-nv Jul 2, 2024
b2fdef8
update dependencies
alexbarghi-nv Jul 2, 2024
5ce714d
Merge branch 'dgl-dist-sampling' of https://github.com/alexbarghi-nv/…
alexbarghi-nv Jul 2, 2024
92fd866
update meta files
alexbarghi-nv Jul 2, 2024
6107d82
fix csr/csc issue, wrap up tests
alexbarghi-nv Jul 3, 2024
f04700d
Merge branch 'branch-24.08' into dgl-dist-sampling
alexbarghi-nv Jul 8, 2024
6bc4b4a
m
alexbarghi-nv Jul 8, 2024
faeb4a5
style
alexbarghi-nv Jul 8, 2024
afb9452
revert ci script
alexbarghi-nv Jul 8, 2024
48ba6d4
fix meta.yaml issue
alexbarghi-nv Jul 9, 2024
786c1af
Merge branch 'branch-24.08' into dgl-dist-sampling
alexbarghi-nv Jul 9, 2024
801de87
add type hint
alexbarghi-nv Jul 10, 2024
5e511cc
add missing type hint
alexbarghi-nv Jul 10, 2024
035b69a
remove comment, add issue reference
alexbarghi-nv Jul 10, 2024
ebbc1db
Merge branch 'dgl-dist-sampling' of https://github.com/alexbarghi-nv/…
alexbarghi-nv Jul 10, 2024
b412776
Add type hint
alexbarghi-nv Jul 10, 2024
1c72bd6
add convert function, fix bugs
alexbarghi-nv Jul 10, 2024
18f6ac2
Merge branch 'dgl-dist-sampling' of https://github.com/alexbarghi-nv/…
alexbarghi-nv Jul 10, 2024
9bd0440
Merge branch 'branch-24.08' into dgl-dist-sampling
alexbarghi-nv Jul 10, 2024
2d522b1
move worker init to utility
alexbarghi-nv Jul 10, 2024
4b60d8d
Merge branch 'dgl-dist-sampling' of https://github.com/alexbarghi-nv/…
alexbarghi-nv Jul 10, 2024
e1fa6e0
revert none return, add check
alexbarghi-nv Jul 10, 2024
8529987
style
alexbarghi-nv Jul 10, 2024
ae9133f
resolve merge conflict
alexbarghi-nv Jul 25, 2024
7a3d38f
reverse mfgs
alexbarghi-nv Jul 25, 2024
ddb95d6
resolve merge conflict
alexbarghi-nv Jul 30, 2024
7ba4d89
use global communicator
alexbarghi-nv Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
- packaging>=21
- pandas
- pre-commit
- pydantic
- pydata-sphinx-theme
- pylibcugraphops==24.8.*,>=0.0.0a0
- pylibraft==24.8.*,>=0.0.0a0
Expand All @@ -72,6 +73,7 @@ dependencies:
- sphinx<6
- sphinxcontrib-websupport
- thriftpy2<=0.5.0
- torchdata
- ucx-proc=*=gpu
- ucx-py==0.39.*,>=0.0.0a0
- wget
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-122_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies:
- packaging>=21
- pandas
- pre-commit
- pydantic
- pydata-sphinx-theme
- pylibcugraphops==24.8.*,>=0.0.0a0
- pylibraft==24.8.*,>=0.0.0a0
Expand All @@ -77,6 +78,7 @@ dependencies:
- sphinx<6
- sphinxcontrib-websupport
- thriftpy2<=0.5.0
- torchdata
- ucx-proc=*=gpu
- ucx-py==0.39.*,>=0.0.0a0
- wget
Expand Down
4 changes: 3 additions & 1 deletion conda/recipes/cugraph-dgl/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ requirements:
- numba >=0.57
- numpy >=1.23,<2.0a0
- pylibcugraphops ={{ minor_version }}
- tensordict >=0.1.2
- python
- pytorch
- pytorch >=2.0
- cupy >=12.0.0

tests:
imports:
Expand Down
5 changes: 4 additions & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ dependencies:
- cugraph==24.8.*,>=0.0.0a0
- pytorch>=2.0
- pytorch-cuda==11.8
- &tensordict tensordict>=0.1.2
- dgl>=1.1.0.cu*
cugraph_pyg_dev:
common:
Expand All @@ -655,14 +656,16 @@ dependencies:
- cugraph==24.8.*,>=0.0.0a0
- pytorch>=2.0
- pytorch-cuda==11.8
- &tensordict tensordict>=0.1.2
- *tensordict
- pyg>=2.5,<2.6

depends_on_pytorch:
common:
- output_types: [conda]
packages:
- &pytorch_conda pytorch>=2.0,<2.2.0a0
- torchdata
- pydantic

specific:
- output_types: [requirements]
Expand Down
1 change: 1 addition & 0 deletions python/cugraph-dgl/conda/cugraph_dgl_dev_cuda-118.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ dependencies:
- pytorch-cuda==11.8
- pytorch>=2.0
- scipy
- tensordict>=0.1.2
name: cugraph_dgl_dev_cuda-118
8 changes: 6 additions & 2 deletions python/cugraph-dgl/cugraph_dgl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, 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 @@ -15,8 +15,12 @@

# to prevent rapids context being created when importing cugraph_dgl
os.environ["RAPIDS_NO_INITIALIZE"] = "1"
from cugraph_dgl.graph import Graph
from cugraph_dgl.cugraph_storage import CuGraphStorage
from cugraph_dgl.convert import cugraph_storage_from_heterograph
from cugraph_dgl.convert import (
cugraph_storage_from_heterograph,
cugraph_dgl_graph_from_heterograph,
)
import cugraph_dgl.dataloading
import cugraph_dgl.nn

Expand Down
54 changes: 53 additions & 1 deletion python/cugraph-dgl/cugraph_dgl/convert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, 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 @@ -12,6 +12,8 @@
# limitations under the License.
from __future__ import annotations
from cugraph.utilities.utils import import_optional

import cugraph_dgl
from cugraph_dgl import CuGraphStorage
from cugraph_dgl.utils.cugraph_conversion_utils import (
get_edges_dict_from_dgl_HeteroGraph,
Expand Down Expand Up @@ -39,3 +41,53 @@ def cugraph_storage_from_heterograph(
add_ndata_from_dgl_HeteroGraph(gs, g)
add_edata_from_dgl_HeteroGraph(gs, g)
return gs


def cugraph_dgl_graph_from_heterograph(
input_graph: dgl.DGLGraph,
single_gpu: bool = True,
ndata_storage: str = "torch",
edata_storage: str = "torch",
**kwargs,
) -> cugraph_dgl.Graph:
"""
Converts a DGL Graph to a cuGraph-DGL Graph.
"""

output_graph = cugraph_dgl.Graph(
is_multi_gpu=(not single_gpu),
ndata_storage=ndata_storage,
edata_storage=edata_storage,
**kwargs,
)

# Calling is_homogeneous does not work here
if len(input_graph.ntypes) <= 1:
output_graph.add_nodes(
input_graph.num_nodes(), data=input_graph.ndata, ntype=input_graph.ntypes[0]
)
else:
for ntype in input_graph.ntypes:
data = {
k: v_dict[ntype]
for k, v_dict in input_graph.ndata.items()
if ntype in v_dict
}
output_graph.add_nodes(input_graph.num_nodes(ntype), data=data, ntype=ntype)

if len(input_graph.canonical_etypes) <= 1:
can_etype = input_graph.canonical_etypes[0]
src_t, dst_t = input_graph.edges(form="uv", etype=can_etype)
output_graph.add_edges(src_t, dst_t, input_graph.edata, etype=can_etype)
else:
for can_etype in input_graph.canonical_etypes:
data = {
k: v_dict[can_etype]
for k, v_dict in input_graph.edata.items()
if can_etype in v_dict
}

src_t, dst_t = input_graph.edges(form="uv", etype=can_etype)
output_graph.add_edges(src_t, dst_t, data=data, etype=can_etype)

return output_graph
20 changes: 18 additions & 2 deletions python/cugraph-dgl/cugraph_dgl/dataloading/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# Copyright (c) 2019-2024, 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 @@ -11,9 +11,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings

from cugraph_dgl.dataloading.dataset import (
HomogenousBulkSamplerDataset,
HeterogenousBulkSamplerDataset,
)

from cugraph_dgl.dataloading.sampler import Sampler
from cugraph_dgl.dataloading.neighbor_sampler import NeighborSampler
from cugraph_dgl.dataloading.dataloader import DataLoader

from cugraph_dgl.dataloading.dask_dataloader import DaskDataLoader
from cugraph_dgl.dataloading.dataloader import DataLoader as FutureDataLoader


def DataLoader(*args, **kwargs):
warnings.warn(
"DataLoader has been renamed to DaskDataLoader. "
"In Release 24.10, cugraph_dgl.dataloading.FutureDataLoader "
"will take over the DataLoader name.",
FutureWarning,
)
return DaskDataLoader(*args, **kwargs)
Loading
Loading