-
Notifications
You must be signed in to change notification settings - Fork 617
refact(dpmodel,pt_expt): fitting net #5207
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
Merged
Merged
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
ec2e031
implement pytorch-exportable for se_e2_a descriptor
b8a48ff
better type for xp.zeros
1cc001f
implement env, base_descriptor and exclude_mask, remove the dependenc…
f2fbe88
mv to_torch_tensor to common
e2afbe9
simplify __init__ of the NaiveLayer
4ba511a
fix bug
fb9598a
fix bug
fa03351
simplify init method of se_e2_a descriptor. fig bug in consistent UT
09b33f1
restructure the test folders. add test_common.
67f2e54
add test_exclusion_mask.py
f7d83dd
fix poitential import issue in test.
0c96bb6
correct __call__(). fix bug
9dca912
fix registration issue
17f0a5d
fix pt-expt file extension
8ce93ba
fix(pt): expansion of get_default_nthreads()
3091988
fix bug of intra-inter
85f0583
fix bug of default dp inter value
d33324d
fix cicd
4de9a56
feat: add support for se_r
f4dc0af
fix device of xp array
2384835
fix device of xp array
9646d71
revert extend_coord_with_ghosts
f270069
raise error for non-implemented methods
57433d3
restore import torch
eedcbaf
fix(pt,pt-expt): guard thread setters
d8b2cf4
make exclusion mask modules
aeef15a
fix(pt-expt): clear params on None
8bdb1f8
fix bug
d3b01da
utility to handel dpmodel -> pt_expt conversion
3452a2a
fix to_numpy_array device
ba8e7ab
chore(dpmodel,pt_expt): refactorize the implementation of embedding net
621c7cc
feat: se_t and se_t_tebd descriptors for the pytroch exportable backend.
faa4026
fix bug
e263270
refact: fitting net
ea61141
fix bug
de8f156
merge master
ad83d98
Merge branch 'refact-auto-setattr' into refact-fitting-net
7cf88d2
Merge branch 'master' into refact-fitting-net
njzjz d02aa6a
Merge branch 'master' into refact-fitting-net
njzjz 271dc3b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 356214c
Revert "feat: se_t and se_t_tebd descriptors for the pytroch exportab…
53d2768
Merge remote-tracking branch 'origin/refact-fitting-net' into refact-…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from collections.abc import ( | ||
| Callable, | ||
| ) | ||
| from importlib.util import ( | ||
| find_spec, | ||
| ) | ||
| from typing import ( | ||
| TYPE_CHECKING, | ||
| ClassVar, | ||
| ) | ||
|
|
||
| from deepmd.backend.backend import ( | ||
| Backend, | ||
| ) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from argparse import ( | ||
| Namespace, | ||
| ) | ||
|
|
||
| from deepmd.infer.deep_eval import ( | ||
| DeepEvalBackend, | ||
| ) | ||
| from deepmd.utils.neighbor_stat import ( | ||
| NeighborStat, | ||
| ) | ||
|
|
||
|
|
||
| @Backend.register("pt-expt") | ||
| @Backend.register("pytorch-exportable") | ||
| class PyTorchExportableBackend(Backend): | ||
| """PyTorch exportable backend.""" | ||
|
|
||
| name = "PyTorch Exportable" | ||
| """The formal name of the backend.""" | ||
| features: ClassVar[Backend.Feature] = ( | ||
| Backend.Feature.ENTRY_POINT | ||
| | Backend.Feature.DEEP_EVAL | ||
| | Backend.Feature.NEIGHBOR_STAT | ||
| | Backend.Feature.IO | ||
| ) | ||
|
wanghan-iapcm marked this conversation as resolved.
|
||
| """The features of the backend.""" | ||
| suffixes: ClassVar[list[str]] = [".pte"] | ||
| """The suffixes of the backend.""" | ||
|
|
||
| def is_available(self) -> bool: | ||
| """Check if the backend is available. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| Whether the backend is available. | ||
| """ | ||
| return find_spec("torch") is not None | ||
|
|
||
| @property | ||
| def entry_point_hook(self) -> Callable[["Namespace"], None]: | ||
| """The entry point hook of the backend. | ||
|
|
||
| Returns | ||
| ------- | ||
| Callable[[Namespace], None] | ||
| The entry point hook of the backend. | ||
| """ | ||
| from deepmd.pt.entrypoints.main import main as deepmd_main | ||
|
|
||
| return deepmd_main | ||
|
|
||
| @property | ||
| def deep_eval(self) -> type["DeepEvalBackend"]: | ||
| """The Deep Eval backend of the backend. | ||
|
|
||
| Returns | ||
| ------- | ||
| type[DeepEvalBackend] | ||
| The Deep Eval backend of the backend. | ||
| """ | ||
| raise NotImplementedError | ||
|
wanghan-iapcm marked this conversation as resolved.
|
||
|
|
||
| @property | ||
| def neighbor_stat(self) -> type["NeighborStat"]: | ||
| """The neighbor statistics of the backend. | ||
|
|
||
| Returns | ||
| ------- | ||
| type[NeighborStat] | ||
| The neighbor statistics of the backend. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @property | ||
| def serialize_hook(self) -> Callable[[str], dict]: | ||
| """The serialize hook to convert the model file to a dictionary. | ||
|
|
||
| Returns | ||
| ------- | ||
| Callable[[str], dict] | ||
| The serialize hook of the backend. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @property | ||
| def deserialize_hook(self) -> Callable[[str, dict], None]: | ||
| """The deserialize hook to convert the dictionary to a model file. | ||
|
|
||
| Returns | ||
| ------- | ||
| Callable[[str, dict], None] | ||
| The deserialize hook of the backend. | ||
| """ | ||
| raise NotImplementedError | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.