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

refact: the DPA2 descriptor #3758

Merged
merged 42 commits into from
May 10, 2024
Merged

refact: the DPA2 descriptor #3758

merged 42 commits into from
May 10, 2024

Conversation

iProzd
Copy link
Collaborator

@iProzd iProzd commented May 7, 2024

  • Refact the DPA2 descriptor in PyTorch with clearer interface
  • Support residual
  • Remove bn
  • Add numpy implement

Summary by CodeRabbit

  • New Features

    • Added a new descriptor class DescrptDPA2 implementing DPA-2 functionality for computing descriptors and representations based on input coordinates and atom types.
    • Expanded supported backends for DPA-2 descriptor to include DP in addition to PyTorch.
  • Documentation

    • Updated the supported backends information in the documentation for the DPA-2 descriptor to reflect the addition of DP backend support.
    • Added a reference to the model implementation and a training example link in the DPA-2 descriptor documentation.
  • Tests

    • Introduced test cases for the DescrptDPA2 class in different frameworks like TensorFlow, PyTorch, and DeepMD to cover various parameters and configurations.
    • Validated the functionality of the DescrptDPA2 descriptor class for deep learning models in the test case class TestDescrptDPA2.

iProzd and others added 17 commits April 25, 2024 21:56
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Duo <[email protected]>
Copy link
Contributor

coderabbitai bot commented May 7, 2024

Warning

Rate Limit Exceeded

@iProzd has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 1 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between f17f40f and e223336.

Walkthrough

The recent updates focus on enhancing the deepmd module by refining documentation, optimizing imports, and enriching class functionalities. These changes aim to improve clarity, functionality, and compatibility within the module, including method descriptions, class replacements, and support for new modes and functionalities.

Changes

Files Summary of Changes
deepmd/pt/model/descriptor/dpa2.py - Introduces DescrptDPA2 class for DPA-2 descriptor functionality.
- Adds properties dim_out and dim_emb.
- Updates imports and includes new modules and classes.
deepmd/pt/model/descriptor/repformers.py - Replaces SimpleLinear with MLPLayer.
- Updates se_repformer class parameters and forward method implementation.
deepmd/utils/argcheck.py - Adds env_protection argument with optional default value and updates related functions' documentation.
doc/model/dpa2.md - Expands supported backends for DPA-2 descriptor to include DP in addition to PyTorch.
- Updates model references and training examples.
source/tests/common/dpmodel/test_descriptor_dpa2.py,
source/tests/consistent/descriptor/test_dpa2.py
- Introduces test classes and methods to validate DescrptDPA2 functionality across different frameworks.
- Adds setups for testing various scenarios and defining tolerances.

This summary condenses the changes across different files for a more concise overview.


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>.
    • 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 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.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

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: 11

Out of diff range and nitpick comments (1)
deepmd/pt/model/descriptor/repformer_layer.py (1)

271-290: Review the initialization parameters of Atten2Map.

Consider adding default values for parameters such as has_gate and smooth in the Atten2Map class to enhance usability and avoid potential errors if these parameters are not provided.

deepmd/pt/model/descriptor/dpa2.py Show resolved Hide resolved
deepmd/pt/model/descriptor/dpa2.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa1.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/repformers.py Outdated Show resolved Hide resolved
deepmd/dpmodel/descriptor/repformers.py Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Outdated Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Outdated Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Outdated Show resolved Hide resolved
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: 5

Out of diff range and nitpick comments (2)
deepmd/pt/model/descriptor/repformer_layer.py (2)

32-67: Consider adding type hints for _scale and _mode in the get_residual function to improve code readability and maintainability.


494-494: Plan to refactor grrg for reuse across descriptors.

The method grrg could be reused in different descriptors. Plan a refactoring in a future PR to improve code reuse and maintainability.

deepmd/pt/model/descriptor/repformer_layer.py Outdated Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Show resolved Hide resolved
deepmd/pt/model/descriptor/repformer_layer.py Show resolved Hide resolved
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: 7

doc/model/dpa2.md Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa2.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa2.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa2.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa2.py Show resolved Hide resolved
deepmd/dpmodel/descriptor/dpa2.py Show resolved Hide resolved
deepmd/pt/model/descriptor/dpa2.py Show resolved Hide resolved
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

Out of diff range and nitpick comments (1)
deepmd/pt/model/descriptor/repformer_layer.py (1)

32-67: Consider adding type hints for all parameters in the get_residual function to enhance code readability and maintainability.

@iProzd iProzd requested review from njzjz and wanghan-iapcm May 10, 2024 06:19
@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue May 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 10, 2024
@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue May 10, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 10, 2024
- Refact the DPA2 descriptor in PyTorch with clearer interface
- Support residual
- Remove bn
- Add numpy implement

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added a new descriptor class `DescrptDPA2` implementing DPA-2
functionality for computing descriptors and representations based on
input coordinates and atom types.
- Expanded supported backends for DPA-2 descriptor to include DP in
addition to PyTorch.

- **Documentation**
- Updated the supported backends information in the documentation for
the DPA-2 descriptor to reflect the addition of DP backend support.
- Added a reference to the model implementation and a training example
link in the DPA-2 descriptor documentation.

- **Tests**
- Introduced test cases for the `DescrptDPA2` class in different
frameworks like TensorFlow, PyTorch, and DeepMD to cover various
parameters and configurations.
- Validated the functionality of the `DescrptDPA2` descriptor class for
deep learning models in the test case class `TestDescrptDPA2`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 10, 2024
@iProzd iProzd added this pull request to the merge queue May 10, 2024
Merged via the queue into deepmodeling:devel with commit 74dce7f May 10, 2024
60 checks passed
@iProzd iProzd deleted the rf_dpa2_consist branch May 10, 2024 09:42
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
- Refact the DPA2 descriptor in PyTorch with clearer interface
- Support residual
- Remove bn
- Add numpy implement

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added a new descriptor class `DescrptDPA2` implementing DPA-2
functionality for computing descriptors and representations based on
input coordinates and atom types.
- Expanded supported backends for DPA-2 descriptor to include DP in
addition to PyTorch.

- **Documentation**
- Updated the supported backends information in the documentation for
the DPA-2 descriptor to reflect the addition of DP backend support.
- Added a reference to the model implementation and a training example
link in the DPA-2 descriptor documentation.

- **Tests**
- Introduced test cases for the `DescrptDPA2` class in different
frameworks like TensorFlow, PyTorch, and DeepMD to cover various
parameters and configurations.
- Validated the functionality of the `DescrptDPA2` descriptor class for
deep learning models in the test case class `TestDescrptDPA2`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Duo <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] pt: refactor DPA-2 in the PyTorch backend
3 participants