Skip to content

Commit 96334fb

Browse files
authored
Merge branch 'devel' into fix-train-time
2 parents 15ea1c0 + a3677b6 commit 96334fb

36 files changed

Lines changed: 380 additions & 133 deletions

.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

.pre-commit-config.yaml

Lines changed: 2 additions & 2 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.11.13
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]
@@ -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.6
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 and DPA-3 models.
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/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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def call(
520520
type_embedding = self.type_embedding.call()
521521
# nf x nall x tebd_dim
522522
atype_embd_ext = xp.reshape(
523-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
523+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
524524
(nf, nall, self.tebd_dim),
525525
)
526526
# nfnl x tebd_dim
@@ -1027,7 +1027,7 @@ def call(
10271027
xp.tile(
10281028
(xp.reshape(atype, (-1, 1)) * ntypes_with_padding), (1, nnei)
10291029
),
1030-
(-1),
1030+
(-1,),
10311031
)
10321032
idx_j = xp.reshape(nei_type, (-1,))
10331033
# (nf x nl x nnei) x ng

deepmd/dpmodel/descriptor/dpa2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def call(
841841
type_embedding = self.type_embedding.call()
842842
# repinit
843843
g1_ext = xp.reshape(
844-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
844+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
845845
(nframes, nall, self.tebd_dim),
846846
)
847847
g1_inp = g1_ext[:, :nloc, :]

deepmd/dpmodel/descriptor/dpa3.py

Lines changed: 3 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[1]_.
254+
r"""The DPA3 descriptor[1]_.
255255
256256
Parameters
257257
----------
@@ -562,12 +562,12 @@ def call(
562562
type_embedding = self.type_embedding.call()
563563
if self.use_loc_mapping:
564564
node_ebd_ext = xp.reshape(
565-
xp.take(type_embedding, xp.reshape(atype_ext[:, :nloc], [-1]), axis=0),
565+
xp.take(type_embedding, xp.reshape(atype_ext[:, :nloc], (-1,)), axis=0),
566566
(nframes, nloc, self.tebd_dim),
567567
)
568568
else:
569569
node_ebd_ext = xp.reshape(
570-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
570+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
571571
(nframes, nall, self.tebd_dim),
572572
)
573573
node_ebd_inp = node_ebd_ext[:, :nloc, :]

deepmd/dpmodel/descriptor/repflows.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def call(
526526
# edge_input, h2 = xp.split(dmatrix, [1], axis=-1)
527527
# nb x nloc x nnei x 1
528528
if self.edge_init_use_dist:
529-
edge_input = xp.linalg.vector_norm(diff, axis=-1, keepdims=True)
529+
edge_input = safe_for_vector_norm(diff, axis=-1, keepdims=True)
530530
else:
531531
edge_input = dmatrix[:, :, :, :1]
532532
h2 = dmatrix[:, :, :, 1:]
@@ -578,7 +578,8 @@ def call(
578578
# n_angle x 1
579579
a_sw = (a_sw[:, :, :, None] * a_sw[:, :, None, :])[a_nlist_mask]
580580
else:
581-
edge_index = angle_index = xp.zeros([1, 3], dtype=nlist.dtype)
581+
edge_index = xp.zeros([2, 1], dtype=nlist.dtype)
582+
angle_index = xp.zeros([3, 1], dtype=nlist.dtype)
582583

583584
# get edge and angle embedding
584585
# nb x nloc x nnei x e_dim [OR] n_edge x e_dim
@@ -622,7 +623,7 @@ def call(
622623
edge_ebd,
623624
h2,
624625
sw,
625-
owner=edge_index[:, 0],
626+
owner=edge_index[0, :],
626627
num_owner=nframes * nloc,
627628
nb=nframes,
628629
nloc=nloc,
@@ -1286,8 +1287,8 @@ def call(
12861287
a_nlist: np.ndarray, # nf x nloc x a_nnei
12871288
a_nlist_mask: np.ndarray, # nf x nloc x a_nnei
12881289
a_sw: np.ndarray, # switch func, nf x nloc x a_nnei
1289-
edge_index: np.ndarray, # n_edge x 2
1290-
angle_index: np.ndarray, # n_angle x 3
1290+
edge_index: np.ndarray, # 2 x n_edge
1291+
angle_index: np.ndarray, # 3 x n_angle
12911292
):
12921293
"""
12931294
Parameters
@@ -1312,12 +1313,12 @@ def call(
13121313
Masks of the neighbor list for angle. real nei 1 otherwise 0
13131314
a_sw : nf x nloc x a_nnei
13141315
Switch function for angle.
1315-
edge_index : Optional for dynamic sel, n_edge x 2
1316+
edge_index : Optional for dynamic sel, 2 x n_edge
13161317
n2e_index : n_edge
13171318
Broadcast indices from node(i) to edge(ij), or reduction indices from edge(ij) to node(i).
13181319
n_ext2e_index : n_edge
13191320
Broadcast indices from extended node(j) to edge(ij).
1320-
angle_index : Optional for dynamic sel, n_angle x 3
1321+
angle_index : Optional for dynamic sel, 3 x n_angle
13211322
n2a_index : n_angle
13221323
Broadcast indices from extended node(j) to angle(ijk).
13231324
eij2a_index : n_angle
@@ -1362,11 +1363,11 @@ def call(
13621363
assert (n_edge, 3) == h2.shape
13631364
del a_nlist # may be used in the future
13641365

1365-
n2e_index, n_ext2e_index = edge_index[:, 0], edge_index[:, 1]
1366+
n2e_index, n_ext2e_index = edge_index[0, :], edge_index[1, :]
13661367
n2a_index, eij2a_index, eik2a_index = (
1367-
angle_index[:, 0],
1368-
angle_index[:, 1],
1369-
angle_index[:, 2],
1368+
angle_index[0, :],
1369+
angle_index[1, :],
1370+
angle_index[2, :],
13701371
)
13711372

13721373
# nb x nloc x nnei x n_dim [OR] n_edge x n_dim

deepmd/dpmodel/descriptor/se_t_tebd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def call(
358358
type_embedding = self.type_embedding.call()
359359
# nf x nall x tebd_dim
360360
atype_embd_ext = xp.reshape(
361-
xp.take(type_embedding, xp.reshape(atype_ext, [-1]), axis=0),
361+
xp.take(type_embedding, xp.reshape(atype_ext, (-1,)), axis=0),
362362
(nf, nall, self.tebd_dim),
363363
)
364364
# nfnl x tebd_dim

deepmd/dpmodel/fitting/general_fitting.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def _call_common(
412412
)
413413
fparam = (fparam - self.fparam_avg[...]) * self.fparam_inv_std[...]
414414
fparam = xp.tile(
415-
xp.reshape(fparam, [nf, 1, self.numb_fparam]), (1, nloc, 1)
415+
xp.reshape(fparam, (nf, 1, self.numb_fparam)), (1, nloc, 1)
416416
)
417417
xx = xp.concat(
418418
[xx, fparam],
@@ -431,7 +431,7 @@ def _call_common(
431431
f"get an input aparam of dim {aparam.shape[-1]}, "
432432
f"which is not consistent with {self.numb_aparam}."
433433
)
434-
aparam = xp.reshape(aparam, [nf, nloc, self.numb_aparam])
434+
aparam = xp.reshape(aparam, (nf, nloc, self.numb_aparam))
435435
aparam = (aparam - self.aparam_avg[...]) * self.aparam_inv_std[...]
436436
xx = xp.concat(
437437
[xx, aparam],
@@ -446,7 +446,7 @@ def _call_common(
446446
if self.dim_case_embd > 0:
447447
assert self.case_embd is not None
448448
case_embd = xp.tile(
449-
xp.reshape(self.case_embd[...], [1, 1, -1]), [nf, nloc, 1]
449+
xp.reshape(self.case_embd[...], (1, 1, -1)), (nf, nloc, 1)
450450
)
451451
xx = xp.concat(
452452
[xx, case_embd],
@@ -465,7 +465,7 @@ def _call_common(
465465
)
466466
for type_i in range(self.ntypes):
467467
mask = xp.tile(
468-
xp.reshape((atype == type_i), [nf, nloc, 1]), (1, 1, net_dim_out)
468+
xp.reshape((atype == type_i), (nf, nloc, 1)), (1, 1, net_dim_out)
469469
)
470470
atom_property = self.nets[(type_i,)](xx)
471471
if self.remove_vaccum_contribution is not None and not (
@@ -485,10 +485,10 @@ def _call_common(
485485
outs += xp.reshape(
486486
xp.take(
487487
xp.astype(self.bias_atom_e[...], outs.dtype),
488-
xp.reshape(atype, [-1]),
488+
xp.reshape(atype, (-1,)),
489489
axis=0,
490490
),
491-
[nf, nloc, net_dim_out],
491+
(nf, nloc, net_dim_out),
492492
)
493493
# nf x nloc
494494
exclude_mask = self.emask.build_type_exclude_mask(atype)

0 commit comments

Comments
 (0)