Skip to content

Commit 38fc569

Browse files
Merge branch '3831' of github.com:Chengqian-Zhang/deepmd-kit into 3831
2 parents c3892f4 + c982d0e commit 38fc569

23 files changed

Lines changed: 544 additions & 18 deletions

File tree

.github/workflows/test_cuda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ jobs:
3434
uses: mpi4py/setup-mpi@v1
3535
with:
3636
mpi: mpich
37+
- name: Install wget and unzip
38+
run: apt-get update && apt-get install -y wget unzip
3739
- uses: lukka/get-cmake@latest
3840
with:
3941
useLocalCache: true
4042
useCloudCache: false
41-
- name: Install wget and unzip
42-
run: apt-get update && apt-get install -y wget unzip
4343
- run: |
4444
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
4545
&& sudo dpkg -i cuda-keyring_1.0-1_all.deb \

deepmd/dpmodel/descriptor/dpa1.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,10 @@ def call(
804804
nf, nloc, nnei, _ = dmatrix.shape
805805
exclude_mask = self.emask.build_type_exclude_mask(nlist, atype_ext)
806806
# nfnl x nnei
807+
exclude_mask = exclude_mask.reshape(nf * nloc, nnei)
808+
# nfnl x nnei
807809
nlist = nlist.reshape(nf * nloc, nnei)
810+
nlist = np.where(exclude_mask, nlist, -1)
808811
# nfnl x nnei x 4
809812
dmatrix = dmatrix.reshape(nf * nloc, nnei, 4)
810813
# nfnl x nnei x 1
@@ -824,8 +827,6 @@ def call(
824827
nf * nloc, nnei, self.tebd_dim
825828
)
826829
ng = self.neuron[-1]
827-
# nfnl x nnei
828-
exclude_mask = exclude_mask.reshape(nf * nloc, nnei)
829830
# nfnl x nnei x 4
830831
rr = dmatrix.reshape(nf * nloc, nnei, 4)
831832
rr = rr * exclude_mask[:, :, None]

deepmd/dpmodel/descriptor/repformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def call(
338338
mapping: Optional[np.ndarray] = None,
339339
):
340340
exclude_mask = self.emask.build_type_exclude_mask(nlist, atype_ext)
341-
nlist = nlist * exclude_mask
341+
nlist = np.where(exclude_mask, nlist, -1)
342342
# nf x nloc x nnei x 4
343343
dmatrix, diff, sw = self.env_mat.call(
344344
coord_ext, atype_ext, nlist, self.mean, self.stddev

deepmd/dpmodel/descriptor/se_e2_a.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class DescrptSeA(NativeOP, BaseDescriptor):
117117
The precision of the embedding net parameters. Supported options are |PRECISION|
118118
spin
119119
The deepspin object.
120+
ntypes : int
121+
Number of element types.
122+
Not used in this descriptor, only to be compat with input.
120123
121124
Limitations
122125
-----------
@@ -150,9 +153,11 @@ def __init__(
150153
activation_function: str = "tanh",
151154
precision: str = DEFAULT_PRECISION,
152155
spin: Optional[Any] = None,
156+
ntypes: Optional[int] = None, # to be compat with input
153157
# consistent with argcheck, not used though
154158
seed: Optional[int] = None,
155159
) -> None:
160+
del ntypes
156161
## seed, uniform_seed, not included.
157162
if spin is not None:
158163
raise NotImplementedError("spin is not implemented")

deepmd/dpmodel/descriptor/se_r.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class DescrptSeR(NativeOP, BaseDescriptor):
7575
The precision of the embedding net parameters. Supported options are |PRECISION|
7676
spin
7777
The deepspin object.
78+
ntypes : int
79+
Number of element types.
80+
Not used in this descriptor, only to be compat with input.
7881
7982
Limitations
8083
-----------
@@ -107,9 +110,11 @@ def __init__(
107110
activation_function: str = "tanh",
108111
precision: str = DEFAULT_PRECISION,
109112
spin: Optional[Any] = None,
113+
ntypes: Optional[int] = None, # to be compat with input
110114
# consistent with argcheck, not used though
111115
seed: Optional[int] = None,
112116
) -> None:
117+
del ntypes
113118
## seed, uniform_seed, not included.
114119
if not type_one_side:
115120
raise NotImplementedError("type_one_side == False not implemented")

deepmd/dpmodel/descriptor/se_t.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class DescrptSeT(NativeOP, BaseDescriptor):
7878
If the weights of embedding net are trainable.
7979
seed : int, Optional
8080
Random seed for initializing the network parameters.
81+
ntypes : int
82+
Number of element types.
83+
Not used in this descriptor, only to be compat with input.
8184
"""
8285

8386
def __init__(
@@ -94,7 +97,9 @@ def __init__(
9497
precision: str = DEFAULT_PRECISION,
9598
trainable: bool = True,
9699
seed: Optional[int] = None,
100+
ntypes: Optional[int] = None, # to be compat with input
97101
) -> None:
102+
del ntypes
98103
self.rcut = rcut
99104
self.rcut_smth = rcut_smth
100105
self.sel = sel

deepmd/entrypoints/doc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from deepmd.utils.argcheck import (
55
gen_doc,
66
gen_json,
7+
gen_json_schema,
78
)
89

910
__all__ = ["doc_train_input"]
@@ -15,6 +16,8 @@ def doc_train_input(*, out_type: str = "rst", **kwargs):
1516
doc_str = gen_doc(make_anchor=True)
1617
elif out_type == "json":
1718
doc_str = gen_json()
19+
elif out_type == "json_schema":
20+
doc_str = gen_json_schema()
1821
else:
1922
raise RuntimeError(f"Unsupported out type {out_type}")
2023
print(doc_str) # noqa: T201

deepmd/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def main_parser() -> argparse.ArgumentParser:
500500
parsers_doc.add_argument(
501501
"--out-type",
502502
default="rst",
503-
choices=["rst", "json"],
503+
choices=["rst", "json", "json_schema"],
504504
type=str,
505505
help="The output type",
506506
)

deepmd/pt/model/descriptor/repformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def forward(
410410
atype = extended_atype[:, :nloc]
411411
# nb x nloc x nnei
412412
exclude_mask = self.emask(nlist, extended_atype)
413-
nlist = nlist * exclude_mask
413+
nlist = torch.where(exclude_mask != 0, nlist, -1)
414414
# nb x nloc x nnei x 4, nb x nloc x nnei x 3, nb x nloc x nnei x 1
415415
dmatrix, diff, sw = prod_env_mat(
416416
extended_coord,

deepmd/pt/model/descriptor/se_atten.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,12 @@ def forward(
478478
self.rcut_smth,
479479
protection=self.env_protection,
480480
)
481+
# nb x nloc x nnei
482+
exclude_mask = self.emask(nlist, extended_atype)
483+
nlist = torch.where(exclude_mask != 0, nlist, -1)
481484
nlist_mask = nlist != -1
482485
nlist = torch.where(nlist == -1, 0, nlist)
483486
sw = torch.squeeze(sw, -1)
484-
# beyond the cutoff sw should be 0.0
485-
sw = sw.masked_fill(~nlist_mask, 0.0)
486487
# nf x nloc x nt -> nf x nloc x nnei x nt
487488
atype_tebd = extended_atype_embd[:, :nloc, :]
488489
atype_tebd_nnei = atype_tebd.unsqueeze(2).expand(-1, -1, self.nnei, -1)
@@ -495,8 +496,10 @@ def forward(
495496
atype_tebd_nlist = torch.gather(atype_tebd_ext, dim=1, index=index)
496497
# nb x nloc x nnei x nt
497498
atype_tebd_nlist = atype_tebd_nlist.view(nb, nloc, nnei, nt)
499+
# beyond the cutoff sw should be 0.0
500+
sw = sw.masked_fill(~nlist_mask, 0.0)
498501
# (nb x nloc) x nnei
499-
exclude_mask = self.emask(nlist, extended_atype).view(nb * nloc, nnei)
502+
exclude_mask = exclude_mask.view(nb * nloc, nnei)
500503
if self.old_impl:
501504
assert self.filter_layers_old is not None
502505
dmatrix = dmatrix.view(

0 commit comments

Comments
 (0)