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

feat pt : Support property fitting #3867

Merged
merged 86 commits into from
Sep 5, 2024
Merged

Conversation

Chengqian-Zhang
Copy link
Collaborator

@Chengqian-Zhang Chengqian-Zhang commented Jun 12, 2024

Solve issue #3866

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.
    • Implemented the PropertyModel class to integrate properties specific to atomic models.
  • Enhancements

    • Added an 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 improved property evaluation.
    • Expanded loss function capabilities to handle the "property" loss type.
    • Improved argument definitions for fitting and loss functionalities, enhancing configurability.
    • Updated the model selection logic to include the new PropertyModel.
    • Enhanced the DeepEvalWrapper class to support additional model evaluation features, including new methods for retrieving model characteristics.
  • Documentation

    • Updated class docstrings to reflect new attributes and parameters, improving clarity and usability.
  • Tests

    • Expanded the set of test examples related to the "property" category to improve test coverage.
    • Introduced new test classes and parameterized tests for improved validation of property-related functionalities.

@Chengqian-Zhang Chengqian-Zhang marked this pull request as draft June 12, 2024 10:00
Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

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 dde48fd and 4d8934f.

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.

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

Outside diff range and nitpick comments (8)
deepmd/pt/train/training.py (6)

Line range hint 366-366: Use the simplified method to access dictionary values.

- config.get("learning_rate_dict", None)
+ config.get("learning_rate_dict")

Also applies to: 452-452


Line range hint 470-470: Remove assignments to unused variables to clean up the code.

- ntest = model_params.get("data_bias_nsample", 1)
- old_type_map, new_type_map = (
-     _model_params["type_map"],
-     _model_params["new_type_map"],
- )

Also applies to: 586-586


Line range hint 688-688: Use context managers for file operations to ensure proper resource management.

- fout = open(self.disp_file, mode="w", buffering=1)
+ with open(self.disp_file, mode="w", buffering=1) as fout:
- fout1 = open(record_file, mode="w", buffering=1)
+ with open(record_file, mode="w", buffering=1) as fout1:

Also applies to: 692-692


Line range hint 734-737: Simplify the conditional assignment using a ternary operator.

- if _step_id < self.warmup_steps:
-     pref_lr = _lr.start_lr
- else:
-     pref_lr = cur_lr
+ pref_lr = _lr.start_lr if _step_id < self.warmup_steps else cur_lr

Line range hint 844-844: Rename the unused loop control variable to _ to indicate it is intentionally unused.

- for ii in range(valid_numb_batch):
+ for _ in range(valid_numb_batch):

Line range hint 1115-1115: Use direct key checks in dictionaries instead of checking against the keys list.

- if key in dict.keys():
+ if key in dict:
deepmd/utils/argcheck.py (2)

Line range hint 75-75: Specify stacklevel in warnings.warn to improve the clarity of the warning's origin.

-            warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning)
+            warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning, stacklevel=2)
Tools
Ruff

2536-2536: Local variable base is assigned to but never used (F841)

Remove assignment to unused variable base


Line range hint 1171-1171: Remove unused variable assignments to clean up the code.

-    link_lf = make_link("loc_frame", "model/descriptor[loc_frame]")
-    link_se_e2_a = make_link("se_e2_a", "model/descriptor[se_e2_a]")
-    link_se_e2_r = make_link("se_e2_r", "model/descriptor[se_e2_r]")
-    link_se_e3 = make_link("se_e3", "model/descriptor[se_e3]")
-    link_se_a_tpe = make_link("se_a_tpe", "model/descriptor[se_a_tpe]")
-    link_hybrid = make_link("hybrid", "model/descriptor[hybrid]")
-    link_se_atten = make_link("se_atten", "model/descriptor[se_atten]")
-    link_se_atten_v2 = make_link("se_atten_v2", "model/descriptor[se_atten_v2]")

Also applies to: 1172-1172, 1173-1173, 1174-1174, 1175-1175, 1176-1176, 1177-1177, 1178-1178

Tools
Ruff

2536-2536: Local variable base is assigned to but never used (F841)

Remove assignment to unused variable base

deepmd/utils/argcheck.py Outdated Show resolved Hide resolved
deepmd/pt/model/task/property.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 12, 2024

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 1 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/pt/loss/property.py 47.72% 23 Missing ⚠️
deepmd/entrypoints/test.py 86.56% 9 Missing ⚠️
...epmd/dpmodel/atomic_model/property_atomic_model.py 0.00% 6 Missing ⚠️
deepmd/dpmodel/model/property_model.py 80.00% 2 Missing ⚠️
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     

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

@Chengqian-Zhang Chengqian-Zhang marked this pull request as ready for review June 13, 2024 10:13
@Chengqian-Zhang Chengqian-Zhang marked this pull request as draft June 13, 2024 10:15
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: 3

Outside diff range and nitpick comments (10)
deepmd/pt/utils/stat.py (4)

Line range hint 88-88: Avoid using mutable data structures for default arguments.

- def compute_output_stats(merged, ntypes, keys=["energy"], stat_file_path=None, rcond=None, preset_bias=None, model_forward=None, intensive=False):
+ def compute_output_stats(merged, ntypes, keys=None, stat_file_path=None, rcond=None, preset_bias=None, model_forward=None, intensive=False):
+     if keys is None:
+         keys = ["energy"]

Line range hint 154-154: Remove the unused variable natoms to clean up the code.

- natoms = system["natoms"],

Line range hint 238-238: Avoid using mutable data structures for default arguments.

- def compute_output_stats_global(sampled, ntypes, keys=["energy"], rcond=None, preset_bias=None, model_pred=None, intensive=False):
+ def compute_output_stats_global(sampled, ntypes, keys=None, rcond=None, preset_bias=None, model_pred=None, intensive=False):
+     if keys is None:
+         keys = ["energy"]

Line range hint 292-292: Use key in dict instead of key in dict.keys() for a more Pythonic and efficient approach.

- if kk in preset_bias.keys()
+ if kk in preset_bias

- for kk in keys.keys()
+ for kk in keys

- for kk in bias_atom_e.keys()
+ for kk in bias_atom_e

- for kk in merged_natoms.keys()
+ for kk in merged_natoms

- for kk in model_pred.keys()
+ for kk in model_pred

Also applies to: 335-335, 344-344, 449-449, 491-491, 497-497, 499-499, 504-504

deepmd/pt/train/training.py (6)

Line range hint 367-367: Use config.get("learning_rate_dict") instead of config.get("learning_rate_dict", None) as it is cleaner and the default return of get is None.

- config.get("learning_rate_dict", None)
+ config.get("learning_rate_dict")

Also applies to: 453-453


Line range hint 471-471: Remove assignment to unused variables ntest and old_type_map, which are declared but never used.

- ntest = model_params.get("data_bias_nsample", 1)
- old_type_map, new_type_map = (
-     _model_params["type_map"],
-     _model_params["new_type_map"],
- )

Also applies to: 587-587


Line range hint 526-526: Use key in dict instead of key in dict.keys() for checking key existence in a dictionary, which is more Pythonic and efficient.

- key in dict.keys()
+ key in dict

Also applies to: 1116-1116


Line range hint 689-689: Use context handlers for file operations to ensure that files are properly closed after their scope ends, which improves code safety and readability.

- fout = open(self.disp_file, mode="w", buffering=1)
+ with open(self.disp_file, mode="w", buffering=1) as fout:

- fout1 = open(record_file, mode="w", buffering=1)
+ with open(record_file, mode="w", buffering=1) as fout1:

Also applies to: 693-693


Line range hint 735-738: Simplify the conditional assignment for pref_lr using a ternary operator, which makes the code more concise.

- if _step_id < self.warmup_steps:
-     pref_lr = _lr.start_lr
- else:
-     pref_lr = cur_lr
+ pref_lr = _lr.start_lr if _step_id < self.warmup_steps else cur_lr

Line range hint 845-845: Rename the unused loop control variable ii to _ to indicate that it is intentionally unused.

- for ii in range(valid_numb_batch):
+ for _ in range(valid_numb_batch):

deepmd/pt/model/model/property_model.py Outdated Show resolved Hide resolved
deepmd/pt/model/task/property.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: 6

Outside diff range and nitpick comments (16)
deepmd/pt/utils/stat.py (4)

Line range hint 88-88: Avoid using mutable default structures for argument defaults. Replace with None and initialize within the function.

- preset_bias: Optional[Dict[str, List[Optional[torch.Tensor]]]] = {},
+ preset_bias: Optional[Dict[str, List[Optional[torch.Tensor]]]] = None,
+ if preset_bias is None:
+     preset_bias = {},

Also applies to: 238-238


Line range hint 154-154: Remove the unused variable natoms.

- natoms = {kk: merged_natoms[kk].sum(-1) for kk in bias_atom_e.keys()}

Line range hint 166-166: Ensure loop variables nframes and system are bound in the function definition.

- for kk in keys:
+ for kk, nframes, system in zip(keys, nf, sampled):

Also applies to: 167-167


Line range hint 292-292: Replace key in dict.keys() with key in dict to simplify the code.

- if kk in preset_bias.keys()
+ if kk in preset_bias

Also applies to: 335-335, 344-344, 449-449, 493-493, 499-499, 501-501, 506-506

deepmd/pt/model/atomic_model/base_atomic_model.py (3)

Line range hint 80-80: Avoid using mutable default arguments.

- def __init__(self, type_map: List[str], atom_exclude_types: List[int] = [], pair_exclude_types: List[Tuple[int, int]] = [], rcond: Optional[float] = None, preset_out_bias: Optional[Dict[str, torch.Tensor]] = None):
+ def __init__(self, type_map: List[str], atom_exclude_types: List[int] = None, pair_exclude_types: List[Tuple[int, int]] = None, rcond: Optional[float] = None, preset_out_bias: Optional[Dict[str, torch.Tensor]] = None):
+     atom_exclude_types = atom_exclude_types if atom_exclude_types is not None else []
+     pair_exclude_types = pair_exclude_types if pair_exclude_types is not None else []

- def reinit_atom_exclude(self, exclude_types: List[int] = []):
+ def reinit_atom_exclude(self, exclude_types: List[int] = None):
+     exclude_types = exclude_types if exclude_types is not None else []

- def reinit_pair_exclude(self, exclude_types: List[Tuple[int, int]] = []):
+ def reinit_pair_exclude(self, exclude_types: List[Tuple[int, int]] = None):
+     exclude_types = exclude_types if exclude_types is not None else []

Also applies to: 81-81, 129-129, 139-139


Line range hint 95-95: Remove unused local variable.

- ntypes = self.get_ntypes()

Line range hint 254-254: Optimize dictionary key checks.

- for kk in ret_dict.keys():
+ for kk in ret_dict:

- if kk in out_std.keys()
+ if kk in out_std

- if kk in out_bias.keys()
+ if kk in out_bias

Also applies to: 543-543, 544-544

deepmd/pt/train/training.py (7)

Line range hint 375-375: Use config.get("learning_rate_dict") instead of config.get("learning_rate_dict", None) for simplicity.

- if self.multi_task and config.get("learning_rate_dict", None) is not None:
+ if self.multi_task and config.get("learning_rate_dict") is not None:

Line range hint 469-469: Simplify the check by using config.get("learning_rate_dict").

- if self.multi_task and config.get("learning_rate_dict", None) is not None:
+ if self.multi_task and config.get("learning_rate_dict") is not None:

Line range hint 567-567: Use key in dict instead of key in dict.keys() to check for key existence in a dictionary.

