Skip to content

Commit

Permalink
merge devel to master (v3.0.0) (deepmodeling#4407)
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz authored Nov 23, 2024
2 parents b875ea8 + 2303ff0 commit e695a91
Show file tree
Hide file tree
Showing 1,566 changed files with 217,864 additions and 33,846 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
40 changes: 40 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# DeePMD-kit devcontainer environment

This [devcontainer](https://vscode.js.cn/docs/devcontainers/devcontainer-cli) environment setups Python and C++ environment to develop DeePMD-kit.
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.
The whole setup process requires about 10 minutes, so one needs to be patient.

## Python environment

The following packages are installed into the Python environment `.venv`:

- DeePMD-kit (in edit mode)
- Backends including TensorFlow, PyTorch, JAX
- LAMMPS
- MPICH
- CMake
- pre-commit (including hooks)
- Test packages including pytest
- Doc packages including sphinx

## C++ interface

The C++ interface with TensorFlow and PyTorch support is installed into `dp` directory.

When calling and debuging LAMMPS with DeePMD-kit, use the following scripts instead of the regular `lmp`:

- `.devcontainer/lmp`
- `.devcontainer/gdb_lmp`

Use the following scripts for `pytest` with LAMMPS:

- `.devcontainer/pytest_lmp`
- `.devcontainer/gdb_pytest_lmp`

## Rebuild

Usually the Python package does not need to reinstall.
But when one wants to recompile the C++ code, the following scripts can be executed.

- `.devcontainer/build_cxx.sh`
- `.devcontainer/build_py.sh`
21 changes: 21 additions & 0 deletions .devcontainer/build_cxx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -ev

NPROC=$(nproc --all)
SCRIPT_PATH=$(dirname $(realpath -s $0))

export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')

mkdir -p ${SCRIPT_PATH}/../buildcxx/
cd ${SCRIPT_PATH}/../buildcxx/
cmake -D ENABLE_TENSORFLOW=ON \
-D ENABLE_PYTORCH=ON \
-D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
-D CMAKE_BUILD_TYPE=Debug \
-D BUILD_TESTING:BOOL=TRUE \
-D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \
${SCRIPT_PATH}/../source
cmake --build . -j${NPROC}
cmake --install .
8 changes: 8 additions & 0 deletions .devcontainer/build_py.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ev

SCRIPT_PATH=$(dirname $(realpath -s $0))
cd ${SCRIPT_PATH}/..

uv sync --dev --python 3.12 --extra cpu --extra torch --extra jax --extra lmp --extra test --extra docs
pre-commit install
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "DeePMD-kit",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"postCreateCommand": ".devcontainer/build_py.sh && .devcontainer/download_libtorch.sh && .devcontainer/build_cxx.sh && pre-commit install-hooks",
"remoteEnv": {
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin",
"DP_ENABLE_PYTORCH": "1",
"DP_VARIANT": "cpu",
"LMP_CXX11_ABI_0": "1",
"UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu"
}
}
8 changes: 8 additions & 0 deletions .devcontainer/download_libtorch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ev

SCRIPT_PATH=$(dirname $(realpath -s $0))
cd ${SCRIPT_PATH}/..

wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcpu.zip -O ~/libtorch.zip
unzip ~/libtorch.zip
9 changes: 9 additions & 0 deletions .devcontainer/gdb_lmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
SCRIPT_PATH=$(dirname $(realpath -s $0))

export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')

env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
gdb ${SCRIPT_PATH}/../.venv/lib/python3.12/site-packages/lammps/lmp "$@"
9 changes: 9 additions & 0 deletions .devcontainer/gdb_pytest_lmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..

export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')

env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
gdb --args python -m pytest -s "$@"
9 changes: 9 additions & 0 deletions .devcontainer/lmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
SCRIPT_PATH=$(dirname $(realpath -s $0))

export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')

env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
${SCRIPT_PATH}/../.venv/bin/lmp "$@"
9 changes: 9 additions & 0 deletions .devcontainer/pytest_lmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
SCRIPT_PATH=$(dirname $(realpath -s $0))/../..

export CMAKE_PREFIX_PATH=${SCRIPT_PATH}/../libtorch
TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')

env LAMMPS_PLUGIN_PATH=${SCRIPT_PATH}/../dp/lib/deepmd_lmp \
LD_LIBRARY_PATH=${SCRIPT_PATH}/../dp/lib:${CMAKE_PREFIX_PATH}/lib:${TENSORFLOW_ROOT} \
python -m pytest "$@"
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# do not show up detailed difference on GitHub
source/3rdparty/* linguist-generated=true
source/3rdparty/README.md linguist-generated=false
.git_archival.txt export-subst
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ body:
validations:
required: true
- type: input
id: tf-version
id: backend-version
attributes:
label: TensorFlow Version
description: "The version will be printed when running DeePMD-kit."
label: Backend and its version
description: "The backend and its version will be printed when running DeePMD-kit, e.g. TensorFlow v2.15.0."
validations:
required: true
- type: dropdown
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/generic-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ body:
validations:
required: true
- type: input
id: tf-version
id: backend-version
attributes:
label: TensorFlow Version
description: "The version will be printed when running DeePMD-kit."
label: Backend and its version
description: "The backend and its version will be printed when running DeePMD-kit, e.g. TensorFlow v2.15.0."
validations:
required: true
- type: textarea
Expand Down
77 changes: 38 additions & 39 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
Python:
- changed-files:
- any-glob-to-any-file:
- deepmd/**/*
- deepmd_utils/**/*
- source/tests/**/*
Docs:
- changed-files:
- any-glob-to-any-file: doc/**/*
Examples:
- changed-files:
- any-glob-to-any-file: examples/**/*
Core:
- changed-files:
- any-glob-to-any-file: source/lib/**/*
CUDA:
- changed-files:
- any-glob-to-any-file: source/lib/src/gpu/**/*
ROCM:
- changed-files:
- any-glob-to-any-file: source/lib/src/gpu/**/*
OP:
- changed-files:
- any-glob-to-any-file: source/op/**/*
C++:
- changed-files:
- any-glob-to-any-file: source/api_cc/**/*
C:
- changed-files:
- any-glob-to-any-file: source/api_c/**/*
LAMMPS:
- changed-files:
- any-glob-to-any-file: source/lmp/**/*
Gromacs:
- changed-files:
- any-glob-to-any-file: source/gmx/**/*
i-Pi:
- changed-files:
- any-glob-to-any-file: source/ipi/**/*
Python:
- changed-files:
- any-glob-to-any-file:
- deepmd/**/*
- source/tests/**/*
Docs:
- changed-files:
- any-glob-to-any-file: doc/**/*
Examples:
- changed-files:
- any-glob-to-any-file: examples/**/*
Core:
- changed-files:
- any-glob-to-any-file: source/lib/**/*
CUDA:
- changed-files:
- any-glob-to-any-file: source/lib/src/gpu/**/*
ROCM:
- changed-files:
- any-glob-to-any-file: source/lib/src/gpu/**/*
OP:
- changed-files:
- any-glob-to-any-file: source/op/**/*
C++:
- changed-files:
- any-glob-to-any-file: source/api_cc/**/*
C:
- changed-files:
- any-glob-to-any-file: source/api_c/**/*
LAMMPS:
- changed-files:
- any-glob-to-any-file: source/lmp/**/*
Gromacs:
- changed-files:
- any-glob-to-any-file: source/gmx/**/*
i-PI:
- changed-files:
- any-glob-to-any-file: source/ipi/**/*
24 changes: 19 additions & 5 deletions .github/workflows/build_cc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
on:
push:
branches-ignore:
- "gh-readonly-queue/**"
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
name: Build C++
jobs:
buildcc:
name: Build C++
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
include:
Expand All @@ -24,9 +30,13 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- uses: lukka/get-cmake@latest
- run: python -m pip install tensorflow
- run: python -m pip install uv
- run: source/install/uv_with_retry.sh pip install --system tensorflow
- name: Download libtorch
run: |
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.1.2%2Bcpu.zip -O libtorch.zip
unzip libtorch.zip
- run: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
&& sudo dpkg -i cuda-keyring_1.0-1_all.deb \
Expand All @@ -48,13 +58,17 @@ jobs:
&& sudo apt-get update \
&& sudo apt-get install -y rocm-dev hipcub-dev
if: matrix.variant == 'rocm'
- run: source/install/build_cc.sh
- run: |
export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch
source/install/build_cc.sh
env:
DP_VARIANT: ${{ matrix.dp_variant }}
DOWNLOAD_TENSORFLOW: "FALSE"
CMAKE_GENERATOR: Ninja
if: matrix.variant != 'clang'
- run: source/install/build_cc.sh
- run: |
export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch
source/install/build_cc.sh
env:
DP_VARIANT: cpu
DOWNLOAD_TENSORFLOW: "FALSE"
Expand Down
Loading

0 comments on commit e695a91

Please sign in to comment.