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

Merge recent updates on devel to master. #1217

Merged
merged 7 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
conda:
environment: doc/environment.yml
environment: doc/environment.yml
formats: all
6 changes: 4 additions & 2 deletions deepmd/descriptor/hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ class DescrptHybrid (Descriptor):

Parameters
----------
descrpt_list : list
list : list
Build a descriptor from the concatenation of the list of descriptors.
"""
def __init__ (self,
descrpt_list : list
list : list
) -> None :
"""
Constructor
"""
# warning: list is conflict with built-in list
descrpt_list = list
if descrpt_list == [] or descrpt_list is None:
raise RuntimeError('cannot build descriptor from an empty list of descriptors.')
formatted_descript_list = []
Expand Down
7 changes: 3 additions & 4 deletions deepmd/descriptor/se_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, List, Dict, Any

from deepmd.env import tf
from deepmd.common import get_activation_func, get_precision, ACTIVATION_FN_DICT, PRECISION_DICT, docstring_parameter, get_np_precision
from deepmd.common import get_activation_func, get_precision, ACTIVATION_FN_DICT, PRECISION_DICT, docstring_parameter
from deepmd.utils.argcheck import list_to_doc
from deepmd.env import GLOBAL_TF_FLOAT_PRECISION
from deepmd.env import GLOBAL_NP_FLOAT_PRECISION
Expand All @@ -13,7 +13,7 @@
from deepmd.utils.tabulate import DPTabulate
from deepmd.utils.type_embed import embed_atom_type
from deepmd.utils.sess import run_sess
from deepmd.utils.graph import load_graph_def, get_tensor_by_name_from_graph, get_embedding_net_variables
from deepmd.utils.graph import load_graph_def, get_tensor_by_name_from_graph
from .descriptor import Descriptor
from .se import DescrptSe

Expand Down Expand Up @@ -133,7 +133,6 @@ def __init__ (self,
self.compress_activation_fn = get_activation_func(activation_function)
self.filter_activation_fn = get_activation_func(activation_function)
self.filter_precision = get_precision(precision)
self.filter_np_precision = get_np_precision(precision)
self.exclude_types = set()
for tt in exclude_types:
assert(len(tt) == 2)
Expand Down Expand Up @@ -687,7 +686,7 @@ def _filter_lower(
net = 'filter_-1_net_' + str(type_i)
else:
net = 'filter_' + str(type_input) + '_net_' + str(type_i)
return op_module.tabulate_fusion(self.table.data[net].astype(self.filter_np_precision), info, xyz_scatter, tf.reshape(inputs_i, [natom, shape_i[1]//4, 4]), last_layer_size = outputs_size[-1])
return op_module.tabulate_fusion(tf.cast(self.table.data[net], self.filter_precision), info, xyz_scatter, tf.reshape(inputs_i, [natom, shape_i[1]//4, 4]), last_layer_size = outputs_size[-1])
else:
if (not is_exclude):
xyz_scatter = embedding_net(
Expand Down
4 changes: 4 additions & 0 deletions deepmd/utils/argcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ def loss_ener():
doc_limit_pref_v = limit_pref('virial')
doc_start_pref_ae = start_pref('atom_ener')
doc_limit_pref_ae = limit_pref('atom_ener')
doc_start_pref_pf = start_pref('atom_pref')
doc_limit_pref_pf = limit_pref('atom_pref')
doc_relative_f = 'If provided, relative force error will be used in the loss. The difference of force will be normalized by the magnitude of the force in the label with a shift given by `relative_f`, i.e. DF_i / ( || F || + relative_f ) with DF denoting the difference between prediction and label and || F || denoting the L2 norm of the label.'
return [
Argument("start_pref_e", [float,int], optional = True, default = 0.02, doc = doc_start_pref_e),
Expand All @@ -488,6 +490,8 @@ def loss_ener():
Argument("limit_pref_v", [float,int], optional = True, default = 0.00, doc = doc_limit_pref_v),
Argument("start_pref_ae", [float,int], optional = True, default = 0.00, doc = doc_start_pref_ae),
Argument("limit_pref_ae", [float,int], optional = True, default = 0.00, doc = doc_limit_pref_ae),
Argument("start_pref_pf", [float,int], optional = True, default = 0.00, doc = doc_start_pref_pf),
Argument("limit_pref_pf", [float,int], optional = True, default = 0.00, doc = doc_limit_pref_pf),
Argument("relative_f", [float,None], optional = True, doc = doc_relative_f)
]

Expand Down
2 changes: 1 addition & 1 deletion doc/install/install-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ One may add the following arguments to `cmake`:
| -DCUDA_TOOLKIT_ROOT_DIR=<value> | Path | Detected automatically | The path to the CUDA toolkit directory. |
| -DUSE_ROCM_TOOLKIT=<value> | `TRUE` or `FALSE` | `FALSE` | If `TRUE`, Build GPU support with ROCM toolkit. |
| -DROCM_ROOT=<value> | Path | Detected automatically | The path to the ROCM toolkit directory. |
| -DLAMMPS_VERSION_NUMBER=<value> | Number | `20201029` | Only neccessary for LAMMPS built-in mode. The version number of LAMMPS (yyyymmdd). |
| -DLAMMPS_VERSION_NUMBER=<value> | Number | `20210929` | Only neccessary for LAMMPS built-in mode. The version number of LAMMPS (yyyymmdd). |
| -DLAMMPS_SOURCE_ROOT=<value> | Path | - | Only neccessary for LAMMPS plugin mode. The path to the LAMMPS source code (later than 8Apr2021). If not assigned, the plugin mode will not be enabled. |

If the cmake has executed successfully, then
Expand Down
22 changes: 11 additions & 11 deletions doc/install/install-lammps.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ make lammps
DeePMD-kit will generate a module called `USER-DEEPMD` in the `build` directory. If you need low precision version, move `env_low.sh` to `env.sh` in the directory. Now download the LAMMPS code (`29Oct2020` or later), and uncompress it:
```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/stable_29Oct2020.tar.gz
tar xf stable_29Oct2020.tar.gz
wget https://github.com/lammps/lammps/archive/stable_29Sep2021.tar.gz
tar xf stable_29Sep2021.tar.gz
```
The source code of LAMMPS is stored in directory `lammps-stable_29Oct2020`. Now go into the LAMMPS code and copy the DeePMD-kit module like this
The source code of LAMMPS is stored in directory `lammps-stable_29Sep2021`. Now go into the LAMMPS code and copy the DeePMD-kit module like this
```bash
cd lammps-stable_29Oct2020/src/
cd lammps-stable_29Sep2021/src/
cp -r $deepmd_source_dir/source/build/USER-DEEPMD .
```
Now build LAMMPS
Expand All @@ -43,22 +43,22 @@ Starting from `8Apr2021`, LAMMPS also provides a plugin mode, allowing one build
Now download the LAMMPS code (`8Apr2021` or later), and uncompress it:
```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/patch_30Jul2021.tar.gz
tar xf patch_30Jul2021.tar.gz
wget https://github.com/lammps/lammps/archive/stable_29Sep2021.tar.gz
tar xf stable_29Sep2021.tar.gz
```
The source code of LAMMPS is stored in directory `lammps-patch_30Jul2021`. Now go into the LAMMPS code and create a directory called `build`
The source code of LAMMPS is stored in directory `lammps-stable_29Sep2021`. Now go into the LAMMPS code and create a directory called `build`
```bash
mkdir -p lammps-patch_30Jul2021/build/
cd lammps-patch_30Jul2021/build/
mkdir -p lammps-stable_29Sep2021/build/
cd lammps-stable_29Sep2021/build/
```
Now build LAMMPS. Note that `PLUGIN` and `KSPACE` package must be enabled, and `BUILD_SHARED_LIBS` must be set to `yes`. You can install any other package you want.
```bash
cmake -D PKG_PLUGIN=ON -D PKG_KSPACE=ON -D LAMMPS_INSTALL_RPATH=ON -D BUILD_SHARED_LIBS=yes -D CMAKE_INSTALL_PREFIX=${deepmd_root} ../cmake
cmake -D PKG_PLUGIN=ON -D PKG_KSPACE=ON -D LAMMPS_INSTALL_RPATH=ON -D BUILD_SHARED_LIBS=yes -D CMAKE_INSTALL_PREFIX=${deepmd_root} -D CMAKE_INSTALL_LIBDIR=lib -D CMAKE_INSTALL_FULL_LIBDIR=${deepmd_root}/lib ../cmake
make -j4
make install
```

If everything works fine, you will end up with an executable `${deepmd_root}/lmp`.
```bash
${deepmd_root}/lmp -h
```
```
2 changes: 1 addition & 1 deletion doc/third-party/lammps-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
If you are using the plugin mode, enable DeePMD-kit package in LAMMPS with `plugin` command:

```
plugin load path/to/deepmd/lib/libdeepmd_lmp.so
plugin load libdeepmd_lmp.so
```

The built-in mode doesn't need this step.
Expand Down
4 changes: 2 additions & 2 deletions examples/water/lmp/in.plugin.lammps
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ read_data water.lmp
mass 1 16
mass 2 2

# load the plugin at <install_prefix>/lib/libdeepmd_lmp.so
plugin load ../../../dp/lib/libdeepmd_lmp.so
# load the deepmd plugin
plugin load libdeepmd_lmp.so

pair_style deepmd frozen_model.pb
pair_coeff * *
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NPROC=$(nproc --all)
BUILD_TMP_DIR=${SCRIPT_PATH}/../build
mkdir -p ${BUILD_TMP_DIR}
cd ${BUILD_TMP_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DINSTALL_TENSORFLOW=TRUE ${CUDA_ARGS} -DLAMMPS_VERSION=patch_30Jul2021 -DUSE_TTM=TRUE ..
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DINSTALL_TENSORFLOW=TRUE ${CUDA_ARGS} -DLAMMPS_VERSION=stable_29Sep2021 -DUSE_TTM=TRUE ..
make -j${NPROC}
make install

Expand Down
4 changes: 2 additions & 2 deletions source/install/build_lammps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BUILD_TMP_DIR=${SCRIPT_PATH}/../build_lammps
mkdir -p ${BUILD_TMP_DIR}
cd ${BUILD_TMP_DIR}
# download LAMMMPS
LAMMPS_VERSION=patch_30Jul2021
LAMMPS_VERSION=stable_29Sep2021
if [ ! -d "lammps-${LAMMPS_VERSION}" ]
then
curl -L -o lammps.tar.gz https://github.com/lammps/lammps/archive/refs/tags/${LAMMPS_VERSION}.tar.gz
Expand All @@ -25,7 +25,7 @@ fi
cd ${BUILD_TMP_DIR}/lammps-${LAMMPS_VERSION}
mkdir -p ${BUILD_TMP_DIR}/lammps-${LAMMPS_VERSION}/build
cd ${BUILD_TMP_DIR}/lammps-${LAMMPS_VERSION}/build
cmake -C ../cmake/presets/all_off.cmake -D PKG_PLUGIN=ON -D PKG_KSPACE=ON -D BUILD_SHARED_LIBS=yes -D LAMMPS_INSTALL_RPATH=ON -D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} ../cmake
cmake -C ../cmake/presets/all_off.cmake -D PKG_PLUGIN=ON -D PKG_KSPACE=ON -D BUILD_SHARED_LIBS=yes -D LAMMPS_INSTALL_RPATH=ON -D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -D CMAKE_INSTALL_LIBDIR=lib -D CMAKE_INSTALL_FULL_LIBDIR=${INSTALL_PREFIX}/lib ../cmake

make -j${NPROC}
make install
Expand Down
4 changes: 2 additions & 2 deletions source/lmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_subdirectory(plugin)
if (NOT DEFINED LAMMPS_VERSION_NUMBER)
# set the default to 29 Oct 2020
set(LAMMPS_VERSION_NUMBER 20201029)
# set the default to stable_29Sep2021
set(LAMMPS_VERSION_NUMBER 20210929)
endif()
message(STATUS "LAMMPS version is ${LAMMPS_VERSION_NUMBER}")

Expand Down