-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
RuntimeError: scatter_add_cuda_kernel does not have a deterministic implementation #3175
Comments
|
Sure. The difference between those two approaches is that, for |
Thank you very much for explanation :) |
Sorry for reopening the issue again; I tried the above solution with the GCNConv method, and it works fine, but using the SparseTensor method with GATConv throwing this error
|
Can you show me a script to reproduce? I have no problems running the following script: import torch
from torch_geometric.nn import GATConv
from torch_geometric.datasets import Planetoid
import torch_geometric.transforms as T
torch.use_deterministic_algorithms(True)
data = Planetoid('/tmp/dawdh', name='Cora', transform=T.ToSparseTensor())[0]
data = data.cuda()
conv = GATConv(data.num_node_features, 20, heads=4)
conv = conv.cuda()
out = conv(data.x, data.adj_t)
out.mean().backward() |
Hi @rusty1s As per this comment on PyTorch repo, deterministic scatter operation is now available for 1D tensors. Thus I think for
however it does not work. The problem is only due to presence of a singleton dimension in
Changing this line instead to the following does work:
TLDR: It might be possible to start supporting deterministic |
Thanks for the reference @aabbas90. In my understanding, deterministic Notably, I'm afraid that operating on 1D tensors will actually never be the case in PyG (as this requires that the number of features needs to be one). |
Yes deterministic
But I guess it does not help much since other ops would still be non-deterministic. |
Ah, I see. In that case we would need to try to |
Thanks, yes I was partly interested in contributing but cannot currently build torch-scatter successfully from source. So I am afraid I do not have enough capacity to go down this rabbit hole. |
Please let me know the issues when installing |
The error I am getting is:
To install from source I did the following inside a conda environment with python 3.7:
where |
Can you uninstall and try to install CPU-only (as detailed above). Please report any installation logs as well. |
Sorry for intervening in your discussion, but I have a question regarding the workaround posted here for the OP issue: |
The usage of |
I use edge attributes. If add_self_loops is enabled, a NotImplementedError arises (e.g. check the GATConv forward implementation if edge_dim is set). In more recent versions, one cannot actually omit setting the edge_dim either due to an assert failure in message(), even if the dimensionality of the edge attributes is kept in check externally to the call (which is also a bit annoying to be fair), so having self loops becomes effectively locked for SparseTensors in GAT or GATv2Conv.. |
Can you clarify what you mean by one cannot omit setting Furthermore, note that you can always set transform = T.Compose([T.AddSelfLoops(), T.ToSparseTensor()]) This should mimic the original behavior. |
OK. So, in pytorch_geometric/torch_geometric/nn/conv/gat_conv.py Lines 219 to 239 in aa99b50
At the same time, in pytorch_geometric/torch_geometric/nn/conv/gat_conv.py Lines 272 to 275 in aa99b50
Maybe the intention here was to only support passing edge attributes directly to the SparseTensor constructor (i.e. without support for passing |
I think this is definitely intended. If you pass in I guess the easiest workaround for your problem would be the addition of self-loops in |
Well, from my understanding And yep, the final solution should be what you said in the second paragraph! However, as per your previous comment, a temporary workaround could be to just add the self loops as part of the Transform or directly to the original |
Hi, @rusty1s I try to make mutag_gin.py output a deterministic result. Following the above suggestions, I have changed the dataset to SparseTensor,
Any help would be appreciated. Thanks. |
I have encontered the same problem, have you figured it out? |
You need to use |
Closing this issue as there seems no action item, but feel free to create a new issue or discussion. |
I am trying to use GCN and GAT from library and getting this error :
I tried to add
torch.use_deterministic_algorithms(True)
but not workingSame code is working well on CPU.
How I can avoid this error?
The text was updated successfully, but these errors were encountered: