-
Notifications
You must be signed in to change notification settings - Fork 55
Add metatensor models #124
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
Conversation
|
We require contributors to sign our Contributor License Agreement (CLA), and we don't have record of your signature. In order for us to review and merge your code, please sign the CLA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start, I would be a little bit cautious about including the batched autograd code in this repo for forces and stresses as it seems as though it could differ for future models and "MetaTensor" seems as though it may be a collection of models in the future c.f. fairchem or graphpes and so it may be more maintainable if that logic lives in your repo? That wouldn't be a reason not to merge but worth some thought.
This is a conscious design decision that was made in |
torch_sim/models/metatensor.py
Outdated
| if not neighbor_list_options.full_list: | ||
| raise ValueError( | ||
| "Neighbor list options must be full for metatensor models to " | ||
| "be used in torchsim." | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because neighbor_list_fn can only return full NL? I think we should still support half NL, because that's still a relevant use case for some model. I can help with an implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as far as I understand torch-sim has an interface for the NLs which doesn't support half NLs. Currently, the only backend for this interface seems to be vesin-torch. @CompRhys please correct me if I'm wrong. Anyway, a full NL should cover >90% of models in practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the default neighbor list is vesin-torch but you can change that. All of them are tested against ase neighborlist implement. You can turn off the full NL here https://github.com/Radical-AI/torch-sim/blob/c79fc6591802df53a5fd0869b96715826ef0d09e/torch_sim/neighbors.py#L547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can models request a different NL from torch-sim? Or is the API of neighbor_list_fn defined around full NL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can request a different NL when you initialize the model. For example, in MACE https://github.com/Radical-AI/torch-sim/blob/c79fc6591802df53a5fd0869b96715826ef0d09e/torch_sim/models/mace.py#L105
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I updated this!
Co-authored-by: Guillaume Fraux <luthaf@luthaf.fr> Signed-off-by: Filippo Bigi <98903385+frostedoyster@users.noreply.github.com>
91c5b25 to
e51eadd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @frostedoyster, this will be very nice interface to have.
Couple comments just to make sure the interface behaves as intended.
For added context, I want to point you to our Current Posture on Model Interfaces, just to share how we are thinking about supporting models over time.
torch_sim/models/metatensor.py
Outdated
| ) | ||
|
|
||
| # Calculate neighbor list(s) for this system | ||
| for neighbor_list_options in self._requested_neighbor_lists: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all models in metatensor use a radial cutoff for the neighbor list?
If not, consider setting a dynamic memory_scales_with @propery. The default memory_scales_with from ModelInterface will return "n_atoms_x_density", which is only correct for models with radial cutoffs.
For max-neighbors based cutoffs, the memory scaler will be incorrect and the autobatching will subtly break. See here for a more detailed discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at the moment this interface only supports a fixed cutoff radius, although metatensor itself would allow for a clamped number of neighbors by simply feeding a filtered neighbor list. However, we have never tested this possibility in training or in production, and therefore I would keep it as is for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also the possibility for model to set interaction_range to infinity, which is used for long-range models. I don't know if these would work with the current code, I'll check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model scaling can be handled manually for edge cases, so I am happy leaving it as n_atoms_x_density
Signed-off-by: Filippo Bigi <98903385+frostedoyster@users.noreply.github.com>
|
Sorry for all the failures:
|
|
We require contributors to sign our Contributor License Agreement (CLA), and we don't have record of your signature. In order for us to review and merge your code, please sign the CLA. |
|
Err, I already signed the CLA, and if I try to sign it again I get a |
The api that the bot checks doesn't have a signed CLA associated with the Github account "Luthaf", I don't have deeper access to check the actual records. Could you try again to register the github username, if that doesn't work we will debug further. |
|
I might have registered as |
We're very glad to see contributions and there's always some teething issues trying to get new processes to work smoothly! The SiO2 rattled structure test to test a high force configuration seems to be problematic on the Github runners for some models. We see quite big differences for MACE in CI when tests pass locally. Is that the same with PET-MAD here? |
|
The test errors on CI seems to only happen on ARM macos + float32 dtype. The tests are fine on ubuntu I can also reproduce the failure locally on another ARM mac. So I'd guess that something makes the model not work quite as well on macos+float32 (maybe a different BLAS implementation?), which the CI is showing us. I'll see what's the best way to fix that with @frostedoyster |
it's been updated it to be case insensitive, the next push to this branch should now add the signed label back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fixed the docs issue, c.f. step 7
docs/dev/add_model.md. - Fixed my incorrect rattling code to only use weibull for scale.
LGTM.
|
Thanks for the help! Just one last comment: you might want to update this line in the top-level readme to reflect all the new models that you've added recently
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I updated the README as suggested. Thanks for the contribution! I'll merge when tests are passing.
This reverts commit 8437e6d.
|
Looking back at the discussion, I am realizing I may have been a bit trigger happy in merging this, apologies. Even though the docs build worked once, it's now failing in main. Should I revert this or would you prefer to take care of any remaining issues in a new PR? EDIT: I'd suggest just opening a new PR and we can merge that in or make more changes as needed, sorry for confusion. |
Hi everyone and thanks for the great work on the library. Also, let us know if you have feedback on https://github.com/Luthaf/vesin!
Summary
metatensorfamily of models (see https://docs.metatensor.org/latest/atomistic/index.html)Checklist
Before a pull request can be merged, the following items must be checked:
Run ruff on your code.
Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply run
pre-commit installand a check will be run prior to allowing commits.