Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c0b71f0
chore: bump LAMMPS to stable_22Jul2025
njzjz Aug 3, 2025
3cb979d
vendor old get_lammps_version
njzjz Aug 3, 2025
2742eaa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 3, 2025
3948184
fix typo
njzjz Aug 3, 2025
fbea912
update lammps version
njzjz Aug 3, 2025
db0048e
logging for debug
njzjz Aug 4, 2025
6a68f9d
debug lmp, not ipi
njzjz Aug 4, 2025
0c84093
Merge branch 'devel' into lammps-stable_22Jul2025
njzjz Aug 4, 2025
7d651ab
clean up LMP_CXX11_ABI_0
njzjz Aug 4, 2025
b6ed9ee
Merge branch 'lammps-stable_22Jul2025' of https://github.com/njzjz/de…
njzjz Aug 4, 2025
77dd1a9
Revert "debug lmp, not ipi"
njzjz Aug 4, 2025
c17c713
Revert "logging for debug"
njzjz Aug 4, 2025
6797908
disable the MPI tests
njzjz Aug 4, 2025
7cd3e7d
mpich is still required
njzjz Aug 5, 2025
00c8bc7
fix idx_map
njzjz Aug 5, 2025
b897686
bump lammps to 2025.7.22.0.2
njzjz Aug 5, 2025
1a3aac5
Revert "mpich is still required"
njzjz Aug 5, 2025
b649db6
Revert "disable the MPI tests"
njzjz Aug 5, 2025
9e3ca79
install mpich
njzjz Aug 5, 2025
e9f548c
Revert "Revert "disable the MPI tests""
njzjz Aug 5, 2025
51c5eef
Revert "Revert "mpich is still required""
njzjz Aug 5, 2025
705bb52
fix idx_map
njzjz Aug 5, 2025
ae8d2c5
move mpich deps to metadata
njzjz Aug 5, 2025
839063f
Update pyproject.toml
njzjz Aug 5, 2025
27fd43a
Update pyproject.toml
njzjz Aug 5, 2025
0111e96
load mpi
njzjz Aug 5, 2025
fe1aa56
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2025
5a288bd
fix errors
njzjz Aug 6, 2025
36db848
fix slice
njzjz Aug 6, 2025
31b541b
fix
njzjz Aug 6, 2025
2dde1b7
Revert "Revert "Revert "mpich is still required"""
njzjz Aug 6, 2025
4036f0a
Revert "Revert "Revert "disable the MPI tests"""
njzjz Aug 6, 2025
7a9ac5f
add mpich to dependencies
njzjz Aug 6, 2025
aca113c
use cdll
njzjz Aug 6, 2025
7a1dd60
move check build out of lmp.py
njzjz Aug 6, 2025
af44833
avoid load symlink
njzjz Aug 6, 2025
a987430
fix match
njzjz Aug 6, 2025
20c3b27
remove conflict mpi in test_cuda
njzjz Aug 7, 2025
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
2 changes: 1 addition & 1 deletion .devcontainer/build_cxx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cmake -D ENABLE_TENSORFLOW=ON \
-D ENABLE_PYTORCH=ON \
-D ENABLE_PADDLE=ON \
-D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
-D LAMMPS_VERSION=stable_22Jul2025 \
-D CMAKE_BUILD_TYPE=Debug \
-D BUILD_TESTING:BOOL=TRUE \
-D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \
Expand Down
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"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"
}
}
1 change: 0 additions & 1 deletion .github/workflows/test_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
LMP_CXX11_ABI_0: 1
CMAKE_GENERATOR: Ninja
CXXFLAGS: ${{ matrix.check_memleak && '-fsanitize=leak' || '' }}
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/workflows/suppr.txt
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/test_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
with:
python-version: '3.11'
# cache: 'pip'
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich
- name: Install wget and unzip
run: apt-get update && apt-get install -y wget unzip
- uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -74,7 +70,6 @@ jobs:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
LMP_CXX11_ABI_0: 1
CMAKE_GENERATOR: Ninja
DP_VARIANT: cuda
DP_USE_MPICH2: 1
Expand Down
7 changes: 7 additions & 0 deletions backend/dp_backend.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
"""A PEP-517 backend to find TensorFlow."""

import os

from scikit_build_core import build as _orig

from .find_pytorch import (
Expand Down Expand Up @@ -39,10 +41,15 @@ def __dir__() -> list[str]:
def get_requires_for_build_wheel(
config_settings: dict,
) -> list[str]:
if os.environ.get("CIBUILDWHEEL", "0") == "1":
cibw_deps = ["mpich"]
else:
cibw_deps = []
return (
_orig.get_requires_for_build_wheel(config_settings)
+ find_tensorflow()[1]
+ find_pytorch()[1]
+ cibw_deps
)


Expand Down
8 changes: 7 additions & 1 deletion backend/find_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ def get_pt_requirement(pt_version: str = "") -> dict:
raise RuntimeError("Unsupported CUDA version") from None
if pt_version == "":
pt_version = os.environ.get("PYTORCH_VERSION", "")
if os.environ.get("CIBUILDWHEEL", "0") == "1":
# PyTorch OP library is built against mpich
mpi_requirement = ["mpich"]
else:
mpi_requirement = []

return {
"torch": [
Expand All @@ -134,7 +139,8 @@ def get_pt_requirement(pt_version: str = "") -> dict:
f"torch=={Version(pt_version).base_version}.*"
if pt_version != ""
# https://github.com/pytorch/pytorch/commit/7e0c26d4d80d6602aed95cb680dfc09c9ce533bc
else "torch>=2.1.0"
else "torch>=2.1.0",
*mpi_requirement,
],
}

Expand Down
1 change: 1 addition & 0 deletions backend/read_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]:

cmake_args = [
"-DBUILD_PY_IF:BOOL=TRUE",
f"-DCIBUILDWHEEL={os.environ.get('CIBUILDWHEEL', '0')}",
*cmake_args,
]
return (
Expand Down
1 change: 0 additions & 1 deletion deepmd/lmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def get_library_path(module: str, filename: str) -> list[str]:
pt_dir = os.path.join(torch.__path__[0], "lib")
op_dir = str(SHARED_LIB_DIR)


cuda_library_paths = []
if platform.system() == "Linux":
cuda_library_paths.extend(
Expand Down
19 changes: 19 additions & 0 deletions deepmd/lmp_check_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from deepmd.env import (
GLOBAL_CONFIG,
)

if GLOBAL_CONFIG.get("lammps_version", "") == "":

def get_op_dir() -> str:
"""Get the directory of the deepmd-kit OP library."""
# empty
return ""
else:
from deepmd.lmp import (
get_op_dir,
)

__all__ = [
"get_op_dir",
]
30 changes: 30 additions & 0 deletions deepmd/pt/cxx_op.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import platform
from ctypes import (
CDLL,
RTLD_GLOBAL,
)
from importlib import (
metadata,
)

import torch
from packaging.version import (
Expand Down Expand Up @@ -87,6 +94,29 @@ def load_library(module_name: str) -> bool:
return False


def load_mpi_library() -> None:
"""Load MPI library.

When building with cibuildwheel, the link to the MPI library is lost
after the wheel is repaired.
"""
if platform.system() == "Linux":
libname = "libmpi.so.*"
elif platform.system() == "Darwin":
libname = "libmpi.*.dylib"
else:
raise RuntimeError("Unsupported platform")
MPI_LIB = next(p for p in metadata.files("mpich") if p.match(libname)).locate()
# use CDLL to load the library
CDLL(MPI_LIB, mode=RTLD_GLOBAL)


if GLOBAL_CONFIG.get("cibuildwheel", "0") == "1" and platform.system() in (
"Linux",
"Darwin",
):
load_mpi_library()

ENABLE_CUSTOMIZED_OP = load_library("deepmd_op_pt")

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion doc/install/easy-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ If your platform is not supported, or you want to build against the installed ba
pip install deepmd-kit[gpu,cu12,lmp,ipi]
```

MPICH is required for parallel running.
MPICH will be installed automatically - you do not need to install a MPI library by yourself.
22 changes: 11 additions & 11 deletions doc/install/install-lammps.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ DeePMD-kit will generate a module called `USER-DEEPMD` in the `build` directory,

```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/stable_29Aug2024_update1.tar.gz
tar xf stable_29Aug2024_update1.tar.gz
wget https://github.com/lammps/lammps/archive/stable_22Jul2025.tar.gz
tar xf stable_22Jul2025.tar.gz
```

The source code of LAMMPS is stored in the directory `lammps-stable_29Aug2024_update1`.
The source code of LAMMPS is stored in the directory `lammps-stable_22Jul2025`.

Then, you can [build LAMMPS](https://docs.lammps.org/Build.html) with either make or CMake.

Expand All @@ -30,7 +30,7 @@ Then, you can [build LAMMPS](https://docs.lammps.org/Build.html) with either mak
Now go into the LAMMPS code and copy the DeePMD-kit module like this

```bash
cd lammps-stable_29Aug2024_update1/src/
cd lammps-stable_22Jul2025/src/
cp -r $deepmd_source_dir/source/build/USER-DEEPMD .
make yes-kspace
make yes-extra-fix
Expand Down Expand Up @@ -60,8 +60,8 @@ make no-user-deepmd
Now go into the LAMMPS directory and create a directory called `build`:

```bash
mkdir -p lammps-stable_29Aug2024_update1/build/
cd lammps-stable_29Aug2024_update1/build/
mkdir -p lammps-stable_22Jul2025/build/
cd lammps-stable_22Jul2025/build/
```

Patch the LAMMPS `CMakeLists.txt` file:
Expand Down Expand Up @@ -94,15 +94,15 @@ Now download the LAMMPS code (`8Apr2021` or later), and uncompress it:

```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/stable_29Aug2024_update1.tar.gz
tar xf stable_29Aug2024_update1.tar.gz
wget https://github.com/lammps/lammps/archive/stable_22Jul2025.tar.gz
tar xf stable_22Jul2025.tar.gz
```

The source code of LAMMPS is stored in the directory `lammps-stable_29Aug2024_update1`. The directory of the source code should be specified as the CMAKE argument `LAMMPS_SOURCE_ROOT` during installation of the DeePMD-kit C++ interface. Now go into the LAMMPS directory and create a directory called `build`
The source code of LAMMPS is stored in the directory `lammps-stable_22Jul2025`. The directory of the source code should be specified as the CMAKE argument `LAMMPS_SOURCE_ROOT` during installation of the DeePMD-kit C++ interface. Now go into the LAMMPS directory and create a directory called `build`

```bash
mkdir -p lammps-stable_29Aug2024_update1/build/
cd lammps-stable_29Aug2024_update1/build/
mkdir -p lammps-stable_22Jul2025/build/
cd lammps-stable_22Jul2025/build/
```

Now build LAMMPS. Note that `PLUGIN` must be enabled, and `BUILD_SHARED_LIBS` must be set to `yes`. You can install any other package you want.
Expand Down
18 changes: 5 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ requires-python = ">=3.9"
keywords = ["deepmd"]

[project.entry-points."lammps.plugins"]
deepmd = "deepmd.lmp:get_op_dir"
deepmd = "deepmd.lmp_check_build:get_op_dir"

[project.entry-points."dpgui"]
"DeePMD-kit" = "deepmd.utils.argcheck:gen_args"
Expand Down Expand Up @@ -108,7 +108,7 @@ docs = [
"sphinx-remove-toctrees",
]
lmp = [
"lammps~=2024.8.29.1.0",
"lammps[mpi]~=2025.7.22.0.2",
]
ipi = [
"ipi",
Expand Down Expand Up @@ -238,14 +238,11 @@ manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2022-11-19-1b19e81"
manylinux-aarch64-image = "manylinux_2_28"

[tool.cibuildwheel.macos]
before-all = [
'''pip install mpich''',
]
repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies"""

[tool.cibuildwheel.macos.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_29Aug2024_update1"
DP_LAMMPS_VERSION = "stable_22Jul2025"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
DP_ENABLE_PADDLE = "1"
Expand All @@ -259,7 +256,7 @@ inherit.environment = "append"
environment.MACOSX_DEPLOYMENT_TARGET = "11.0"

[tool.cibuildwheel.linux]
repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 --exclude libc10.so --exclude libtorch.so --exclude libtorch_cpu.so -w {dest_dir} {wheel}"
repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 --exclude libc10.so --exclude libtorch.so --exclude libtorch_cpu.so --exclude libmpi.so.12 -w {dest_dir} {wheel}"
environment-pass = [
"CIBW_BUILD",
"DP_VARIANT",
Expand All @@ -272,7 +269,6 @@ before-all = [
# https://almalinux.org/blog/2023-12-20-almalinux-8-key-update/
"""rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux""",
"""{ if [ "$(uname -m)" = "x86_64" ] ; then yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-nvcc-${CUDA_VERSION/./-} cuda-cudart-devel-${CUDA_VERSION/./-}; fi }""",
'''/opt/python/cp311-cp311/bin/python -m pip install mpich''',
# uv is not available in the old manylinux image
"""{ if [ "$(uname -m)" = "x86_64" ] ; then pipx install uv; fi }""",
]
Expand All @@ -282,18 +278,14 @@ before-build = [
]
[tool.cibuildwheel.linux.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_29Aug2024_update1"
DP_LAMMPS_VERSION = "stable_22Jul2025"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
DP_ENABLE_PADDLE = "1"
MPI_HOME = "/usr/lib64/mpich"
PATH = "/usr/lib64/mpich/bin:$PATH"
# use CPU version of torch for building, which should also work for GPU
# note: uv has different behavior from pip on extra index url
# https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY.md#packages-that-exist-on-multiple-indexes
UV_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu"
# trick to find the correction version of mpich
CMAKE_PREFIX_PATH="/opt/python/cp311-cp311/"

[tool.cibuildwheel.windows]
test-extras = ["cpu", "torch", "paddle"]
Expand Down
2 changes: 2 additions & 0 deletions source/config/run_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ PD_VERSION = @PADDLE_VERSION@
PD_INFERENCE_DIR = @PADDLE_INFERENCE_DIR@
MODEL_VERSION=@MODEL_VERSION@
DP_VARIANT=@DP_VARIANT@
LAMMPS_VERSION = @LAMMPS_VERSION@
CIBUILDWHEEL = @CIBUILDWHEEL@
2 changes: 1 addition & 1 deletion source/install/build_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cmake -D ENABLE_TENSORFLOW=ON \
-D USE_TF_PYTHON_LIBS=TRUE \
-D USE_PT_PYTHON_LIBS=TRUE \
${CUDA_ARGS} \
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
-D LAMMPS_VERSION=stable_22Jul2025 \
..
cmake --build . -j${NPROC}
cmake --install .
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_from_c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_29Aug2024_update1 ..
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_22Jul2025 ..
cmake --build . -j${NPROC}
cmake --install .
cmake --build . --target=lammps
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_lammps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BUILD_TMP_DIR=${SCRIPT_PATH}/../build_lammps
mkdir -p ${BUILD_TMP_DIR}
cd ${BUILD_TMP_DIR}
# download LAMMMPS
LAMMPS_VERSION=stable_29Aug2024_update1
LAMMPS_VERSION=stable_22Jul2025
if [ ! -d "lammps-${LAMMPS_VERSION}" ]; then
curl -L -o lammps.tar.gz https://github.com/lammps/lammps/archive/refs/tags/${LAMMPS_VERSION}.tar.gz
tar vxzf lammps.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion source/install/test_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INSTALL_PREFIX=${SCRIPT_PATH}/../../dp_test
BUILD_TMP_DIR=${SCRIPT_PATH}/../build_tests
mkdir -p ${BUILD_TMP_DIR}
cd ${BUILD_TMP_DIR}
cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_29Aug2024_update1 ${CUDA_ARGS} ..
cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_22Jul2025 ${CUDA_ARGS} ..
cmake --build . -j${NPROC}
cmake --install .
ctest --output-on-failure
2 changes: 1 addition & 1 deletion source/install/test_cc_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cmake \
-D USE_PT_PYTHON_LIBS=TRUE \
-D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-D BUILD_TESTING:BOOL=TRUE \
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
-D LAMMPS_VERSION=stable_22Jul2025 \
${CUDA_ARGS} ..
cmake --build . -j${NPROC}
cmake --install .
Expand Down
Loading
Loading