Skip to content

Commit 6b79be9

Browse files
authored
Merge branch 'devel' into D0604_fitting_hook
2 parents 7c62be2 + c151e04 commit 6b79be9

101 files changed

Lines changed: 2001 additions & 403 deletions

Some content is hidden

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

.github/workflows/build_wheel.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
platform_id: macosx_arm64
4545
dp_variant: cpu
4646
# win-64
47-
- os: windows-2019
47+
- os: windows-2022
4848
python: 311
4949
platform_id: win_amd64
5050
dp_variant: cpu
@@ -70,7 +70,7 @@ jobs:
7070
rm -rf .git
7171
if: matrix.dp_pkg_name == 'deepmd-kit-cu11'
7272
- name: Build wheels
73-
uses: pypa/cibuildwheel@v2.23
73+
uses: pypa/cibuildwheel@v3.0
7474
env:
7575
CIBW_BUILD_VERBOSITY: 1
7676
CIBW_ARCHS: all

.github/workflows/test_cc.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@ jobs:
2121
with:
2222
python-version: '3.11'
2323
cache: 'pip'
24-
- name: Setup MPI
25-
uses: mpi4py/setup-mpi@v1
26-
with:
27-
mpi: mpich
2824
- uses: lukka/get-cmake@latest
2925
- run: python -m pip install uv
3026
- name: Install Python dependencies
3127
run: |
3228
source/install/uv_with_retry.sh pip install --system tensorflow-cpu~=2.18.0 jax==0.5.0
3329
export TENSORFLOW_ROOT=$(python -c 'import importlib,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
34-
source/install/uv_with_retry.sh pip install --system -e .[cpu,test,lmp,jax] mpi4py
30+
source/install/uv_with_retry.sh pip install --system -e .[cpu,test,lmp,jax] mpi4py mpich
3531
source/install/uv_with_retry.sh pip install --system 'torch==2.7' --index-url https://download.pytorch.org/whl/cpu
3632
- name: Convert models
3733
run: source/tests/infer/convert-models.sh
@@ -54,13 +50,13 @@ jobs:
5450
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/paddle/lib/*.so ${{ github.workspace }}/dp_test/lib/
5551
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/onednn/lib/* ${{ github.workspace }}/dp_test/lib/
5652
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/mklml/lib/* ${{ github.workspace }}/dp_test/lib/
53+
export LD_LIBRARY_PATH=${{ github.workspace }}/dp_test/lib:$LD_LIBRARY_PATH
5754
pytest --cov=deepmd source/lmp/tests
5855
env:
5956
OMP_NUM_THREADS: 1
6057
TF_INTRA_OP_PARALLELISM_THREADS: 1
6158
TF_INTER_OP_PARALLELISM_THREADS: 1
6259
LAMMPS_PLUGIN_PATH: ${{ github.workspace }}/dp_test/lib/deepmd_lmp
63-
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib
6460
if: ${{ !matrix.check_memleak }}
6561
# test ipi
6662
- run: |

.github/workflows/test_python.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
# changes, setting `TENSORFLOW_ROOT`.
4141
DP_ENABLE_PYTORCH: 1
4242
DP_BUILD_TESTING: 1
43-
UV_EXTRA_INDEX_URL: "https://pypi.anaconda.org/mpi4py/simple"
4443
HOROVOD_WITH_TENSORFLOW: 1
4544
HOROVOD_WITHOUT_PYTORCH: 1
4645
HOROVOD_WITH_MPI: 1

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
exclude: ^source/3rdparty
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
3131
# Ruff version.
32-
rev: v0.11.12
32+
rev: v0.12.2
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]
@@ -40,7 +40,7 @@ repos:
4040
types_or: [python, pyi, jupyter]
4141
- repo: https://github.com/pycqa/flake8
4242
# flake8 cannot autofix
43-
rev: "7.2.0"
43+
rev: "7.3.0"
4444
hooks:
4545
- id: flake8
4646
additional_dependencies:
@@ -60,7 +60,7 @@ repos:
6060
- id: blacken-docs
6161
# C++
6262
- repo: https://github.com/pre-commit/mirrors-clang-format
63-
rev: v20.1.5
63+
rev: v20.1.7
6464
hooks:
6565
- id: clang-format
6666
exclude: ^(source/3rdparty|source/lib/src/gpu/cudart/.+\.inc|.+\.ipynb$|.+\.json$)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ See [our v2 paper](https://doi.org/10.1063/5.0155600) for details of all feature
7676
#### v3
7777

7878
- Multiple backends supported. Add PyTorch and JAX backends.
79-
- The DPA-2 model.
79+
- The DPA2 and DPA3 models.
8080
- Plugin mechanisms for external models.
8181

8282
See [our v3 paper](https://doi.org/10.1021/acs.jctc.5c00340) for details of all features until v3.0.

deepmd/calculator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ def calculate(
130130
cell = None
131131
symbols = self.atoms.get_chemical_symbols()
132132
atype = [self.type_dict[k] for k in symbols]
133-
e, f, v = self.dp.eval(coords=coord, cells=cell, atom_types=atype)[:3]
133+
134+
fparam = self.atoms.info.get("fparam", None)
135+
aparam = self.atoms.info.get("aparam", None)
136+
e, f, v = self.dp.eval(
137+
coords=coord, cells=cell, atom_types=atype, fparam=fparam, aparam=aparam
138+
)[:3]
134139
self.results["energy"] = e[0][0]
135140
# see https://gitlab.com/ase/ase/-/merge_requests/2485
136141
self.results["free_energy"] = e[0][0]

deepmd/dpmodel/array_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def xp_take_along_axis(arr, indices, axis):
6060

6161
shape = list(arr.shape)
6262
shape.pop(-1)
63-
shape = [*shape, n]
63+
shape = (*shape, n)
6464

6565
arr = xp.reshape(arr, (-1,))
6666
if n != 0:

deepmd/dpmodel/descriptor/dpa1.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ def __init__(
319319
trainable_ln=trainable_ln,
320320
ln_eps=ln_eps,
321321
seed=child_seed(seed, 0),
322+
trainable=trainable,
322323
)
323324
self.use_econf_tebd = use_econf_tebd
324325
self.use_tebd_bias = use_tebd_bias
@@ -333,6 +334,7 @@ def __init__(
333334
use_tebd_bias=use_tebd_bias,
334335
type_map=type_map,
335336
seed=child_seed(seed, 1),
337+
trainable=trainable,
336338
)
337339
self.tebd_dim = tebd_dim
338340
self.concat_output_tebd = concat_output_tebd
@@ -520,7 +522,7 @@ def call(
520522
type_embedding = self.type_embedding.call()
521523
# nf x nall x tebd_dim
522524
atype_embd_ext = xp.reshape(
523-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
525+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
524526
(nf, nall, self.tebd_dim),
525527
)
526528
# nfnl x tebd_dim
@@ -691,6 +693,7 @@ def __init__(
691693
ln_eps: Optional[float] = 1e-5,
692694
smooth: bool = True,
693695
seed: Optional[Union[int, list[int]]] = None,
696+
trainable: bool = True,
694697
) -> None:
695698
self.rcut = rcut
696699
self.rcut_smth = rcut_smth
@@ -741,6 +744,7 @@ def __init__(
741744
self.resnet_dt,
742745
self.precision,
743746
seed=child_seed(seed, 0),
747+
trainable=trainable,
744748
)
745749
self.embeddings = embeddings
746750
if self.tebd_input_mode in ["strip"]:
@@ -756,6 +760,7 @@ def __init__(
756760
self.resnet_dt,
757761
self.precision,
758762
seed=child_seed(seed, 1),
763+
trainable=trainable,
759764
)
760765
self.embeddings_strip = embeddings_strip
761766
else:
@@ -774,6 +779,7 @@ def __init__(
774779
smooth=self.smooth,
775780
precision=self.precision,
776781
seed=child_seed(seed, 2),
782+
trainable=trainable,
777783
)
778784

779785
wanted_shape = (self.ntypes, self.nnei, 4)
@@ -1027,7 +1033,7 @@ def call(
10271033
xp.tile(
10281034
(xp.reshape(atype, (-1, 1)) * ntypes_with_padding), (1, nnei)
10291035
),
1030-
(-1),
1036+
(-1,),
10311037
)
10321038
idx_j = xp.reshape(nei_type, (-1,))
10331039
# (nf x nl x nnei) x ng
@@ -1186,6 +1192,7 @@ def __init__(
11861192
smooth: bool = True,
11871193
precision: str = DEFAULT_PRECISION,
11881194
seed: Optional[Union[int, list[int]]] = None,
1195+
trainable: bool = True,
11891196
) -> None:
11901197
"""Construct a neighbor-wise attention net."""
11911198
super().__init__()
@@ -1219,6 +1226,7 @@ def __init__(
12191226
smooth=smooth,
12201227
precision=precision,
12211228
seed=child_seed(seed, ii),
1229+
trainable=trainable,
12221230
)
12231231
for ii in range(layer_num)
12241232
]
@@ -1314,6 +1322,7 @@ def __init__(
13141322
smooth: bool = True,
13151323
precision: str = DEFAULT_PRECISION,
13161324
seed: Optional[Union[int, list[int]]] = None,
1325+
trainable: bool = True,
13171326
) -> None:
13181327
"""Construct a neighbor-wise attention layer."""
13191328
super().__init__()
@@ -1340,6 +1349,7 @@ def __init__(
13401349
smooth=smooth,
13411350
precision=precision,
13421351
seed=child_seed(seed, 0),
1352+
trainable=trainable,
13431353
)
13441354
self.attn_layer_norm = LayerNorm(
13451355
self.embed_dim,
@@ -1420,6 +1430,7 @@ def __init__(
14201430
smooth: bool = True,
14211431
precision: str = DEFAULT_PRECISION,
14221432
seed: Optional[Union[int, list[int]]] = None,
1433+
trainable: bool = True,
14231434
) -> None:
14241435
"""Construct a multi-head neighbor-wise attention net."""
14251436
super().__init__()
@@ -1449,6 +1460,7 @@ def __init__(
14491460
use_timestep=False,
14501461
precision=precision,
14511462
seed=child_seed(seed, 0),
1463+
trainable=trainable,
14521464
)
14531465
self.out_proj = NativeLayer(
14541466
hidden_dim,
@@ -1457,6 +1469,7 @@ def __init__(
14571469
use_timestep=False,
14581470
precision=precision,
14591471
seed=child_seed(seed, 1),
1472+
trainable=trainable,
14601473
)
14611474

14621475
def call(self, query, nei_mask, input_r=None, sw=None, attnw_shift=20.0):

deepmd/dpmodel/descriptor/dpa2.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ def init_subclass_params(sub_data, sub_class):
474474
smooth=smooth,
475475
type_one_side=self.repinit_args.type_one_side,
476476
seed=child_seed(seed, 0),
477+
trainable=trainable,
477478
)
478479
self.use_three_body = self.repinit_args.use_three_body
479480
if self.use_three_body:
@@ -493,6 +494,7 @@ def init_subclass_params(sub_data, sub_class):
493494
resnet_dt=self.repinit_args.resnet_dt,
494495
smooth=smooth,
495496
seed=child_seed(seed, 5),
497+
trainable=trainable,
496498
)
497499
else:
498500
self.repinit_three_body = None
@@ -533,6 +535,7 @@ def init_subclass_params(sub_data, sub_class):
533535
g1_out_mlp=self.repformer_args.g1_out_mlp,
534536
ln_eps=self.repformer_args.ln_eps,
535537
seed=child_seed(seed, 1),
538+
trainable=trainable,
536539
)
537540
self.rcsl_list = [
538541
(self.repformers.get_rcut(), self.repformers.get_nsel()),
@@ -562,6 +565,7 @@ def init_subclass_params(sub_data, sub_class):
562565
use_tebd_bias=use_tebd_bias,
563566
type_map=type_map,
564567
seed=child_seed(seed, 2),
568+
trainable=trainable,
565569
)
566570
self.concat_output_tebd = concat_output_tebd
567571
self.precision = precision
@@ -585,6 +589,7 @@ def init_subclass_params(sub_data, sub_class):
585589
bias=False,
586590
precision=precision,
587591
seed=child_seed(seed, 3),
592+
trainable=trainable,
588593
)
589594
self.tebd_transform = None
590595
if self.add_tebd_to_repinit_out:
@@ -594,6 +599,7 @@ def init_subclass_params(sub_data, sub_class):
594599
bias=False,
595600
precision=precision,
596601
seed=child_seed(seed, 4),
602+
trainable=trainable,
597603
)
598604
assert self.repinit.rcut > self.repformers.rcut
599605
assert self.repinit.sel[0] > self.repformers.sel[0]
@@ -841,7 +847,7 @@ def call(
841847
type_embedding = self.type_embedding.call()
842848
# repinit
843849
g1_ext = xp.reshape(
844-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
850+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
845851
(nframes, nall, self.tebd_dim),
846852
)
847853
g1_inp = g1_ext[:, :nloc, :]

deepmd/dpmodel/descriptor/dpa3.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def deserialize(cls, data: dict) -> "RepFlowArgs":
251251

252252
@BaseDescriptor.register("dpa3")
253253
class DescrptDPA3(NativeOP, BaseDescriptor):
254-
r"""The DPA-3 descriptor.
254+
r"""The DPA3 descriptor[1]_.
255255
256256
Parameters
257257
----------
@@ -282,6 +282,12 @@ class DescrptDPA3(NativeOP, BaseDescriptor):
282282
When True, local indexing and mapping are applied to neighbor lists and embeddings during descriptor computation.
283283
type_map : list[str], Optional
284284
A list of strings. Give the name to each type of atoms.
285+
286+
References
287+
----------
288+
.. [1] Zhang, D., Peng, A., Cai, C. et al. Graph neural
289+
network model for the era of large atomistic models.
290+
arXiv preprint arXiv:2506.01686 (2025).
285291
"""
286292

287293
def __init__(
@@ -351,6 +357,7 @@ def init_subclass_params(sub_data, sub_class):
351357
env_protection=env_protection,
352358
precision=precision,
353359
seed=child_seed(seed, 1),
360+
trainable=trainable,
354361
)
355362

356363
self.use_econf_tebd = use_econf_tebd
@@ -368,6 +375,7 @@ def init_subclass_params(sub_data, sub_class):
368375
use_tebd_bias=use_tebd_bias,
369376
type_map=type_map,
370377
seed=child_seed(seed, 2),
378+
trainable=trainable,
371379
)
372380
self.concat_output_tebd = concat_output_tebd
373381
self.precision = precision
@@ -556,12 +564,12 @@ def call(
556564
type_embedding = self.type_embedding.call()
557565
if self.use_loc_mapping:
558566
node_ebd_ext = xp.reshape(
559-
xp.take(type_embedding, xp.reshape(atype_ext[:, :nloc], [-1]), axis=0),
567+
xp.take(type_embedding, xp.reshape(atype_ext[:, :nloc], (-1,)), axis=0),
560568
(nframes, nloc, self.tebd_dim),
561569
)
562570
else:
563571
node_ebd_ext = xp.reshape(
564-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
572+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
565573
(nframes, nall, self.tebd_dim),
566574
)
567575
node_ebd_inp = node_ebd_ext[:, :nloc, :]

0 commit comments

Comments
 (0)