Skip to content

Commit

Permalink
merge devel into master (deepmodeling#2917)
Browse files Browse the repository at this point in the history
Prepare v2.2.6.
  • Loading branch information
njzjz authored Oct 13, 2023
2 parents 477b785 + fc09e77 commit 2fe6927
Show file tree
Hide file tree
Showing 111 changed files with 5,285 additions and 18,135 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# do not show up detailed difference on GitHub
source/3rdparty/* linguist-generated=true
2 changes: 2 additions & 0 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/test_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ jobs:
test_cuda:
name: Test Python and C++ on CUDA
runs-on: nvidia
# https://github.com/deepmodeling/deepmd-kit/pull/2884#issuecomment-1744216845
container:
image: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
options: --gpus all
if: github.repository_owner == 'deepmodeling' && github.event.label.name == 'Test CUDA' || github.event_name == 'workflow_dispatch'
steps:
- name: Make sudo and git work
run: apt-get update && apt-get install -y sudo git
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
# cache: 'pip'
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
with:
Expand All @@ -26,14 +32,17 @@ jobs:
&& sudo dpkg -i cuda-keyring_1.0-1_all.deb \
&& sudo apt-get update \
&& sudo apt-get -y install cuda-11-8 libcudnn8=8.9.5.*-1+cuda11.8
if: false # skip as we use nvidia image
- name: Set PyPI mirror for Aliyun cloud machine
run: python -m pip config --user set global.index-url https://mirrors.aliyun.com/pypi/simple/
- run: python -m pip install -U "pip>=21.3.1,!=23.0.0"
- run: pip install -v -e .[gpu,test,lmp,cu11] "ase @ https://github.com/rosswhitfield/ase/archive/edd03571aff6944b77b4a4b055239f3c3e4eeb66.zip"
- run: python -m pip install -v -e .[gpu,test,lmp,cu11] "ase @ https://github.com/rosswhitfield/ase/archive/edd03571aff6944b77b4a4b055239f3c3e4eeb66.zip"
env:
DP_BUILD_TESTING: 1
DP_VARIANT: cuda
CUDA_PATH: /usr/local/cuda-11.8
- run: dp --version
- run: pytest -s --cov=deepmd --cov=deepmd_cli source/tests --durations=0
- run: python -m pytest -s --cov=deepmd --cov=deepmd_cli source/tests --durations=0
- run: source/install/test_cc_local.sh
env:
OMP_NUM_THREADS: 1
Expand All @@ -45,10 +54,10 @@ jobs:
DP_USE_MPICH2: 1
CUDA_PATH: /usr/local/cuda-11.8
- run: |
export LD_LIBRARY_PATH=${{ github.workspace }}/dp_test/lib:$CUDA_PATH/lib64:$LD_LIBRARY_PATH
export PATH=${{ github.workspace }}/dp_test/bin:$PATH
pytest -s --cov=deepmd source/lmp/tests
pytest -s --cov=deepmd source/ipi/tests
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/dp_test/lib:$CUDA_PATH/lib64:$LD_LIBRARY_PATH
export PATH=$GITHUB_WORKSPACE/dp_test/bin:$PATH
python -m pytest -s --cov=deepmd source/lmp/tests
python -m pytest -s --cov=deepmd source/ipi/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
Expand Down
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: "^.+\\.pbtxt$"
Expand All @@ -27,22 +27,26 @@ repos:
hooks:
- id: isort
files: \.py$
exclude: ^source/3rdparty
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.291
rev: v0.0.292
hooks:
- id: ruff
args: ["--fix"]
exclude: ^source/3rdparty
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black-jupyter
exclude: ^source/3rdparty
# numpydoc
- repo: https://github.com/Carreau/velin
rev: 0.0.12
hooks:
- id: velin
args: ["--write"]
exclude: ^source/3rdparty
# Python inside docs
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
Expand Down Expand Up @@ -102,6 +106,7 @@ repos:
- --comment-style
- "#"
- --no-extra-eol
exclude: ^source/3rdparty
# HTML
- id: insert-license
files: \.(html|vue|xml)$
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ A full [document](doc/train/train-input-auto.rst) on options in the training inp
- [Install GROMACS](doc/install/install-gromacs.md)
- [Building conda packages](doc/install/build-conda.md)
- [Install Node.js interface](doc/install/install-nodejs.md)
- [Easy install the latest development version](doc/install/easy-install-dev.md)
- [Data](doc/data/index.md)
- [System](doc/data/system.md)
- [Formats of a system](doc/data/data-conv.md)
Expand Down
4 changes: 4 additions & 0 deletions backend/dynamic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def dynamic_metadata(
"pytest",
"pytest-cov",
"pytest-sugar",
"dpgui",
],
"docs": [
"sphinx>=3.1.1",
Expand All @@ -62,6 +63,9 @@ def dynamic_metadata(
"i-PI",
*find_libpython_requires,
],
"gui": [
"dpgui",
],
**get_tf_requirement(tf_version),
"cu11": [
"nvidia-cuda-runtime-cu11",
Expand Down
4 changes: 4 additions & 0 deletions deepmd/descriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from .se_a_ebd import (
DescrptSeAEbd,
)
from .se_a_ebd_v2 import (
DescrptSeAEbdV2,
)
from .se_a_ef import (
DescrptSeAEf,
DescrptSeAEfLower,
Expand All @@ -39,6 +42,7 @@
"DescrptHybrid",
"DescrptLocFrame",
"DescrptSeA",
"DescrptSeAEbdV2",
"DescrptSeAEbd",
"DescrptSeAEf",
"DescrptSeAEfLower",
Expand Down
36 changes: 28 additions & 8 deletions deepmd/descriptor/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ class SomeDescript(Descriptor):
"""
return Descriptor.__plugins.register(key)

@classmethod
def get_class_by_input(cls, input: dict):
try:
descrpt_type = input["type"]
except KeyError:
raise KeyError("the type of descriptor should be set by `type`")
if descrpt_type in Descriptor.__plugins.plugins:
return Descriptor.__plugins.plugins[descrpt_type]
else:
raise RuntimeError("Unknown descriptor type: " + descrpt_type)

def __new__(cls, *args, **kwargs):
if cls is Descriptor:
try:
descrpt_type = kwargs["type"]
except KeyError:
raise KeyError("the type of descriptor should be set by `type`")
if descrpt_type in Descriptor.__plugins.plugins:
cls = Descriptor.__plugins.plugins[descrpt_type]
else:
raise RuntimeError("Unknown descriptor type: " + descrpt_type)
cls = cls.get_class_by_input(kwargs)
return super().__new__(cls)

@abstractmethod
Expand Down Expand Up @@ -489,3 +493,19 @@ def build_type_exclude_mask(
def explicit_ntypes(self) -> bool:
"""Explicit ntypes with type embedding."""
return False

@classmethod
@abstractmethod
def update_sel(cls, global_jdata: dict, local_jdata: dict):
"""Update the selection and perform neighbor statistics.
Parameters
----------
global_jdata : dict
The global data, containing the training section
local_jdata : dict
The local data refer to the current class
"""
# call subprocess
cls = cls.get_class_by_input(local_jdata)
return cls.update_sel(global_jdata, local_jdata)
18 changes: 18 additions & 0 deletions deepmd/descriptor/hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,21 @@ def pass_tensors_from_frz_model(
def explicit_ntypes(self) -> bool:
"""Explicit ntypes with type embedding."""
return any(ii.explicit_ntypes for ii in self.descrpt_list)

@classmethod
def update_sel(cls, global_jdata: dict, local_jdata: dict):
"""Update the selection and perform neighbor statistics.
Parameters
----------
global_jdata : dict
The global data, containing the training section
local_jdata : dict
The local data refer to the current class
"""
local_jdata_cpy = local_jdata.copy()
local_jdata_cpy["list"] = [
Descriptor.update_sel(global_jdata, sub_jdata)
for sub_jdata in local_jdata["list"]
]
return local_jdata_cpy
13 changes: 13 additions & 0 deletions deepmd/descriptor/loc_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,16 @@ def init_variables(
self.dstd = get_tensor_by_name_from_graph(
graph, "descrpt_attr%s/t_std" % suffix
)

@classmethod
def update_sel(cls, global_jdata: dict, local_jdata: dict):
"""Update the selection and perform neighbor statistics.
Parameters
----------
global_jdata : dict
The global data, containing the training section
local_jdata : dict
The local data refer to the current class
"""
return local_jdata
19 changes: 19 additions & 0 deletions deepmd/descriptor/se.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,22 @@ def init_variables(
def precision(self) -> tf.DType:
"""Precision of filter network."""
return self.filter_precision

@classmethod
def update_sel(cls, global_jdata: dict, local_jdata: dict):
"""Update the selection and perform neighbor statistics.
Parameters
----------
global_jdata : dict
The global data, containing the training section
local_jdata : dict
The local data refer to the current class
"""
from deepmd.entrypoints.train import (
update_one_sel,
)

# default behavior is to update sel which is a list
local_jdata_cpy = local_jdata.copy()
return update_one_sel(global_jdata, local_jdata_cpy, False)
Loading

0 comments on commit 2fe6927

Please sign in to comment.