-
Notifications
You must be signed in to change notification settings - Fork 2
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
Caching destroys computational graph #62
Comments
What happens if you set |
this might make the error go away, but might also give wrong results, since the new cell is not part of the computational graph and only the old one is |
Yes, I wasn't thinking clearly. It seems that some more plumbing is required to make |
Yes I have to check if the forces are really correct though. But, if we are the code inside a metatensor atomistic model we are not doing the gradients by ourselves and can't keep the graph. And additionally, I think it is a bad experience if you get faced with an error when you try to call backward. I would argue to remove the caching or make it optional. What was the speedup you got @ceriottm from the caching? We didn't report it in the PR. If we make it optional, I would turn it off by default and we have to state that one has to keep if one calls forward a second time. HOWEVER, we can only do this if the if the forces are correct which is something to be tested. |
I tried Better also for the tests would be to have some structures with the same cell but different positions and consequently forces. |
I vote for making it optional other opinions? |
The recently introduced caching in #43 does not make it possible to use backward a second in a PMEPotential instance when the cell is not changing. The first time one calls backward on a calculator works fine
But, if you reuse the calculator and compute the potential a second time
You get a RuntimeError stating that
This is introduced by the caching because if one changes the cell to something like
cell = 4 * torch.eye(3, requires_grad=True)
. Thebackward()
call works without problems.I am not sure but this problem might also be related to solving #57.
Thanks to @Luthaf who tracked this down
The text was updated successfully, but these errors were encountered: