-
Notifications
You must be signed in to change notification settings - Fork 18
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
Optimize SpeciesConverter of TorchANI #39
Conversation
Like with your EnergyShifter class, I don't think this repository is the right place for this. NNPOps is a collection of optimized kernels for bottleneck operations. It isn't meant to be a grab bag of minor patches to other libraries. |
Also, NNPOps is supposed to sit just above PyTorch in the stack, but below libraries that make use of it like TorchANI or TorchMD-Net. That means it can't import TorchANI. Otherwise it leads to circular dependencies. And circular dependencies lead to suffering. |
TorchANI doesn't import NNPOps, so there are no circular dependencies.
As you should remember, in March we tried to engage with TorchANI developers, but we haven't reached an agreement. |
But it might in the future. We intend that it should be able to. The point is that when you design an architecture, you need to define the position of every module within the stack. Each one can use things lower in the stack, but not anything higher up. The NNPOps Python module is meant to sit just above PyTorch, but below any library that might potentially use it (TorchANI, SchNetPack, TorchMD-Net, etc.). When you install it, that shouldn't require installing anything beyond PyTorch. If someone wants to use it, that shouldn't require them (and all their users) to install TorchANI. When you import it, that shouldn't import TorchANI.
I don't think we discussed these two features? I suggest opening an issue on the TorchANI github suggesting them. You can offer to open a PR implementing them. |
The current goal is to get the ML support into OpenMM (https://github.com/orgs/openmm/projects/1) as soon as possible. What will happen in the future, we will deal in the future.
This PR doesn't change the situation: |
No! That's the exact opposite of how you design robust software! You need to have a clear architecture and rigorously maintain it. Trust me, if you don't, you will come to regret it!
Then we need to fix that ASAP, because it breaks our architecture. For example, if the SchNetPack developers wanted to adopt our optimized kernel for computing SchNet, it would become impossible to |
I think it might help to step back and consider what the purpose of NNPOps is. Fortunately, the goal is clearly stated right at the start of the README:
That's it. Anything that doesn't fit within that goal (optimized implementations of bottleneck operations) doesn't belong in NNPOps. It goes somewhere else. Next, the README lists the core design principles. Here is the first one.
That's critical. NNPOps is meant to be self contained. You should be able to use it without bringing in lots of other dependencies. Now consider this PR. It doesn't implement any calculations at all. It's just a trivial wrapper around a TorchANI class. Its only function is to invoke the TorchANI object and stash the result in a field. That's it. I suppose you must have written this because it was useful for some code you were writing, but it has nothing to do with any of the goals of NNPOps. This isn't the right place for it. |
Check #41 for the full picture. Specifically, the example: https://github.com/openmm/NNPOps/blob/2a5da7c24590a2bd21786ad0ad4df5092690028d/README.md#example |
The first thing I would do is open one or more issues on the TorchANI repo suggesting these changes and offering to provide code. This class doesn't implement any kind of calculation. It's just a workaround for a particular flaw in TorchANI (that it repeats the calculation on every step). The more of these changes we can push upstream to them, the better. For anything they don't want to accept, the next thing I would do is move the imports inside the classes. You should be able to Finally we should consider whether NNPOps is the best place for all of these, or whether, for example, OpenMM-ML would be a better place. |
Let's move the discussion to #40. It is more general than this PR. |
@peastman can we proceed with this? |
Go ahead. |
This assume that a molecule is constant, so the atomic number conversion to species can be pre-computed.
TorchANISpeciesConverter