-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MLIAP Unified Generalized Interface #4673
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
base: develop
Are you sure you want to change the base?
Conversation
akohlmey
left a comment
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.
@codeformore Thanks for your contribution. Before even looking at any specific details of the implementation, I have some rather formal and fundamental suggestions for changes concerning the naming conventions of styles and keywords, and a few other LAMMPS programming style issues (especially for header file "hygiene" which is extremely important for a project as large as LAMMPS).
There will likely be suggestions from me on more details later on and also from other LAMMPS developers. However, I thought it is best to do this in stages and not overwhelm you with a huge pile of comments.
Please add your affiliation. |
|
Tagging Ben Nebgen (Los Alamos National Laboratory) @bnebgen-LANL and Nick Lubbers (Los Alamos National Laboratory) @lubbersnick who worked with us on this feature. |
|
@codeformore here is one more thing that occurred to me: your description of the |
bb295a7 to
98d2569
Compare
|
Rebased onto develop branch. |
I've pushed updates that address the feedback provided in the previous review. Please let me know if there's anything I missed. Thanks again for your time and thoughtful feedback. |
Axel, thanks for the idea. You are probably correct in that doing it via a fix would possibly make things easier. We'd like to hold off on making this shift until another time since we've got this feature working, if that is OK. We aren't seeing any performance degradation doing it as a compute. |
@bnebgen-LANL Sorry, but you are missing my point. The issue is not compute versus fix. A compute is the appropriate class to provide the information you want to make available. My point is that your compute is duplicating functionality that already exists, i.e. mapping per-atom arrays to keywords. So, to reduce code duplication, you would just create a fix property/atom instance internally from within the compute and can then store data in it and refer to it. I personally don't worry so much about performance, but I do worry about the effort required to maintain LAMMPS. The more duplicated functionality there is, the more work it is to keep things working and up-to-date. What is worse is that the interfaces are usually not exactly the same, which results in somewhat inconsistent behavior and that is something we want to reduce, if not avoid, for the sake of the users. |
| data = castedPair->data; | ||
|
|
||
| //Register the extra_property compute with the data class | ||
| data->register_extra_property(property_name, size_peratom_cols); |
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.
As @akohlmey mentioned this can likely be replaced by something that internally creates a fix property/atom. See https://github.com/lammps/lammps/blob/develop/src/RHEO/compute_rheo_interface.cpp#L66 for an example on how to create a d2_some_name X array with X columns and retrieve its index via atom->find_custom.
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 Richard. Sorry to be a pain, but is there an example in kokkos? We would want to see the correct way to do this on both sides.
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.
@stanmoore1 It seems to me that fix property/atom/kk is missing full support for IARRAY and DARRAY and isn't creating any dual views for those. So I would expect the following in atom_kokkos.h:
DAT::tdual_int_3d k_iarray;
DAT::tdual_float_3d k_darray;Also
DAT::tdual_int_2d k_ivector;seems to be missing? Same story?
@akohlmey think we are also missing something equivalent to Nevermind, it's the same index as on the host and the find_custom in atom_kokkos.h that gives us the kokkos views so we can utilize device data.k_* members are public, so all you need is to cast atom to AtomKokkos* and access the public field with the same index.
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.
@bnebgen-LANL I'm not seeing a straight forward example that you can just copy. It looks more like the Kokkos code could be extended to a more general solution and you would be the first client of it.
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 detailed suggestions and discussion.
I looked into replacing the ExtraProperties infrastructure with a fix-based approach using fix property/atom as suggested. While that pattern works well on the CPU implementation, it appears that the Kokkos version (fix property/atom/kk) currently lacks full support for DARRAY and IARRAY, including the necessary tdual_* views (as mentioned above). Without that, I don't see a straightforward way to access custom per-atom double arrays on device (please tell me if my assumption is incorrect), which we rely on for the modifications in the MLIAP unified interface.
Given this, I don't believe the fix-based pattern is currently viable on the Kokkos side without additional infrastructure. I'm happy to adapt to a unified fix property/atom interface in the future if support is added—but for now, the ExtraProperties approach provides the functionality we need for both non-Kokkos and Kokkos runs and keeps the CPU and Kokkos implementations similar.
Please let me know if you'd recommend a different approach given these constraints. I'm open to alternatives if there's a better-supported path. Thanks again for the feedback.
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.
It should be fairly trivial to add the missing dual views in fix property/atom/kk. We already have something similar in SPARTA.
|
I'm happy to go with whatever the lammps maintainers want. However, Caden is only at LANL until Friday. Is there a way we could move forward with the merge and if/when Stan or somebody else implements the appropriate dual views, I can revisit this to implement it through the fix methodology? |
@bnebgen-LANL What is the rush? We generally prefer to iterate pull requests until everybody is satisfied. At the moment, the PR doesn't even pass the automated testing. So far, we only looked at some formal details. There hasn't even been a proper review, manual tests, checks of the documentation and so on. There also are some sweeping changes coming (KOKKOS with mixed and single precision, build system updates and more. Plus we have the LAMMPS workshop next week. |
|
@bnebgen-LANL this has been idle for three months. Any updates? If there are no plans to bring this pull request into a shape that it has merge conflicts resolved and passes the automated tests (or corrects false positives in the tests), then I suggest we close this for now and you resubmit when it is closer to being complete and reviewable. |
|
Sorry. The person working on this was out sick for a while. We should make more progress soon. |
|
Hi @bnebgen-LANL, sorry for not looking at this sooner. Based on this discussion, in order for this to be accepted in to LAMMPS, I see two alternatives:
|
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.
Given the difficulties identified with the new compute extraProperty/atom command, I think it best to withdraw this PR until a clear path forward has been identified. [I have changed my mind on this, see below]
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 best path forward for this is to leverage the existing fix pair command, which was created by @sjplimp for exactly this kind of use case. It so far just has one use instance: to extract per-atom uncertainty metric from pair_style pace/extrapolation. It would be relatively easy to add a function PairMLIAP::extract_peratom() to extract pointers to uncertainties and other per-atom quantities from MLIAPData::extra_properties, see PairPACEExtrapolation::extract_peratom(). The atom uncertainties currently accessed from the compute class ComputeMLIAPPropertyAtom can just as well or better be accessed from the FixPair class. Since this can be done fairly quickly, I recommend keeping this PR open.
Summary
This implementation introduces the ability to extract named per-atom "extra properties" from machine-learned interatomic potentials (MLIAPs) implementing the unified interface, such as uncertainty metrics from ensemble models. It includes both infrastructure support in the MLIAP data handling and a new compute command for use in LAMMPS input scripts.
Key features include:
Author(s)
Caden Fischer (Los Alamos National Laboratory) - caden.fischer@gmail.com
Deepsana Shahi (Los Alamos National Laboratory) - deepsanashahi@gmail.com
Licensing
By submitting this pull request, I agree, that my contribution will be included in LAMMPS and redistributed under either the GNU General Public License version 2 (GPL v2) or the GNU Lesser General Public License version 2.1 (LGPL v2.1).
Implementation Notes
Key Components Implemented
ExtraPropertiesClassExtraPropertiesclass instantiated withinMLIAPData.std::unordered_map<std::string, double**>, where:std::stringis the name of the property (e.g.,"energy_std")double**points to the associated per-atom data (dimensioned by number of atoms × property dimension)compute extraProperty/atomCommandcomputestyle (extraProperty/atomandextraProperty/atom/kk) registers a request for a specific property name and its dimensionality.ExtraPropertiesinstance inMLIAPDatato access the requested per-atom vectors.Integration with MLIAP Unified Interface
compute_extra_property()in theMLIAPUnifiedInterface.update_extra_property(), ensuring the requested property is made available to LAMMPS viaExtraProperties.Testing Strategy
lanl/HIPPYNNto compute and expose standard deviations for properties such as potential energy.energy_stdin.mliap.unified.hippynn.ensemble.Al.txtenergy_stdin.mliap.unified.hippynn.ensemble.kk.Al.txtAll runs completed successfully and produced the expected per-atom extra property output.
Post Submission Checklist