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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CSR Tensor with NN layers #83032

Open
vgutta opened this issue Aug 8, 2022 · 5 comments
Open

Support for CSR Tensor with NN layers #83032

vgutta opened this issue Aug 8, 2022 · 5 comments
Labels
module: nn Related to torch.nn module: sparse Related to torch.sparse triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@vgutta
Copy link

vgutta commented Aug 8, 2022

馃悰 Describe the bug

When I try to pass a CSR tensor to a forward pass for a NN it outputs NaN.

Here is the NN:

class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = GCNConv(292, 8)
        self.conv2 = GCNConv(8, 7)

    def forward(self, data):
         x, edge_index = data.x.to_dense(), data.edge_index
         x = self.conv1(x, edge_index)
         x = F.relu(x)
         x = F.dropout(x, training=self.training)
         x = self.conv2(x, edge_index)
         return F.log_softmax(x, dim=1)

Are there any specific reasons why CSR tensors are not supported yet?

Versions

PyTorch 1.10

cc @nikitaved @pearu @cpuhrsch @amjames @bhosmer @albanD @mruberry @jbschlosser @walterddr @kshitij12345 @saketh-are

@bdhirsh bdhirsh added module: sparse Related to torch.sparse module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Aug 10, 2022
@amjames
Copy link
Collaborator

amjames commented Aug 10, 2022

Could you provide a full reproduction for this?

I tried this out and as you call to_dense in forward there shouldn't be any issue. Without that transformation there are issues with the backward pass, but not forward.

@vgutta
Copy link
Author

vgutta commented Aug 25, 2022

@amjames Are there any recommended solutions for dealing errors during backward pass for data in sparse format?

Example errors found here

@amjames
Copy link
Collaborator

amjames commented Aug 26, 2022

@vgutta I see errors here at the backward step, these are known issues and we are working toward better autograd support for sparse layouts.

I am curious specifically about your original report that passing a sparse CSR tensor to the forward pass results in NaN. This is unexpected and I could not reproduce that result. Could you point out where that is observed? I did not see it in the linked notebook.

@cpuhrsch
Copy link
Contributor

cpuhrsch commented Sep 6, 2022

@amjames @vgutta - The issue cites PyTorch version 1.10. Does this persist on a recent nightly? Thanks.

@vgutta
Copy link
Author

vgutta commented Sep 6, 2022

@vgutta I see errors here at the backward step, these are known issues and we are working toward better autograd support for sparse layouts.

I am curious specifically about your original report that passing a sparse CSR tensor to the forward pass results in NaN. This is unexpected and I could not reproduce that result. Could you point out where that is observed? I did not see it in the linked notebook.

@amjames Sorry forgot to mention in my previous reply that the original issue may have had more to do with the dataset and model I was using rather than a PyTorch issue.

@cpuhrsch I think as far as I can tell the backward pass does not support sparse layouts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: nn Related to torch.nn module: sparse Related to torch.sparse triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

4 participants