-
Notifications
You must be signed in to change notification settings - Fork 29
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
TorchForce
-equipped System
object errs upon serialization/deserialization
#37
Comments
This has to do with the details of how SWIG generated wrappers work. Deserialization is implemented in C++. SWIG has to generate a Python wrapper object for each force in the system, but it only knows how to do that for force classes that are built into OpenMM, not ones that are defined by separate plugins. It just returns a generic Force object rather than a TorchForce. Pass that object to |
alright. slight confusion: once i deserialize a |
I'm not quite sure what you mean by "replacing" it. If you want to call a TorchForce method on it, then instead of writing (for example) force = system.getForce(0) you would instead write force = TorchForce.cast(system.getForce(0))
That sounds like something is messed up internally. Can you provide the code that leads to that exception? |
so in this gist, between which cells should I be calling |
I don't see anywhere you would need to cast it. Once you add the TorchForce to the System, you never reference it again. The Python Force object is just a lightweight wrapper around a C++ object. Initially you create a TorchForce Python object, which wraps a TorchForce C++ object. That's stored in the System. But when you call |
right, i didn't think i would have to cast it. so it isnt obvious why i'm getting a null error in cell 25? |
You're running into (this error)[https://github.com/openmm/openmm/issues/3098]. The exception just has the wrong message. Most likely it's a NaN. |
duly noted. but from the gist, I am creating a context, setting postions, and getting a non-nan energy before serializing/deserializing the system. there is only an error after I am creating a context with the deserialized system (and setting the same, previous positions) |
also, I am adding a global parameter to the torchforce, which exists in the |
Here's the actual error that's being thrown:
It looks like the serialization proxy isn't saving and restoring the global parameters correctly. Let me fix that! |
Can you verify this fixes the problem for you? Then I can make a new release. |
it appears that a
TorchForce
-equipped system loses itsTorchForce
-specificGlobalParameter
after the system is serialized/deserialized. It also seems that when i equip the deserialized system to a context and try to retrieve the energy, i get aNULL
errorgist
zipped yaml droplet of conda env:
tre.zip
The text was updated successfully, but these errors were encountered: