RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn #152
-
Hey all! I'm trying to call
Has anyone seen this error before? Any clue as to what this means or how to solve it would be greatly appreciated:) thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Hi @isabel-s-rosa, would you mind sharing in what context you are doing this? Is this a "regular" NequIP model (energies, forces, ...) or is this something custom? Could you share a bit more of how you are loading + calling the model? The error appears when you call the gradient in PyTorch w.r.t. a tensor that does not have |
Beta Was this translation helpful? Give feedback.
-
Hi @isabel-s-rosa , A few things in no particular order:
|
Beta Was this translation helpful? Give feedback.
-
This also may be relevant:
Do you run |
Beta Was this translation helpful? Give feedback.
-
Another guess: when you build your input in C++, are you explicitly providing Even if this isn't your bug, it is probably something I should try to make an error rather than a silent failure... if that's possible. |
Beta Was this translation helpful? Give feedback.
-
@isabel-s-rosa, glad Alby was able to resolve the issue! On a side note, I noticed a few settings in your input file that I think are not optimal or outdated, I'll list them below and I hope they will give you better training. As Alby pointed out, we also recommend to start with
Let me know if you have questions + good luck! |
Beta Was this translation helpful? Give feedback.
Another guess: when you build your input in C++, are you explicitly providing
edge_vectors
? That would break the autograd graph and give exactly this error. The network should only be provided withpos
,edge_index
, anedge_cell_shift
(in the periodic case) so that it can buildedge_vectors
out ofpos
so that taking grad w.r.t.pos
gives the right answer.Even if this isn't your bug, it is probably something I should try to make an error rather than a silent failure... if that's possible.