Skip to content

Commit bcc267e

Browse files
chore: bump LAMMPS to stable_22Jul2025 (#4861)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated all scripts, configuration files, and documentation to use the latest LAMMPS stable release version (stable_22Jul2025) for building and installing DeePMD-kit. * Adjusted dependency specifications and environment variables to reflect the new LAMMPS version. * Revised installation instructions to reference the updated LAMMPS source archive and directory names. * Replaced external LAMMPS version extraction with a custom implementation for improved version parsing. * Removed obsolete environment variable settings related to C++ ABI configuration. * Updated build dependencies to conditionally include the MPI package based on the build environment. * Enhanced environment setup to properly handle CUDA and MPI library paths across platforms during build and runtime. * Improved library loading to explicitly load MPI libraries when building with cibuildwheel. * Clarified installation documentation to indicate automatic MPICH installation without manual MPI setup. * Added conditional interface to manage LAMMPS OP library directory retrieval based on configuration. * **Tests** * Modified tests to restrict atom ID indexing to the subset of atoms matching coordinate array lengths for consistency in validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@ustc.edu.cn> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 102a2ed commit bcc267e

35 files changed

+227
-88
lines changed

.devcontainer/build_cxx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cmake -D ENABLE_TENSORFLOW=ON \
1313
-D ENABLE_PYTORCH=ON \
1414
-D ENABLE_PADDLE=ON \
1515
-D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \
16-
-D LAMMPS_VERSION=stable_29Aug2024_update1 \
16+
-D LAMMPS_VERSION=stable_22Jul2025 \
1717
-D CMAKE_BUILD_TYPE=Debug \
1818
-D BUILD_TESTING:BOOL=TRUE \
1919
-D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \

.devcontainer/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin",
1212
"DP_ENABLE_PYTORCH": "1",
1313
"DP_VARIANT": "cpu",
14-
"LMP_CXX11_ABI_0": "1",
1514
"UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu"
1615
}
1716
}

.github/workflows/test_cc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
OMP_NUM_THREADS: 1
4242
TF_INTRA_OP_PARALLELISM_THREADS: 1
4343
TF_INTER_OP_PARALLELISM_THREADS: 1
44-
LMP_CXX11_ABI_0: 1
4544
CMAKE_GENERATOR: Ninja
4645
CXXFLAGS: ${{ matrix.check_memleak && '-fsanitize=leak' || '' }}
4746
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/workflows/suppr.txt

.github/workflows/test_cuda.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ jobs:
3030
with:
3131
python-version: '3.11'
3232
# cache: 'pip'
33-
- name: Setup MPI
34-
uses: mpi4py/setup-mpi@v1
35-
with:
36-
mpi: mpich
3733
- name: Install wget and unzip
3834
run: apt-get update && apt-get install -y wget unzip
3935
- uses: lukka/get-cmake@latest
@@ -74,7 +70,6 @@ jobs:
7470
OMP_NUM_THREADS: 1
7571
TF_INTRA_OP_PARALLELISM_THREADS: 1
7672
TF_INTER_OP_PARALLELISM_THREADS: 1
77-
LMP_CXX11_ABI_0: 1
7873
CMAKE_GENERATOR: Ninja
7974
DP_VARIANT: cuda
8075
DP_USE_MPICH2: 1

backend/dp_backend.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# SPDX-License-Identifier: LGPL-3.0-or-later
22
"""A PEP-517 backend to find TensorFlow."""
33

4+
import os
5+
46
from scikit_build_core import build as _orig
57

68
from .find_pytorch import (
@@ -39,10 +41,15 @@ def __dir__() -> list[str]:
3941
def get_requires_for_build_wheel(
4042
config_settings: dict,
4143
) -> list[str]:
44+
if os.environ.get("CIBUILDWHEEL", "0") == "1":
45+
cibw_deps = ["mpich"]
46+
else:
47+
cibw_deps = []
4248
return (
4349
_orig.get_requires_for_build_wheel(config_settings)
4450
+ find_tensorflow()[1]
4551
+ find_pytorch()[1]
52+
+ cibw_deps
4653
)
4754

4855

backend/find_pytorch.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def get_pt_requirement(pt_version: str = "") -> dict:
124124
raise RuntimeError("Unsupported CUDA version") from None
125125
if pt_version == "":
126126
pt_version = os.environ.get("PYTORCH_VERSION", "")
127+
if os.environ.get("CIBUILDWHEEL", "0") == "1":
128+
# PyTorch OP library is built against mpich
129+
mpi_requirement = ["mpich"]
130+
else:
131+
mpi_requirement = []
127132

128133
return {
129134
"torch": [
@@ -134,7 +139,8 @@ def get_pt_requirement(pt_version: str = "") -> dict:
134139
f"torch=={Version(pt_version).base_version}.*"
135140
if pt_version != ""
136141
# https://github.com/pytorch/pytorch/commit/7e0c26d4d80d6602aed95cb680dfc09c9ce533bc
137-
else "torch>=2.1.0"
142+
else "torch>=2.1.0",
143+
*mpi_requirement,
138144
],
139145
}
140146

backend/read_env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]:
119119

120120
cmake_args = [
121121
"-DBUILD_PY_IF:BOOL=TRUE",
122+
f"-DCIBUILDWHEEL={os.environ.get('CIBUILDWHEEL', '0')}",
122123
*cmake_args,
123124
]
124125
return (

deepmd/lmp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def get_library_path(module: str, filename: str) -> list[str]:
8181
pt_dir = os.path.join(torch.__path__[0], "lib")
8282
op_dir = str(SHARED_LIB_DIR)
8383

84-
8584
cuda_library_paths = []
8685
if platform.system() == "Linux":
8786
cuda_library_paths.extend(

deepmd/lmp_check_build.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: LGPL-3.0-or-later
2+
from deepmd.env import (
3+
GLOBAL_CONFIG,
4+
)
5+
6+
if GLOBAL_CONFIG.get("lammps_version", "") == "":
7+
8+
def get_op_dir() -> str:
9+
"""Get the directory of the deepmd-kit OP library."""
10+
# empty
11+
return ""
12+
else:
13+
from deepmd.lmp import (
14+
get_op_dir,
15+
)
16+
17+
__all__ = [
18+
"get_op_dir",
19+
]

deepmd/pt/cxx_op.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# SPDX-License-Identifier: LGPL-3.0-or-later
22
import platform
3+
from ctypes import (
4+
CDLL,
5+
RTLD_GLOBAL,
6+
)
7+
from importlib import (
8+
metadata,
9+
)
310

411
import torch
512
from packaging.version import (
@@ -87,6 +94,29 @@ def load_library(module_name: str) -> bool:
8794
return False
8895

8996

97+
def load_mpi_library() -> None:
98+
"""Load MPI library.
99+
100+
When building with cibuildwheel, the link to the MPI library is lost
101+
after the wheel is repaired.
102+
"""
103+
if platform.system() == "Linux":
104+
libname = "libmpi.so.*"
105+
elif platform.system() == "Darwin":
106+
libname = "libmpi.*.dylib"
107+
else:
108+
raise RuntimeError("Unsupported platform")
109+
MPI_LIB = next(p for p in metadata.files("mpich") if p.match(libname)).locate()
110+
# use CDLL to load the library
111+
CDLL(MPI_LIB, mode=RTLD_GLOBAL)
112+
113+
114+
if GLOBAL_CONFIG.get("cibuildwheel", "0") == "1" and platform.system() in (
115+
"Linux",
116+
"Darwin",
117+
):
118+
load_mpi_library()
119+
90120
ENABLE_CUSTOMIZED_OP = load_library("deepmd_op_pt")
91121

92122
__all__ = [

0 commit comments

Comments
 (0)