-
Notifications
You must be signed in to change notification settings - Fork 11
Enable NanoPET for atomic-basis spherical targets #527
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: main
Are you sure you want to change the base?
Conversation
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.
Just checked the model part for now, I will check the data augmentation and infrastructure parts later
docs/src/advanced-concepts/fitting-atomic-basis-spherical-targets.rst
Outdated
Show resolved
Hide resolved
docs/src/advanced-concepts/fitting-atomic-basis-spherical-targets.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Filippo Bigi <[email protected]> Co-authored-by: Paolo Pegolo <paolo.pegolo.epfl.ch>
Co-authored-by: Paolo Pegolo <[email protected]>
@Luthaf @frostedoyster @ppegolo here's an update - ready for review when you're ready! On my side, still to do (but shouldn't affect review in the meantime):
|
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.
I'm not sure how much I understand the changes to PET, so I'll let someone else check this part.
One question is how much work would it be to port this to NativePET?
# symmetrize the PET edge features and pass through its head | ||
if ( | ||
self.atomic_basis_target_info[output_name]["sample_kind"] | ||
== "per_pair_sym" |
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.
why is this a different kind of sample?
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.
Because in this case the PET features are still one whole block (i.e. we haven't sliced by s2_pi/first_atom_type/second_atom_type yet), and because it is symmetrized the normal samples aren't complete in info: we have "duplicated" samples that carry the index s2_pi=+/-1
# First, build the indices that split the block samples by system | ||
split_indices: List[int] = [] | ||
|
||
if target_type == "spherical": |
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.
what's the difference between target_type == "spherical"
and target_type == "atomic_basis_spherical"
?
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.
atomic basis spherical doesn't have all the atomic samples in a given block - only those with the corresponding to the atom types. The splitting along the samples axis needs more care than for pure spherical targets
s2_pi: int, | ||
) -> List[int]: | ||
""" | ||
Finds the indices that splits a TensorBlock along the samples axis by system 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.
Is this an implementation of metatensor/metatensor#627?
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 :)
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 @jwa7, it looks good. I think it would be nice to have some test. If merging is not urgent, I can also write a test when I have some time. I still haven't looked at the changes in the model
docs/src/advanced-concepts/fitting-atomic-basis-spherical-targets.rst
Outdated
Show resolved
Hide resolved
docs/src/advanced-concepts/fitting-atomic-basis-spherical-targets.rst
Outdated
Show resolved
Hide resolved
src/metatrain/utils/data/dataset.py
Outdated
tensor_map = join( | ||
[ | ||
_empty_tensor_map_like(self[tensor_i][target_key]) | ||
for tensor_i in range(len(self)) | ||
], | ||
"samples", | ||
remove_tensor_name=True, | ||
different_keys="union", | ||
) |
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.
This will be terribly slow (and run out of memory) with a large dataset
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.
Not sure what a good solution is though...
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.
This has now been moved so that it only affects spherical_atomic_basis
targets, but is still unresolved. Needs some thought...
…tesian`... etc bools
An update on the current progress: From the perspective of the original goals of this PR, this is almost ready. The only things left to do is figure out an issue with samples slicing in the case of per-pair targets. However, in light of recent discussions, it seems appropriate to put this work on pause temporarily until other issues are figured out. These are:
Then, on top of these changes, this PR can be steered in the following way:
|
Extends NanoPET to enable predictions of spherical targets expressed on an atomic basis. Examples are the electron density decomposed on an auxiliary basis, and the Hamiltonian on the coupled atomic orbital basis.
Overview
NanoPET architecture details
Other metatrain infrastructure details
join_kwargs={"different_keys": "union"}
as this is required for targets on an atomic basis where different systems have different atom types (and therefore keys)TargetInfo
has been modified to include attributes such astarget_type: str
andsample_kind: str
. The former is used to replace all theis_scalar
,is_cartesian
, ... etc bool flagsContributor (creator of pull-request) checklist
[ ] Issue referenced (for PRs that solve an issue)?Reviewer checklist
📚 Documentation preview 📚: https://metatrain--527.org.readthedocs.build/en/527/