- missing_keys = [key for key in self.model_keys if key not in self.optim_dict.keys()]
+ missing_keys = [key for key in self.model_keys if key not in self.optim_dict]

Line range hint 714-714: Use a context manager when opening files to ensure that resources are properly managed and the file is closed after its contents are no longer needed.

- fout = open(self.disp_file, mode="w", buffering=1) if self.rank == 0 else None
+ fout = open(self.disp_file, mode="w", buffering=1) if self.rank == 0 else None  # Consider using `with open(...) as fout:` to ensure file closure
- fout1 = open(record_file, mode="w", buffering=1)
+ fout1 = open(record_file, mode="w", buffering=1)  # Consider using `with open(...) as fout1:` to ensure file closure

Also applies to: 718-718


Line range hint 760-763: Refactor the if-else block to a ternary operator for clarity and brevity.

- if _step_id < self.warmup_steps:
-     pref_lr = _lr.start_lr
- else:
-     pref_lr = cur_lr
+ pref_lr = _lr.start_lr if _step_id < self.warmup_steps else cur_lr

Line range hint 870-870: Rename the unused loop variable ii to _ii to indicate it's intentionally unused.

- for ii in range(valid_numb_batch):
+ for _ii in range(valid_numb_batch):

Line range hint 1141-1141: Use key in dict instead of key in dict.keys() for checking key existence.

- missing_keys = [item for item in target_keys if item not in input_keys.keys()]
+ missing_keys = [item for item in target_keys if item not in input_keys]
deepmd/utils/argcheck.py (2)

Line range hint 75-75: Specify a stacklevel for the warning to improve debugging.

- warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning)
+ warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning, stacklevel=2)

This change will help trace back the warning to the caller of the function, rather than the utility function itself, which can be very helpful in debugging.

Tools
Ruff

2536-2536: Local variable base is assigned to but never used (F841)

Remove assignment to unused variable base


Line range hint 1171-1178: Remove unused local variables that store link references.

- link_lf = make_link("loc_frame", "model/descriptor[loc_frame]")
- link_se_e2_a = make_link("se_e2_a", "model/descriptor[se_e2_a]")
- link_se_e2_r = make_link("se_e2_r", "model/descriptor[se_e2_r]")
- link_se_e3 = make_link("se_e3", "model/descriptor[se_e3]")
- link_se_a_tpe = make_link("se_a_tpe", "model/descriptor[se_a_tpe]")
- link_hybrid = make_link("hybrid", "model/descriptor[hybrid]")
- link_se_atten = make_link("se_atten", "model/descriptor[se_atten]")
- link_se_atten_v2 = make_link("se_atten_v2", "model/descriptor[se_atten_v2]")

These variables are assigned but never used, which can lead to unnecessary memory usage and potential confusion.

Tools
Ruff

2536-2536: Local variable base is assigned to but never used (F841)

Remove assignment to unused variable base

deepmd/pt/model/model/property_model.py Outdated Show resolved Hide resolved
deepmd/pt/loss/property.py Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/utils/argcheck.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: 0

Outside diff range and nitpick comments (4)
deepmd/pt/model/atomic_model/base_atomic_model.py (4)

Line range hint 80-80: Replace mutable default argument with None.

- def __init__(self, type_map: List[str], atom_exclude_types: List[int] = [], pair_exclude_types: List[Tuple[int, int]] = [], rcond: Optional[float] = None, preset_out_bias: Optional[Dict[str, torch.Tensor]] = None):
+ def __init__(self, type_map: List[str], atom_exclude_types: List[int] = None, pair_exclude_types: List[Tuple[int, int]] = None, rcond: Optional[float] = None, preset_out_bias: Optional[Dict[str, torch.Tensor]] = None):
+     atom_exclude_types = atom_exclude_types if atom_exclude_types is not None else []
+     pair_exclude_types = pair_exclude_types if pair_exclude_types is not None else []

Line range hint 129-129: Replace mutable default arguments with None.

- def reinit_atom_exclude(self, exclude_types: List[int] = []):
- def reinit_pair_exclude(self, exclude_types: List[Tuple[int, int]] = []):
+ def reinit_atom_exclude(self, exclude_types: List[int] = None):
+     exclude_types = exclude_types if exclude_types is not None else []
+ def reinit_pair_exclude(self, exclude_types: List[Tuple[int, int]] = None):
+     exclude_types = exclude_types if exclude_types is not None else []

Also applies to: 139-139


Line range hint 254-254: Optimize dictionary key checks.

- if key in self.bias_keys.keys():
+ if key in self.bias_keys:

Also applies to: 548-548, 549-549


Line range hint 95-95: Remove unused local variable ntypes.

- ntypes = self.get_ntypes()

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

Outside diff range and nitpick comments (2)
deepmd/utils/argcheck.py (2)

Line range hint 75-75: Please specify a stacklevel for the warnings.warn call to improve debugging.

-            warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning)
+            warnings.warn(f"{key} has been removed and takes no effect.", FutureWarning, stacklevel=2)

Line range hint 1171-1178: Remove unused variable assignments.

-    link_lf = make_link("loc_frame", "model/descriptor[loc_frame]")
-    link_se_e2_a = make_link("se_e2_a", "model/descriptor[se_e2_a]")
-    link_se_e2_r = make_link("se_e2_r", "model/descriptor[se_e2_r]")
-    link_se_e3 = make_link("se_e3", "model/descriptor[se_e3]")
-    link_se_a_tpe = make_link("se_a_tpe", "model/descriptor[se_a_tpe]")
-    link_hybrid = make_link("hybrid", "model/descriptor[hybrid]")
-    link_se_atten = make_link("se_atten", "model/descriptor[se_atten]")
-    link_se_atten_v2 = make_link("se_atten_v2", "model/descriptor[se_atten_v2]")

deepmd/utils/argcheck.py Show resolved Hide resolved
deepmd/utils/argcheck.py Show resolved Hide resolved
@iProzd
Copy link
Collaborator

iProzd commented Sep 5, 2024

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

Copy link
Member

@njzjz njzjz left a comment

Choose a reason for hiding this comment

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

I create #4105. We may resolve the issue later instead of doing in this issue.

@njzjz njzjz added this pull request to the merge queue Sep 5, 2024
Merged via the queue into deepmodeling:devel with commit f4139fa Sep 5, 2024
60 checks passed
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
Fix the spelling as suggested by
deepmodeling#3867 (comment).

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

## Summary by CodeRabbit

- **Bug Fixes**
- Corrected typos in attribute names from `reduciable` to `reducible`
across multiple files, enhancing the accuracy of parameter definitions
and improving code consistency.

- **Tests**
- Updated test cases to reflect the corrected attribute names, ensuring
that tests accurately validate the new `reducible` parameter.

These changes improve the clarity and correctness of the codebase,
ensuring that attribute names are consistent and accurately reflect
their intended functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <[email protected]>
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
Solve issue deepmodeling#3866

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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.
- Implemented the `PropertyModel` class to integrate properties specific
to atomic models.

- **Enhancements**
- Added an `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 improved property evaluation.
- Expanded loss function capabilities to handle the "property" loss
type.
- Improved argument definitions for fitting and loss functionalities,
enhancing configurability.
- Updated the model selection logic to include the new `PropertyModel`.
- Enhanced the `DeepEvalWrapper` class to support additional model
evaluation features, including new methods for retrieving model
characteristics.

- **Documentation**
- Updated class docstrings to reflect new attributes and parameters,
improving clarity and usability.

- **Tests**
- Expanded the set of test examples related to the "property" category
to improve test coverage.
- Introduced new test classes and parameterized tests for improved
validation of property-related functionalities.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Chenqqian Zhang <[email protected]>
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] Support property fitting in devel branch
4 participants