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] pytorch geometric interface #1200

Closed
jannessm opened this issue Oct 8, 2020 · 6 comments
Closed

[FEA] pytorch geometric interface #1200

jannessm opened this issue Oct 8, 2020 · 6 comments
Assignees
Milestone

Comments

@jannessm
Copy link

jannessm commented Oct 8, 2020

I am currently using Pytorch geometric for deep learning on graphs. It supports way more convolutions than DGL. So I was wondering if there is a plan to support an interface of converting graphs to a cugraph graph and vice versa.

Regards.

@jannessm jannessm added the ? - Needs Triage Need team to review and classify label Oct 8, 2020
@BradReesWork
Copy link
Member

@jannessm great question. I need to dive into pytorch format before fully answering the questions. The roadmap is currently Pandas and CuPy this year.

@flandolfi
Copy link

Hi @jannessm,

I am working with PyTorch-Geometric (PyG) and for the moment I'm using the following solution (only regards PyG to cuGraph for the moment). Maybe it can be of some help.

from torch.utils.dlpack import from_dlpack, to_dlpack
from torch_geometric.data import Data
from torch_geometric.utils import add_self_loops

import cudf
import cugraph as cx


def to_cugraph(data: Data):
    edge_index, weights = add_self_loops(data.edge_index, data.edge_attr, num_nodes=data.num_nodes)
    df = edge_index.contiguous().t().clone().detach()
    df = cudf.from_dlpack(to_dlpack(df))

    if weights is not None:
        weights = weights.contiguous().view(-1).clone().detach()
        df[2] = cudf.from_dlpack(to_dlpack(weights))

    return cx.from_cudf_edgelist(df, source=0, destination=1,
                                 edge_attr=2 if df.shape[1] == 3 else None,
                                 renumber=False)

Adding self loops is needed to handle the issue #1206 I opened a while ago.

@BradReesWork the conversion cuDF/PyTorch seem to work using DLPack, but we need to take care of some details, like the row-major format and the case in which a tensor is non-contiguous.

Anyway, probably the conversion from and to PyG should be done from the PyG side (paging @rusty1s :)).

Regards,
Francesco

@BradReesWork BradReesWork added this to the 0.19 milestone Feb 5, 2021
@BradReesWork BradReesWork added UX and removed ? - Needs Triage Need team to review and classify labels Feb 5, 2021
@github-actions
Copy link

github-actions bot commented Mar 7, 2021

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@rusty1s
Copy link

rusty1s commented Mar 7, 2021

This issue can likely be closed. I will work on cugraph conversion on PyG side.
@flandolfi Let me know if you have any plans to contribute your implementation.

@flandolfi
Copy link

@flandolfi Let me know if you have any plans to contribute your implementation.

Sure, I will make a PR in a week or so!

@BradReesWork BradReesWork modified the milestones: 0.19, 0.20 Mar 29, 2021
@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants