Skip to content

Commit

Permalink
Merge branch 'devel' into rf_finetune
Browse files Browse the repository at this point in the history
Signed-off-by: Duo <[email protected]>
  • Loading branch information
iProzd authored Jun 3, 2024
2 parents a67ef2c + f23c77e commit 8270305
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 157 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ jobs:
CMAKE_GENERATOR: Ninja
CXXFLAGS: ${{ matrix.check_memleak && '-fsanitize=leak' || '' }}
# test lammps
# ASE issue: https://gitlab.com/ase/ase/-/merge_requests/2843
# TODO: remove ase version when ase has new release
- run: |
export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
python -m uv pip install --system -e .[cpu,test,lmp] mpi4py "ase @ https://gitlab.com/ase/ase/-/archive/8c5aa5fd6448c5cfb517a014dccf2b214a9dfa8f/ase-8c5aa5fd6448c5cfb517a014dccf2b214a9dfa8f.tar.gz"
python -m uv pip install --system -e .[cpu,test,lmp] mpi4py
env:
DP_BUILD_TESTING: 1
if: ${{ !matrix.check_memleak }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- run: python -m uv pip install --system "tensorflow>=2.15.0rc0" "torch>=2.2.0"
- run: |
export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
python -m uv pip install --system -v -e .[gpu,test,lmp,cu12,torch] mpi4py "ase @ https://gitlab.com/ase/ase/-/archive/8c5aa5fd6448c5cfb517a014dccf2b214a9dfa8f/ase-8c5aa5fd6448c5cfb517a014dccf2b214a9dfa8f.tar.gz"
python -m uv pip install --system -v -e .[gpu,test,lmp,cu12,torch] mpi4py
env:
DP_VARIANT: cuda
DP_ENABLE_NATIVE_OPTIMIZATION: 1
Expand Down
46 changes: 20 additions & 26 deletions deepmd/dpmodel/descriptor/dpa1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Union,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
Expand Down Expand Up @@ -28,32 +48,6 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Union,
)

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
34 changes: 14 additions & 20 deletions deepmd/dpmodel/descriptor/dpa2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from typing import (
List,
Optional,
Tuple,
Union,
)

import numpy as np

from deepmd.dpmodel import (
NativeOP,
)
from deepmd.dpmodel.utils import (
EnvMat,
NetworkCollection,
)
from deepmd.dpmodel.utils.network import (
Identity,
NativeLayer,
Expand All @@ -25,30 +39,10 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
List,
Optional,
Tuple,
Union,
)

from deepmd.dpmodel import (
NativeOP,
)
from deepmd.dpmodel.utils import (
EnvMat,
NetworkCollection,
)
from deepmd.utils.finetune import (
get_index_between_two_maps,
map_pair_exclude_types,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
28 changes: 10 additions & 18 deletions deepmd/dpmodel/descriptor/repformers.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import numpy as np

from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
Callable,
List,
Expand All @@ -25,6 +7,8 @@
Union,
)

import numpy as np

from deepmd.dpmodel import (
PRECISION_DICT,
NativeOP,
Expand All @@ -34,8 +18,16 @@
PairExcludeMask,
)
from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
get_activation_fn,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .descriptor import (
DescriptorBlock,
Expand Down
43 changes: 18 additions & 25 deletions deepmd/dpmodel/descriptor/se_e2_a.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import itertools

import numpy as np

from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
import itertools
from typing import (
Any,
List,
Optional,
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
Expand All @@ -43,6 +21,21 @@
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .base_descriptor import (
BaseDescriptor,
Expand Down
34 changes: 14 additions & 20 deletions deepmd/dpmodel/descriptor/se_r.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import numpy as np

from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
from typing import (
Any,
Expand All @@ -27,6 +7,8 @@
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
Expand All @@ -38,9 +20,21 @@
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .base_descriptor import (
BaseDescriptor,
Expand Down
41 changes: 17 additions & 24 deletions deepmd/dpmodel/descriptor/se_t.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import copy
import itertools
from typing import (
List,
Optional,
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
Expand All @@ -19,30 +36,6 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
from typing import (
List,
Optional,
Tuple,
)

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
12 changes: 3 additions & 9 deletions deepmd/dpmodel/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@

import numpy as np

from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.utils.version import (
check_version_compatibility,
)


class Identity(NativeOP):
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/entrypoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def train(FLAGS):

def freeze(FLAGS):
model = torch.jit.script(inference.Tester(FLAGS.model, head=FLAGS.head).model)
if '"type": "dpa2"' in model.model_def_script:
if '"type": "dpa2"' in model.get_model_def_script():
extra_files = {"type": "dpa2"}
else:
extra_files = {"type": "else"}
Expand Down
Loading

0 comments on commit 8270305

Please sign in to comment.