deepmd-kit icon indicating copy to clipboard operation
deepmd-kit copied to clipboard

feat pt : Support property fitting in `devel` branch

Open Chengqian-Zhang opened this issue 1 year ago • 4 comments

Solve issue #3866

  • [x] successfully from scratch training and finetuning
  • [x] support extensive and intensive property
  • [x] argcheck
  • [x] multi properties(successfully test)
  • [x] example
  • [x] UT
  • [x] dp test
  • [ ] doc

Summary by CodeRabbit

  • New Features

    • Introduced property fitting neural networks with the new PropertyFittingNet class.
    • Added the DeepProperty class for evaluating properties of structures using a deep learning model.
    • Introduced EnergyModel class for energy-related property predictions.
  • Enhancements

    • Added intensive property to several classes to indicate whether a fitting property is intensive or extensive.
    • Enhanced output property definitions and manipulation methods in various models for better property evaluation.
  • Documentation

    • Added a README file in examples/property/ providing descriptions of the included dataset and properties.
    • Introduced files with type mappings and raw data sequences for property datasets.

Chengqian-Zhang avatar Jun 12 '24 10:06 Chengqian-Zhang

Walkthrough

Walkthrough

The recent updates enhance the DeepMD framework by introducing new classes and methods focused on property fitting and evaluation. Key additions include the PropertyFittingNet class for neural network fitting, the DeepProperty class for evaluating properties, and various modifications to incorporate intensive properties. Additionally, the DeepEvalWrapper class has been updated to support new model types and provide detailed information about model characteristics.

Changes

Files Change Summary
deepmd/dpmodel/fitting/property_fitting.py Added the PropertyFittingNet class for property fitting neural networks, including methods for initialization, serialization, and deserialization.
deepmd/dpmodel/output_def.py Updated OutputVariableDef class to include an intensive boolean attribute, modified the constructor to accept this parameter, and added a validation check.
deepmd/infer/deep_eval.py, deepmd/infer/deep_property.py Introduced mappings for properties, a new abstract method get_intensive, and the DeepProperty class for evaluating structural properties using deep learning models.
deepmd/pt/model/atomic_model/base_atomic_model.py, deepmd/pt/model/atomic_model/dp_atomic_model.py, deepmd/pt/model/atomic_model/property_atomic_model.py Added the get_intensive method and introduced DPPropertyAtomicModel class for property intensiveness retrieval.
deepmd/pt/model/model/property_model.py Added PropertyModel class with methods for forward pass, task dimension retrieval, and checking if output is intensive.
deepmd/pt/train/training.py Introduced PropertyLoss to handle property loss types within the training process, enhancing model training capabilities.
deepmd/pt/utils/stat.py Included intensive parameter in compute_output_stats and compute_output_stats_global functions for fitting property classification.
deepmd/pt/model/model/__init__.py Updated imports and modified get_standard_model logic to accommodate the new PropertyModel, including integration with IPython.
source/tests/common/test_examples.py Added a new example file path for testing related to the "property" category, expanding the test coverage.
source/tests/universal/common/cases/atomic_model/atomic_model.py, source/tests/universal/common/cases/model/model.py Introduced new test classes PropertyAtomicModelTest and PropertyModelTest to validate the properties and functionalities of the new models.
source/tests/universal/dpmodel/atomc_model/test_atomic_model.py Added TestPropertyAtomicModelDP class for testing property atomic model functionalities, including new fitting parameters and descriptors.
source/tests/universal/pt/atomc_model/test_atomic_model.py Introduced TestPropertyAtomicModelPT class for parameterized tests with property-specific fitting parameters and descriptors.
source/tests/universal/pt/fitting/test_fitting.py Added PropertyFittingNet and FittingParamProperty to enhance the testing capabilities related to property fitting functionalities.
source/tests/universal/pt/model/test_model.py Introduced TestPropertyModelPT class to rigorously validate the PropertyModel with parameterized tests and dynamic input variations.
deepmd/pt/infer/deep_eval.py Added get_intensive and get_task_dim methods in DeepEvalWrapper to retrieve model characteristics and output dimensions.

Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL

Commits

Files that changed from the base of the PR and between dde48fd4646d96015493ec16e32d35b7ae530122 and 4d8934fda6b16a75010c05ec4972b005b1a92cf7.

