Skip to content
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

fix dplr: support initializing from a restart file #4084

Merged
merged 35 commits into from
Nov 7, 2024

Conversation

Yi-FanLi
Copy link
Collaborator

@Yi-FanLi Yi-FanLi commented Aug 28, 2024

Thie PR aims at fixing #3679.

The get_valid_pairs will raise an error when

  1. reading a restart file written from previous dplr jobs
  2. reading a data file written from previous dplr jobs
  3. executing 'run 0' for twice

The origin is that the check in get_valid_pairs is too strict for the initialization process. The check requires that a pair of real and virtual atoms found by iterating over the bondlist to be the local atoms of the same processor. This requirement is automatically satisfied during the running of MD because the positions of virtual atoms are set equal to those of real atoms before rebuilding bondlists. However, during initialization (Verlet::setup(int flag)), the bondlist is built based on the initial configuration provided by the user. If the user provides a configuration in which the virtual atoms are placed at the Wannier centroids, it is possible that a bond formed by a pair of real and virtual atoms are between a local and a ghost atom, which triggers this error.

This PR loosens the requirement on the initial configuration provided by the user. In the setup_post_neighbor function, the get_valid_pairs function searches for bonded pairs but skips the aforementioned check. It sets the coordinates of the virtual atoms to the coordinates of the real atoms, and then rebuilds the bondlist. Afterwards, the check can be passed.

Summary by CodeRabbit

  • New Features
    • Introduced a new method for setting up pre-exchange operations, enhancing simulation lifecycle management.
  • Changes
    • Renamed the post_integrate method to pre_exchange to better reflect its role in the simulation process.
    • Updated mask settings to improve clarity and context within the simulation lifecycle.
  • Chores
    • Updated ownership context for Docker image in the build workflow configuration.

Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes involve renaming the post_integrate() method to pre_exchange() in the FixDPLR class, updating its associated mask from POST_INTEGRATE to PRE_EXCHANGE, and introducing a new method setup_pre_exchange(). Additionally, the GitHub Actions workflow has been modified to reflect a change in the repository owner for building and pushing a Docker image.

Changes

Files Change Summary
source/lmp/fix_dplr.cpp Renamed post_integrate() to pre_exchange(), changed mask from POST_INTEGRATE to PRE_EXCHANGE, and added setup_pre_exchange().
source/lmp/fix_dplr.h Renamed post_integrate() to pre_exchange() in class declaration and added setup_pre_exchange().
.github/workflows/build_wheel.yml Updated Docker image ownership from deepmodeling to Yi-FanLi in the workflow configuration.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Yi-FanLi Yi-FanLi marked this pull request as draft August 28, 2024 06:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
source/lmp/fix_dplr.h (1)

47-47: Incomplete Renaming Detected

The method post_integrate() is still being referenced in source/lmp/fix_dplr.cpp. Please ensure that all occurrences of post_integrate() are updated to end_of_step() to maintain consistency across the codebase.

  • File: source/lmp/fix_dplr.cpp
  • Line: Reference found in min_pre_exchange() method.
Analysis chain

Method Renaming Approved

The renaming of post_integrate() to end_of_step() is appropriate for the described functionality. Ensure that all references to this method in the codebase are updated accordingly.

The code changes are approved.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `post_integrate` are updated to `end_of_step`.

# Test: Search for the old function name. Expect: No occurrences.
rg --type cpp -A 5 $'post_integrate'

Length of output: 375

source/lmp/fix_dplr.cpp (1)

402-402: Incomplete Renaming Detected

The function post_integrate is still being referenced in the min_pre_exchange method within source/lmp/fix_dplr.cpp. Please update all occurrences of post_integrate to end_of_step to ensure consistency and prevent potential errors.

  • File: source/lmp/fix_dplr.cpp
  • Line: void FixDPLR::min_pre_exchange() { post_integrate(); }
Analysis chain

Method Implementation and Renaming Approved

The implementation of end_of_step() correctly updates the WC positions as intended. Ensure that all references to this method in the codebase are updated accordingly.

The code changes are approved.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `post_integrate` are updated to `end_of_step`.

# Test: Search for the old function name. Expect: No occurrences.
rg --type cpp -A 5 $'post_integrate'

Length of output: 375

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.07%. Comparing base (dabedd2) to head (97527e6).
Report is 4 commits behind head on devel.

Files with missing lines Patch % Lines
source/lmp/fix_dplr.cpp 86.84% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4084      +/-   ##
==========================================
- Coverage   84.40%   84.07%   -0.33%     
==========================================
  Files         570      570              
  Lines       53071    53099      +28     
  Branches     3054     3059       +5     
==========================================
- Hits        44794    44643     -151     
- Misses       7318     7494     +176     
- Partials      959      962       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@njzjz njzjz linked an issue Aug 28, 2024 that may be closed by this pull request
@Yi-FanLi Yi-FanLi closed this Aug 28, 2024
@Yi-FanLi Yi-FanLi reopened this Aug 28, 2024
variables = data.pop("@variables")
embeddings = data.pop("embeddings")
attention_layers = data.pop("attention_layers")
env_mat = data.pop("env_mat")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable env_mat is not used.
data.pop("type")
variables = data.pop("@variables")
embeddings = data.pop("embeddings")
env_mat = data.pop("env_mat")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable env_mat is not used.
@@ -12,10 +11,10 @@


@overload
def child_seed(seed: Union[int, List[int]], idx: int) -> List[int]: ...
def child_seed(seed: Union[int, list[int]], idx: int) -> list[int]: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.
Comment on lines 65 to 75
def eval(
self,
coords: np.ndarray,
cells: Optional[np.ndarray],
atom_types: Union[list[int], np.ndarray],
atomic: bool = False,
fparam: Optional[np.ndarray] = None,
aparam: Optional[np.ndarray] = None,
mixed_type: bool = False,
**kwargs: dict[str, Any],
) -> tuple[np.ndarray, ...]:

Check notice

Code scanning / CodeQL

Returning tuples with varying lengths Note

DeepProperty.eval returns
tuple of size 1
and
tuple of size 2
.
@@ -29,7 +28,7 @@
real_f: Optional[np.ndarray] = None,
relative: Optional[float] = None,
atomic: Literal[False] = ...,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]: ...
) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.


@overload
def to_jax_array(array: np.ndarray) -> jnp.ndarray: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.


@overload
def to_jax_array(array: None) -> None: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.
)

if TYPE_CHECKING:
import ase.neighborlist

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'ase' is not used.
)
elif model_file.endswith(".hlo"):
model = BaseModel.deserialize(data["model"])
model_def_script = data["model_def_script"]

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable model_def_script is not used.
if data["repinit"].use_three_body:
# deserialize repinit_three_body
statistic_repinit_three_body = repinit_three_body_variable.pop("@variables")
env_mat = repinit_three_body_variable.pop("env_mat")

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'env_mat' is unnecessary as it is
redefined
before this value is used.
@Yi-FanLi Yi-FanLi changed the base branch from devel to r2 November 3, 2024 17:44
source/lmp/fix_dplr.cpp Fixed Show fixed Hide fixed
@Yi-FanLi Yi-FanLi requested a review from njzjz November 5, 2024 19:43
source/lmp/fix_dplr.cpp Outdated Show resolved Hide resolved
@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Nov 7, 2024
Merged via the queue into deepmodeling:devel with commit 9699349 Nov 7, 2024
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LAMMPS fix dplr issue
3 participants