Skip to content

Refactor the neighbor list for training#274

Closed
chrisiacovella wants to merge 5 commits intochoderalab:train-on-dipol-momentfrom
chrisiacovella:ref-training_nlist
Closed

Refactor the neighbor list for training#274
chrisiacovella wants to merge 5 commits intochoderalab:train-on-dipol-momentfrom
chrisiacovella:ref-training_nlist

Conversation

@chrisiacovella
Copy link
Copy Markdown
Member

@chrisiacovella chrisiacovella commented Oct 10, 2024

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.

  • The key logic used in what had been the NeighborList class is merged in the CalculateInteractingPairs class.
  • The Neighborlist class has been removed.
  • CalculateInteractingPairs is renamed NeighborListForTraining and moved to the neighbors.py file
  • The PairList class has been moved to the neighbors.py file
  • Update documentation to reflect the naming changes and locations of several key classes.

Associated Issue(s)

Pull Request Checklist

  • Issue(s) raised/addressed and linked
  • Includes appropriate unit test(s)
  • Appropriate docstring(s) added/updated
  • Appropriate .rst doc file(s) added/updated
  • PR is ready for review

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 93.13725% with 7 lines in your changes missing coverage. Please review.

Project coverage is 84.04%. Comparing base (385ee66) to head (01f1043).
Report is 18 commits behind head on main.

Additional details and impacted files

@chrisiacovella chrisiacovella changed the title Ref training nlist Refactor the neighbor list for training Oct 10, 2024
@wiederm wiederm changed the base branch from main to train-on-dipol-moment October 10, 2024 08:00
Copy link
Copy Markdown
Member

@wiederm wiederm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
# """
#
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here and ff

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"
# )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

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]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a few linebreaks here, can we reformat this?

@wiederm wiederm deleted the branch choderalab:train-on-dipol-moment October 10, 2024 12:18
@wiederm wiederm closed this Oct 10, 2024
@chrisiacovella chrisiacovella self-assigned this Oct 10, 2024
@chrisiacovella chrisiacovella mentioned this pull request Oct 10, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants