Propagate method from MessagePassing class in PyTorch Geometric not determisitic

Hi all,

I have an issue with not being able to reproduce the same output with the same input using the propagate method from the MessagePassing class from torch_geometric.nn (if it matters, aggr=‘mean’). I’ve narrowed it down to being that method specifically, by checking that everything in my own message method is deterministic. I’m otherwise using torch.manual_seed, but there seems to be some randomness induced by that specific method.

My question then follows:

  1. Why is there even randomness in that method to begin with? Am I missing something, or isn’t it desired to have the same aggregated message for the same input?

  2. How can I overcome this, as it is inducing problems for my downstream task?

I’m not exactly sure of the rules of conduct in regards to @'ing people, but I’ve seen other posts doing. If I’m overstepping, sorry in advance. @ptrblck @albanD

`    def forward(self, x, edge_index, edge_attr):
        node_embed = self.propagate(edge_index , x=x, edge_attr = edge_attr) 
        return node_embed

and:

sum(self.propagate(edge_index , x=x, edge_attr = edge_attr)-self.propagate(edge_index , x=x, edge_attr = edge_attr))
tensor([ 1.6689e-06, -8.1956e-07,  2.9802e-08, -1.0431e-07, -5.0664e-07,
         2.3842e-07, -1.0431e-07, -4.2468e-07, -1.4007e-06,  5.1409e-07,
        -9.5367e-07, -9.5367e-07, -2.9802e-08, -2.3842e-07, -2.8312e-07,
         1.7881e-07,  2.9802e-08, -9.5367e-07, -2.9802e-07, -2.9802e-08,
        -4.7684e-07, -2.3842e-07, -9.5367e-07,  0.0000e+00,  1.0431e-07,
         4.7684e-07,  4.7684e-07,  1.6689e-06,  0.0000e+00,  0.0000e+00,
        -9.5367e-07, -2.9802e-07], device='cuda:0', grad_fn=<AddBackward0>)

Could you check the Reproducibility docs and check, if you’ve followed all advices?

I’m not a huge fan of tagging certain users, as it could discourage others to post a valid answer, unless you want to directly address this user for some reason.

1 Like