feat pt : Support property fitting in `devel` branch
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
PropertyFittingNetclass. - Added the
DeepPropertyclass for evaluating properties of structures using a deep learning model. - Introduced
EnergyModelclass for energy-related property predictions.
- Introduced property fitting neural networks with the new
-
Enhancements
- Added
intensiveproperty 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.
- Added
-
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.
- Added a README file in
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?
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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
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.
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.
Lack dp test on property and doc for property fitting. You can review other codes and iterate the code together.
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.
- I add attribute
intensivetoOutputVariableDef. Anintensivevariable must bereducible. If a variable isintensive, doing reduce is to average the output of all the atoms instead of summing them, refer to ” deepmd/pt/model/model/transform_output.py”. - When calculating output bias, for
intensivevariables, 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.
- Add new class to
source/tests/universal - Add UT for
intensiveinoutput_def - Add doc str for the arguments of the
PropertyFittingNetclass init.
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.
+ 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.
+ Hits 42870 43087 +217 - Misses 7822 7934 +112 - Partials 946 948 +2I 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.
+ Hits 42870 43087 +217 - Misses 7822 7934 +112 - Partials 946 948 +2I 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?
+ Hits 42870 43087 +217 - Misses 7822 7934 +112 - Partials 946 948 +2I 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.