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

add BaseModel; store type in serialization #3335

Merged
merged 17 commits into from
Feb 27, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Feb 25, 2024

No description provided.

Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Comment on lines +26 to +28
from deepmd.pt.model.model.dipole_model import (
DipoleModel,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
deepmd.pt.model.model.dipole_model
begins an import cycle.
Comment on lines +29 to +31
from deepmd.pt.model.model.ener_model import (
EnergyModel,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
deepmd.pt.model.model.ener_model
begins an import cycle.
Comment on lines +32 to +34
from deepmd.pt.model.model.polar_model import (
PolarModel,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
deepmd.pt.model.model.polar_model
begins an import cycle.
deepmd/pt/model/model/dp_model.py Fixed Show fixed Hide fixed
deepmd/dpmodel/model/dp_model.py Fixed Show fixed Hide fixed
@@ -17,7 +20,8 @@
DPZBLModel_ = make_model(DPZBLLinearAtomicModel)


class DPZBLModel(DPZBLModel_):
@BaseModel.register("zbl")
class DPZBLModel(DPZBLModel_, BaseModel):

Check warning

Code scanning / CodeQL

Conflicting attributes in base classes Warning

Base classes have conflicting values for attribute 'compute_or_load_stat':
Function compute_or_load_stat
and
Function compute_or_load_stat
.
Base classes have conflicting values for attribute 'compute_or_load_stat': Function compute_or_load_stat and
Function compute_or_load_stat
.
Copy link

codecov bot commented Feb 25, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 75.57%. Comparing base (261c802) to head (d3ef0a4).
Report is 2 commits behind head on devel.

Files Patch % Lines
deepmd/dpmodel/model/base_model.py 85.10% 7 Missing ⚠️
deepmd/utils/plugin.py 76.47% 4 Missing ⚠️
deepmd/pt/model/model/dp_model.py 88.88% 2 Missing ⚠️
...pmd/dpmodel/atomic_model/make_base_atomic_model.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3335      +/-   ##
==========================================
+ Coverage   75.52%   75.57%   +0.05%     
==========================================
  Files         408      409       +1     
  Lines       34277    34377     +100     
  Branches     1604     1600       -4     
==========================================
+ Hits        25888    25982      +94     
- Misses       7528     7534       +6     
  Partials      861      861              

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

Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
DPModel = make_model(DPAtomicModel)

@BaseModel.register("standard")
class DPModel(make_model(DPAtomicModel), BaseModel):

Check warning

Code scanning / CodeQL

Conflicting attributes in base classes Warning

Base classes have conflicting values for attribute 'compute_or_load_stat':
Function compute_or_load_stat
and
Function compute_or_load_stat
.
Base classes have conflicting values for attribute 'compute_or_load_stat': Function compute_or_load_stat and
Function compute_or_load_stat
.
Copy link
Collaborator

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

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

  • I do not understand why the serialization and deserialization cannot be put int BaseBaseModel.
  • would the following inheritance work?
#       torch.nn.Module        BaseAtomicModel        BaseBaseModel
#             |                       |                    |
#             -------------------------                    |
#                         |                                |
#                    DPAtomicModel                         |
#                         |                                |
#                make_model(DPAtomicModel)                 |
#                         |                                |
#                         ----------------------------------
#                                           |
#                                         DPModel
  • in our concept a model is an atomic model, therefore, the base model seems to be a facilitate that provides the plugin, other methods like the get_rcut, get_dim_fparam... seems to be inherited from atomic model rather than model .

deepmd/dpmodel/model/base_model.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/model.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/model.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/model.py Outdated Show resolved Hide resolved
njzjz and others added 2 commits February 25, 2024 16:58
Co-authored-by: Han Wang <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: Han Wang <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
@njzjz njzjz marked this pull request as draft February 25, 2024 22:00
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
@njzjz
Copy link
Member Author

njzjz commented Feb 25, 2024

  • I do not understand why the serialization and deserialization cannot be put int BaseBaseModel.

Done.

  • would the following inheritance work?
#       torch.nn.Module        BaseAtomicModel        BaseBaseModel
#             |                       |                    |
#             -------------------------                    |
#                         |                                |
#                    DPAtomicModel                         |
#                         |                                |
#                make_model(DPAtomicModel)                 |
#                         |                                |
#                         ----------------------------------
#                                           |
#                                         DPModel

We cannot store the plugins of dpmodel and pt in the same class. There must be seperately classes to initialize the plugin separately.

  • in our concept a model is an atomic model, therefore, the base model seems to be a facilitate that provides the plugin, other methods like the get_rcut, get_dim_fparam... seems to be inherited from atomic model rather than model .

It looks to me SpinModel in #3301 is not inherited from an atomic model.

@njzjz njzjz marked this pull request as ready for review February 25, 2024 22:48
@njzjz njzjz mentioned this pull request Feb 25, 2024
11 tasks
deepmd/pt/model/model/model.py Outdated Show resolved Hide resolved
deepmd/pt/model/model/model.py Outdated Show resolved Hide resolved
@wanghan-iapcm
Copy link
Collaborator

We cannot store the plugins of dpmodel and pt in the same class. There must be seperately classes to initialize the plugin separately.

it should be possible to make_base_model for different backends, see #3340

Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
deepmd/dpmodel/model/base_model.py Show resolved Hide resolved
deepmd/utils/plugin.py Show resolved Hide resolved
@njzjz njzjz requested a review from iProzd February 26, 2024 22:43
@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue Feb 27, 2024
Merged via the queue into deepmodeling:devel with commit 854d998 Feb 27, 2024
48 checks passed
@njzjz njzjz linked an issue Mar 1, 2024 that may be closed by this pull request
3 tasks
@njzjz njzjz mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

serialize should contain type information
3 participants