Files selected for processing (1)
  • deepmd/pt/infer/deep_eval.py (4 hunks)
Additional comments not posted (2)
deepmd/pt/infer/deep_eval.py (2)

172-173: LGTM!

The code changes are approved.


209-211: LGTM!

The code changes are approved.


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

coderabbitai[bot] avatar Jun 12 '24 10:06 coderabbitai[bot]

Codecov Report

Attention: Patch coverage is 87.91541% with 40 lines in your changes missing coverage. Please review.

Project coverage is 83.06%. Comparing base (46632f9) to head (4d8934f). Report is 203 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/pt/loss/property.py 47.72% 23 Missing :warning:
deepmd/entrypoints/test.py 86.56% 9 Missing :warning:
...epmd/dpmodel/atomic_model/property_atomic_model.py 0.00% 6 Missing :warning:
deepmd/dpmodel/model/property_model.py 80.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3867      +/-   ##
==========================================
+ Coverage   83.01%   83.06%   +0.05%     
==========================================
  Files         524      532       +8     
  Lines       51642    51971     +329     
  Branches     3030     3030              
==========================================
+ Hits        42871    43171     +300     
- Misses       7825     7855      +30     
+ Partials      946      945       -1     

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

codecov[bot] avatar Jun 12 '24 10:06 codecov[bot]

Lack dp test on property and doc for property fitting. You can review other codes and iterate the code together.

Chengqian-Zhang avatar Jun 17 '24 07:06 Chengqian-Zhang

I notice that in deepmd/dpmodel/model/ener_model.py, the EnergyModel class only implement __init__ method. I do not know why. Currently I only implement __init__ method in class PropertyModel in deepmd/dpmodel/model/property_model.py as well like ener_model.py.

Chengqian-Zhang avatar Jun 28 '24 07:06 Chengqian-Zhang

  1. I add attribute intensive to OutputVariableDef. An intensive variable must be reducible. If a variable is intensive, doing reduce is to average the output of all the atoms instead of summing them, refer to ” deepmd/pt/model/model/transform_output.py”.
  2. When calculating output bias, for intensive variables, we need to multiply the value of the variable by the number of atoms before performing linear regression calculation, see “deepmd/pt/utils/stat.py” for details.

Chengqian-Zhang avatar Aug 27 '24 18:08 Chengqian-Zhang

  1. Add new class to source/tests/universal
  2. Add UT for intensive in output_def
  3. Add doc str for the arguments of the PropertyFittingNet class init.

Chengqian-Zhang avatar Aug 28 '24 16:08 Chengqian-Zhang

I find that we lack UT for all functions of deepmd/pt/model/model/transform_output.py and deepmd/dpmodel/model/transform_output.py, I will add UT tomorrow.

Chengqian-Zhang avatar Aug 28 '24 16:08 Chengqian-Zhang

+ Hits        42870    43087     +217     
- Misses       7822     7934     +112     
- Partials      946      948       +2     

I see that 1/3 of the new codes have not been tested.

njzjz avatar Sep 02 '24 18:09 njzjz

+ Hits        42870    43087     +217     
- Misses       7822     7934     +112     
- Partials      946      948       +2     

I see that 1/3 of the new codes have not been tested.

Where can I see these datas about missing UT? I will add UT based on these datas.

Chengqian-Zhang avatar Sep 03 '24 02:09 Chengqian-Zhang

+ Hits        42870    43087     +217     
- Misses       7822     7934     +112     
- Partials      946      948       +2     

I see that 1/3 of the new codes have not been tested.

Where can I see these datas about missing UT? I will add UT based on these datas.

You can click the link sent by @codecov or click the codecov checks.

It looks like the loss module is not tested. @iProzd Do we have a universal test fixture for loss functions?

njzjz avatar Sep 03 '24 19:09 njzjz

+ Hits        42870    43087     +217     
- Misses       7822     7934     +112     
- Partials      946      948       +2     

I see that 1/3 of the new codes have not been tested.

Where can I see these datas about missing UT? I will add UT based on these datas.

You can click the link sent by @codecov or click the codecov checks.

It looks like the loss module is not tested. @iProzd Do we have a universal test fixture for loss functions?

Not yet, maybe we need a discussion to design a universal test for loss modules.

iProzd avatar Sep 05 '24 12:09 iProzd