deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.41k stars 487 forks source link

feat: add has_message_passing API #3851

Closed njzjz closed 1 month ago

njzjz commented 1 month ago

Fix #3713. Fix #3733. This is a breaking change.

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago
Walkthrough ## Walkthrough The recent changes introduce a new method `has_message_passing` across various descriptor classes in the `deepmd` project. This method returns a boolean value indicating whether a descriptor or descriptor block has message passing capability. These additions are spread across multiple files and modules within `deepmd/dpmodel/descriptor` and `deepmd/pt/model/descriptor`. ## Changes | Files/Modules | Change Summary | |------------------------------------------------------------|------------------------------------------------------------------------------------------------| | `deepmd/.../dpa1.py`, `deepmd/.../dpa2.py` | Added `has_message_passing(self) -> bool` method to indicate message passing capability. | | `deepmd/.../descriptor.py` | Introduced abstract method `has_message_passing` in `DescriptorBlock` class. | | `deepmd/.../repformers.py` | Added `has_message_passing(self) -> bool` method to `DescriptorBlock` class. | | `deepmd/.../se_a.py`, `deepmd/.../se_atten.py`, `deepmd/.../se_t.py` | Added `has_message_passing(self) -> bool` method to `Descriptor` class. | ## Assessment against linked issues | Objective (Issue #) | Addressed | Explanation | |-------------------------------------------------------------------|-----------|-----------------------------------------------------| | Replace string search with API call in freeze function (#3713) | ❓ | The changes add `has_message_passing` but do not directly address replacing string search. | | Implement API to decide if message passing is needed (#3733) | ✅ | |

Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between a87e3c2365b8409d2002a1b6f7743d04d5e5463c and 6e441a54d4fbd76c56db9ca2aef64561d0811a16.
Files selected for processing (11) * deepmd/dpmodel/descriptor/descriptor.py (1 hunks) * deepmd/dpmodel/descriptor/dpa1.py (2 hunks) * deepmd/dpmodel/descriptor/dpa2.py (1 hunks) * deepmd/dpmodel/descriptor/repformers.py (1 hunks) * deepmd/pt/model/descriptor/descriptor.py (1 hunks) * deepmd/pt/model/descriptor/dpa1.py (1 hunks) * deepmd/pt/model/descriptor/dpa2.py (1 hunks) * deepmd/pt/model/descriptor/repformers.py (1 hunks) * deepmd/pt/model/descriptor/se_a.py (2 hunks) * deepmd/pt/model/descriptor/se_atten.py (1 hunks) * deepmd/pt/model/descriptor/se_t.py (2 hunks)
Files skipped from review as they are similar to previous changes (6) * deepmd/dpmodel/descriptor/dpa1.py * deepmd/dpmodel/descriptor/dpa2.py * deepmd/pt/model/descriptor/dpa1.py * deepmd/pt/model/descriptor/dpa2.py * deepmd/pt/model/descriptor/se_a.py * deepmd/pt/model/descriptor/se_t.py
Additional comments not posted (5)
deepmd/dpmodel/descriptor/descriptor.py (1)
`129-131`: The addition of the abstract method `has_message_passing` is correctly implemented and well-documented.
deepmd/pt/model/descriptor/descriptor.py (1)
`172-174`: The addition of the abstract method `has_message_passing` is correctly implemented and well-documented.
deepmd/pt/model/descriptor/repformers.py (1)
`552-554`: The implementation of the method `has_message_passing` in `DescrptBlockRepformers` correctly overrides the abstract method from the base class and is well-documented.
deepmd/pt/model/descriptor/se_atten.py (1)
`584-587`: The implementation of `has_message_passing` correctly returns `False`, aligning with the PR objectives and the AI-generated summary.
deepmd/dpmodel/descriptor/repformers.py (1)
`390-393`: Validate return type consistency for `has_message_passing`. Please verify that all implementations of `has_message_passing` across different classes return a consistent type. This is crucial for maintaining type safety and expected behavior across the module.
--- 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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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 generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@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 as 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. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 80.64516% with 12 lines in your changes missing coverage. Please review.

Project coverage is 82.67%. Comparing base (f23c77e) to head (6e441a5). Report is 2 commits behind head on devel.

Files Patch % Lines
deepmd/dpmodel/descriptor/dpa1.py 50.00% 2 Missing :warning:
deepmd/pt/model/descriptor/se_t.py 50.00% 2 Missing :warning:
deepmd/dpmodel/atomic_model/linear_atomic_model.py 50.00% 1 Missing :warning:
...eepmd/dpmodel/atomic_model/pairtab_atomic_model.py 50.00% 1 Missing :warning:
deepmd/dpmodel/descriptor/dpa2.py 50.00% 1 Missing :warning:
deepmd/dpmodel/descriptor/hybrid.py 50.00% 1 Missing :warning:
deepmd/dpmodel/descriptor/repformers.py 50.00% 1 Missing :warning:
deepmd/dpmodel/descriptor/se_t.py 0.00% 1 Missing :warning:
deepmd/pt/model/descriptor/se_r.py 50.00% 1 Missing :warning:
deepmd/pt/model/model/frozen.py 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## devel #3851 +/- ## ========================================== + Coverage 82.63% 82.67% +0.03% ========================================== Files 515 515 Lines 49533 49609 +76 Branches 2985 2985 ========================================== + Hits 40932 41013 +81 + Misses 7690 7686 -4 + Partials 911 910 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.