Refactor the neighbor list for training#274
Closed
chrisiacovella wants to merge 5 commits intochoderalab:train-on-dipol-momentfrom
Closed
Refactor the neighbor list for training#274chrisiacovella wants to merge 5 commits intochoderalab:train-on-dipol-momentfrom
chrisiacovella wants to merge 5 commits intochoderalab:train-on-dipol-momentfrom
Conversation
wiederm
approved these changes
Oct 10, 2024
Member
wiederm
left a comment
There was a problem hiding this comment.
That's great! I think this makes the code much more readable!
| Whether to regenerate the cache. | ||
| """ | ||
| from modelforge.potential.models import Pairlist | ||
| from modelforge.potential.neighbors import Pairlist |
Member
There was a problem hiding this comment.
its useful to split this off in a neighbors module!
Comment on lines
+41
to
+49
| # class PairlistData(NamedTuple): | ||
| # """ | ||
| # A namedtuple to store the outputs of the Pairlist and Neighborlist forward methods. | ||
| # | ||
| # Attributes | ||
| # ---------- | ||
| # pair_indices : torch.Tensor | ||
| # A tensor of shape (2, n_pairs) containing the indices of the interacting atom pairs. | ||
| # d_ij : torch.Tensor |
Member
There was a problem hiding this comment.
I belive the commented out code can be removed
Comment on lines
+424
to
+437
| # class ComputeInteractingAtomPairs(torch.nn.Module): | ||
| # | ||
| # def __init__(self, cutoff: float, only_unique_pairs: bool = False): | ||
| # """ | ||
| # Initialize the ComputeInteractingAtomPairs module. | ||
| # | ||
| # Parameters | ||
| # ---------- | ||
| # cutoff : float | ||
| # The cutoff distance for neighbor list calculations. | ||
| # only_unique_pairs : bool, optional | ||
| # If True, only unique pairs are returned (default is False). | ||
| # """ | ||
| # |
Comment on lines
+719
to
+725
| # if ( | ||
| # "neighborlist.calculate_distances_and_pairlist.cutoff" | ||
| # in filtered_state_dict | ||
| # ): | ||
| # filtered_state_dict["neighborlist.cutoff"] = filtered_state_dict.pop( | ||
| # "neighborlist.calculate_distances_and_pairlist.cutoff" | ||
| # ) |
Comment on lines
+104
to
+105
| # Note if the indices are not numbered from 0 to n_molecules - 1, this will not work | ||
| # E.g., bincount on [3,3,3, 4,4,4, 5,5,5] will return [0,0,0,3,3,3,3,3,3] |
Member
There was a problem hiding this comment.
there are a few linebreaks here, can we reformat this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Summary
This relates to some of the changes suggested in Issue #269. Specifically, this streamlines the Neighborlist for training. The code has changed quite a bit since these initial classes had been sketched out, and this should hopefully make things clearer and make the code easier to read. This also will reduce the need to massage the config dict inputs related to the neighbor list cutoff that currently needs to be done.
Key changes
Notable points that this PR has either accomplished or will accomplish.
NeighborListclass is merged in theCalculateInteractingPairsclass.Neighborlistclass has been removed.CalculateInteractingPairsis renamedNeighborListForTrainingand moved to the neighbors.py filePairListclass has been moved to the neighbors.py fileAssociated Issue(s)
Pull Request Checklist