Skip to content

Commit e695a91

Browse files
authored
merge devel to master (v3.0.0) (deepmodeling#4407)
2 parents b875ea8 + 2303ff0 commit e695a91

File tree

1,566 files changed

+217864
-33846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,566 files changed

+217864
-33846
lines changed

.devcontainer/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2+
3+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

.devcontainer/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# DeePMD-kit devcontainer environment
2+
3+
This [devcontainer](https://vscode.js.cn/docs/devcontainers/devcontainer-cli) environment setups Python and C++ environment to develop DeePMD-kit.
4+
One can setup locally or use [GitHub Codespaces](https://docs.github.com/en/codespaces) by clicking the Code button on the DeePMD-kit repository page.
5+
The whole setup process requires about 10 minutes, so one needs to be patient.
6+
7+
## Python environment
8+
9+
The following packages are installed into the Python environment `.venv`:
10+
11+
- DeePMD-kit (in edit mode)
12+
- Backends including TensorFlow, PyTorch, JAX
13+
- LAMMPS
14+
- MPICH
15+
- CMake
16+
- pre-commit (including hooks)
17+
- Test packages including pytest
18+
- Doc packages including sphinx
19+
20+
## C++ interface
21+
22+
The C++ interface with TensorFlow and PyTorch support is installed into `dp` directory.
23+
24+
When calling and debuging LAMMPS with DeePMD-kit, use the following scripts instead of the regular `lmp`:
25+
26+
- `.devcontainer/lmp`
27+
- `.devcontainer/gdb_lmp`
28+
29+
Use the following scripts for `pytest` with LAMMPS:
30+
31+
- `.devcontainer/pytest_lmp`
32+
- `.devcontainer/gdb_pytest_lmp`
33+
34+
## Rebuild
35+
36+
Usually the Python package does not need to reinstall.
37+
But when one wants to recompile the C++ code, the following scripts can be executed.
38+
39+
- `.devcontainer/build_cxx.sh`
40+
- `.devcontainer/build_py.sh`

.devcontainer/build_cxx.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
NPROC=$(nproc --all)
5+
SCRIPT_PATH=$(dirname $(realpath -s $0))
6+
7+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
8+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
9+
10+
mkdir -p ${SCRIPT_PATH}/../buildcxx/
11+
cd ${SCRIPT_PATH}/../buildcxx/
12+
cmake -D ENABLE_TENSORFLOW=ON \
13+
-D ENABLE_PYTORCH=ON \
14+
-D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \
15+
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
16+
-D CMAKE_BUILD_TYPE=Debug \
17+
-D BUILD_TESTING:BOOL=TRUE \
18+
-D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \
19+
${SCRIPT_PATH}/../source
20+
cmake --build . -j${NPROC}
21+
cmake --install .

.devcontainer/build_py.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
SCRIPT_PATH=$(dirname $(realpath -s $0))
5+
cd ${SCRIPT_PATH}/..
6+
7+
uv sync --dev --python 3.12 --extra cpu --extra torch --extra jax --extra lmp --extra test --extra docs
8+
pre-commit install

.devcontainer/devcontainer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "DeePMD-kit",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/github-cli:1": {}
8+
},
9+
"postCreateCommand": ".devcontainer/build_py.sh && .devcontainer/download_libtorch.sh && .devcontainer/build_cxx.sh && pre-commit install-hooks",
10+
"remoteEnv": {
11+
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin",
12+
"DP_ENABLE_PYTORCH": "1",
13+
"DP_VARIANT": "cpu",
14+
"LMP_CXX11_ABI_0": "1",
15+
"UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu"
16+
}
17+
}

.devcontainer/download_libtorch.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -ev
3+
4+
SCRIPT_PATH=$(dirname $(realpath -s $0))
5+
cd ${SCRIPT_PATH}/..
6+
7+
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcpu.zip -O ~/libtorch.zip
8+
unzip ~/libtorch.zip

.devcontainer/gdb_lmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
gdb ${SCRIPT_PATH}/../.venv/lib/python3.12/site-packages/lammps/lmp "$@"

.devcontainer/gdb_pytest_lmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
gdb --args python -m pytest -s "$@"

.devcontainer/lmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
${SCRIPT_PATH}/../.venv/bin/lmp "$@"

.devcontainer/pytest_lmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..
3+
4+
export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
5+
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
6+
7+
env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
8+
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
9+
python -m pytest "$@"

.git_archival.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# do not show up detailed difference on GitHub
22
source/3rdparty/* linguist-generated=true
3+
source/3rdparty/README.md linguist-generated=false
4+
.git_archival.txt export-subst

.github/ISSUE_TEMPLATE/bug-report.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ body:
2121
validations:
2222
required: true
2323
- type: input
24-
id: tf-version
24+
id: backend-version
2525
attributes:
26-
label: TensorFlow Version
27-
description: "The version will be printed when running DeePMD-kit."
26+
label: Backend and its version
27+
description: "The backend and its version will be printed when running DeePMD-kit, e.g. TensorFlow v2.15.0."
2828
validations:
2929
required: true
3030
- type: dropdown

.github/ISSUE_TEMPLATE/generic-issue.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ body:
2121
validations:
2222
required: true
2323
- type: input
24-
id: tf-version
24+
id: backend-version
2525
attributes:
26-
label: TensorFlow Version
27-
description: "The version will be printed when running DeePMD-kit."
26+
label: Backend and its version
27+
description: "The backend and its version will be printed when running DeePMD-kit, e.g. TensorFlow v2.15.0."
2828
validations:
2929
required: true
3030
- type: textarea

.github/labeler.yml

+38-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
Python:
2-
- changed-files:
3-
- any-glob-to-any-file:
4-
- deepmd/**/*
5-
- deepmd_utils/**/*
6-
- source/tests/**/*
7-
Docs:
8-
- changed-files:
9-
- any-glob-to-any-file: doc/**/*
10-
Examples:
11-
- changed-files:
12-
- any-glob-to-any-file: examples/**/*
13-
Core:
14-
- changed-files:
15-
- any-glob-to-any-file: source/lib/**/*
16-
CUDA:
17-
- changed-files:
18-
- any-glob-to-any-file: source/lib/src/gpu/**/*
19-
ROCM:
20-
- changed-files:
21-
- any-glob-to-any-file: source/lib/src/gpu/**/*
22-
OP:
23-
- changed-files:
24-
- any-glob-to-any-file: source/op/**/*
25-
C++:
26-
- changed-files:
27-
- any-glob-to-any-file: source/api_cc/**/*
28-
C:
29-
- changed-files:
30-
- any-glob-to-any-file: source/api_c/**/*
31-
LAMMPS:
32-
- changed-files:
33-
- any-glob-to-any-file: source/lmp/**/*
34-
Gromacs:
35-
- changed-files:
36-
- any-glob-to-any-file: source/gmx/**/*
37-
i-Pi:
38-
- changed-files:
39-
- any-glob-to-any-file: source/ipi/**/*
1+
Python:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- deepmd/**/*
5+
- source/tests/**/*
6+
Docs:
7+
- changed-files:
8+
- any-glob-to-any-file: doc/**/*
9+
Examples:
10+
- changed-files:
11+
- any-glob-to-any-file: examples/**/*
12+
Core:
13+
- changed-files:
14+
- any-glob-to-any-file: source/lib/**/*
15+
CUDA:
16+
- changed-files:
17+
- any-glob-to-any-file: source/lib/src/gpu/**/*
18+
ROCM:
19+
- changed-files:
20+
- any-glob-to-any-file: source/lib/src/gpu/**/*
21+
OP:
22+
- changed-files:
23+
- any-glob-to-any-file: source/op/**/*
24+
C++:
25+
- changed-files:
26+
- any-glob-to-any-file: source/api_cc/**/*
27+
C:
28+
- changed-files:
29+
- any-glob-to-any-file: source/api_c/**/*
30+
LAMMPS:
31+
- changed-files:
32+
- any-glob-to-any-file: source/lmp/**/*
33+
Gromacs:
34+
- changed-files:
35+
- any-glob-to-any-file: source/gmx/**/*
36+
i-PI:
37+
- changed-files:
38+
- any-glob-to-any-file: source/ipi/**/*

.github/workflows/build_cc.yml

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
on:
22
push:
3+
branches-ignore:
4+
- "gh-readonly-queue/**"
35
pull_request:
6+
merge_group:
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
9+
cancel-in-progress: true
410
name: Build C++
511
jobs:
612
buildcc:
713
name: Build C++
8-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
915
strategy:
1016
matrix:
1117
include:
@@ -24,9 +30,13 @@ jobs:
2430
- uses: actions/setup-python@v5
2531
with:
2632
python-version: '3.11'
27-
cache: 'pip'
2833
- uses: lukka/get-cmake@latest
29-
- run: python -m pip install tensorflow
34+
- run: python -m pip install uv
35+
- run: source/install/uv_with_retry.sh pip install --system tensorflow
36+
- name: Download libtorch
37+
run: |
38+
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcpu.zip -O libtorch.zip
39+
unzip libtorch.zip
3040
- run: |
3141
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
3242
&& sudo dpkg -i cuda-keyring_1.0-1_all.deb \
@@ -48,13 +58,17 @@ jobs:
4858
&& sudo apt-get update \
4959
&& sudo apt-get install -y rocm-dev hipcub-dev
5060
if: matrix.variant == 'rocm'
51-
- run: source/install/build_cc.sh
61+
- run: |
62+
export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch
63+
source/install/build_cc.sh
5264
env:
5365
DP_VARIANT: ${{ matrix.dp_variant }}
5466
DOWNLOAD_TENSORFLOW: "FALSE"
5567
CMAKE_GENERATOR: Ninja
5668
if: matrix.variant != 'clang'
57-
- run: source/install/build_cc.sh
69+
- run: |
70+
export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch
71+
source/install/build_cc.sh
5872
env:
5973
DP_VARIANT: cpu
6074
DOWNLOAD_TENSORFLOW: "FALSE"

0 commit comments

Comments
 (0)