Skip to content

Commit 91aa1d6

Browse files
committed
fix consistent and bump version
1 parent 42c9724 commit 91aa1d6

8 files changed

Lines changed: 41 additions & 8 deletions

File tree

deepmd/dpmodel/descriptor/dpa3.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def serialize(self) -> dict:
575575
data = {
576576
"@class": "Descriptor",
577577
"type": "dpa3",
578-
"@version": 1,
578+
"@version": 2,
579579
"ntypes": self.ntypes,
580580
"repflow_args": self.repflow_args.serialize(),
581581
"concat_output_tebd": self.concat_output_tebd,
@@ -586,6 +586,7 @@ def serialize(self) -> dict:
586586
"trainable": self.trainable,
587587
"use_econf_tebd": self.use_econf_tebd,
588588
"use_tebd_bias": self.use_tebd_bias,
589+
"use_loc_mapping": self.use_loc_mapping,
589590
"type_map": self.type_map,
590591
"type_embedding": self.type_embedding.serialize(),
591592
}
@@ -610,7 +611,7 @@ def serialize(self) -> dict:
610611
def deserialize(cls, data: dict) -> "DescrptDPA3":
611612
data = data.copy()
612613
version = data.pop("@version")
613-
check_version_compatibility(version, 1, 1)
614+
check_version_compatibility(version, 2, 1)
614615
data.pop("@class")
615616
data.pop("type")
616617
repflow_variable = data.pop("repflow_variable").copy()

deepmd/dpmodel/descriptor/repflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ def serialize(self):
688688
"smooth_edge_update": self.smooth_edge_update,
689689
"use_dynamic_sel": self.use_dynamic_sel,
690690
"sel_reduce_factor": self.sel_reduce_factor,
691+
"use_loc_mapping": self.use_loc_mapping,
691692
# variables
692693
"edge_embd": self.edge_embd.serialize(),
693694
"angle_embd": self.angle_embd.serialize(),

deepmd/pd/model/descriptor/dpa3.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ class DescrptDPA3(BaseDescriptor, paddle.nn.Layer):
8989
Whether to use electronic configuration type embedding.
9090
use_tebd_bias : bool, Optional
9191
Whether to use bias in the type embedding layer.
92+
use_loc_mapping : bool, Optional
93+
Whether to use local atom index mapping in training or non-parallel inference.
94+
Not supported yet in Paddle.
9295
type_map : list[str], Optional
9396
A list of strings. Give the name to each type of atoms.
9497
"""
@@ -108,6 +111,7 @@ def __init__(
108111
seed: Optional[Union[int, list[int]]] = None,
109112
use_econf_tebd: bool = False,
110113
use_tebd_bias: bool = False,
114+
use_loc_mapping: bool = False,
111115
type_map: Optional[list[str]] = None,
112116
) -> None:
113117
super().__init__()
@@ -152,6 +156,7 @@ def init_subclass_params(sub_data, sub_class):
152156
smooth_edge_update=self.repflow_args.smooth_edge_update,
153157
use_dynamic_sel=self.repflow_args.use_dynamic_sel,
154158
sel_reduce_factor=self.repflow_args.sel_reduce_factor,
159+
use_loc_mapping=use_loc_mapping,
155160
exclude_types=exclude_types,
156161
env_protection=env_protection,
157162
precision=precision,
@@ -160,6 +165,7 @@ def init_subclass_params(sub_data, sub_class):
160165

161166
self.use_econf_tebd = use_econf_tebd
162167
self.use_tebd_bias = use_tebd_bias
168+
self.use_loc_mapping = use_loc_mapping
163169
self.type_map = type_map
164170
self.tebd_dim = self.repflow_args.n_dim
165171
self.type_embedding = TypeEmbedNet(
@@ -370,7 +376,7 @@ def serialize(self) -> dict:
370376
data = {
371377
"@class": "Descriptor",
372378
"type": "dpa3",
373-
"@version": 1,
379+
"@version": 2,
374380
"ntypes": self.ntypes,
375381
"repflow_args": self.repflow_args.serialize(),
376382
"concat_output_tebd": self.concat_output_tebd,
@@ -381,6 +387,7 @@ def serialize(self) -> dict:
381387
"trainable": self.trainable,
382388
"use_econf_tebd": self.use_econf_tebd,
383389
"use_tebd_bias": self.use_tebd_bias,
390+
"use_loc_mapping": self.use_loc_mapping,
384391
"type_map": self.type_map,
385392
"type_embedding": self.type_embedding.embedding.serialize(),
386393
}
@@ -405,7 +412,7 @@ def serialize(self) -> dict:
405412
def deserialize(cls, data: dict) -> "DescrptDPA3":
406413
data = data.copy()
407414
version = data.pop("@version")
408-
check_version_compatibility(version, 1, 1)
415+
check_version_compatibility(version, 2, 1)
409416
data.pop("@class")
410417
data.pop("type")
411418
repflow_variable = data.pop("repflow_variable").copy()

deepmd/pd/model/descriptor/repflows.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ class DescrptBlockRepflows(DescriptorBlock):
112112
optim_update : bool, optional
113113
Whether to enable the optimized update method.
114114
Uses a more efficient process when enabled. Defaults to True
115+
use_loc_mapping : bool, Optional
116+
Whether to use local atom index mapping in training or non-parallel inference.
117+
Not supported yet in Paddle.
115118
ntypes : int
116119
Number of element types
117120
activation_function : str, optional
@@ -161,6 +164,7 @@ def __init__(
161164
smooth_edge_update: bool = False,
162165
use_dynamic_sel: bool = False,
163166
sel_reduce_factor: float = 10.0,
167+
use_loc_mapping: bool = False,
164168
optim_update: bool = True,
165169
seed: Optional[Union[int, list[int]]] = None,
166170
) -> None:
@@ -196,6 +200,8 @@ def __init__(
196200
self.use_dynamic_sel = use_dynamic_sel # not supported yet
197201
self.sel_reduce_factor = sel_reduce_factor
198202
assert not self.use_dynamic_sel, "Dynamic selection is not supported yet."
203+
self.use_loc_mapping = use_loc_mapping
204+
assert not self.use_loc_mapping, "Local mapping is not supported yet."
199205

200206
self.n_dim = n_dim
201207
self.e_dim = e_dim

deepmd/pt/model/descriptor/dpa3.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def serialize(self) -> dict:
371371
data = {
372372
"@class": "Descriptor",
373373
"type": "dpa3",
374-
"@version": 1,
374+
"@version": 2,
375375
"ntypes": self.ntypes,
376376
"repflow_args": self.repflow_args.serialize(),
377377
"concat_output_tebd": self.concat_output_tebd,
@@ -382,6 +382,7 @@ def serialize(self) -> dict:
382382
"trainable": self.trainable,
383383
"use_econf_tebd": self.use_econf_tebd,
384384
"use_tebd_bias": self.use_tebd_bias,
385+
"use_loc_mapping": self.use_loc_mapping,
385386
"type_map": self.type_map,
386387
"type_embedding": self.type_embedding.embedding.serialize(),
387388
}
@@ -406,7 +407,7 @@ def serialize(self) -> dict:
406407
def deserialize(cls, data: dict) -> "DescrptDPA3":
407408
data = data.copy()
408409
version = data.pop("@version")
409-
check_version_compatibility(version, 1, 1)
410+
check_version_compatibility(version, 2, 1)
410411
data.pop("@class")
411412
data.pop("type")
412413
repflow_variable = data.pop("repflow_variable").copy()

deepmd/pt/model/descriptor/repflows.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class DescrptBlockRepflows(DescriptorBlock):
156156
In the dynamic selection case, neighbor-scale normalization will use `e_sel / sel_reduce_factor`
157157
or `a_sel / sel_reduce_factor` instead of the raw `e_sel` or `a_sel` values,
158158
accommodating larger selection numbers.
159+
use_loc_mapping : bool, Optional
160+
Whether to use local atom index mapping in training or non-parallel inference.
161+
When True, local indexing and mapping are applied to neighbor lists and embeddings during descriptor computation.
159162
optim_update : bool, optional
160163
Whether to enable the optimized update method.
161164
Uses a more efficient process when enabled. Defaults to True

deepmd/utils/argcheck.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,10 @@ def descrpt_dpa3_args():
13721372
doc_seed = "Random seed for parameter initialization."
13731373
doc_use_econf_tebd = "Whether to use electronic configuration type embedding."
13741374
doc_use_tebd_bias = "Whether to use bias in the type embedding layer."
1375+
doc_use_loc_mapping = (
1376+
"Whether to use local atom index mapping in training or non-parallel inference. "
1377+
"When True, local indexing and mapping are applied to neighbor lists and embeddings during descriptor computation."
1378+
)
13751379
return [
13761380
# doc_repflow args
13771381
Argument("repflow", dict, dpa3_repflow_args(), doc=doc_repflow),
@@ -1426,8 +1430,7 @@ def descrpt_dpa3_args():
14261430
bool,
14271431
optional=True,
14281432
default=True,
1429-
doc="Whether to use local atom index mapping in training or non-parallel inference. "
1430-
"When True, local indexing and mapping are applied to neighbor lists and embeddings during descriptor computation.",
1433+
doc=doc_use_loc_mapping,
14311434
),
14321435
]
14331436

source/tests/consistent/descriptor/test_dpa3.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
(True, False), # optim_update
6868
(True, False), # use_exp_switch
6969
(True, False), # use_dynamic_sel
70+
(True, False), # use_loc_mapping
7071
(0.3, 0.0), # fix_stat_std
7172
(1, 2), # n_multi_edge_message
7273
("float64",), # precision
@@ -84,6 +85,7 @@ def data(self) -> dict:
8485
optim_update,
8586
use_exp_switch,
8687
use_dynamic_sel,
88+
use_loc_mapping,
8789
fix_stat_std,
8890
n_multi_edge_message,
8991
precision,
@@ -124,6 +126,7 @@ def data(self) -> dict:
124126
"precision": precision,
125127
"exclude_types": exclude_types,
126128
"env_protection": 0.0,
129+
"use_loc_mapping": use_loc_mapping,
127130
"trainable": True,
128131
}
129132

@@ -139,6 +142,7 @@ def skip_pt(self) -> bool:
139142
optim_update,
140143
use_exp_switch,
141144
use_dynamic_sel,
145+
use_loc_mapping,
142146
fix_stat_std,
143147
n_multi_edge_message,
144148
precision,
@@ -157,6 +161,7 @@ def skip_pd(self) -> bool:
157161
optim_update,
158162
use_exp_switch,
159163
use_dynamic_sel,
164+
use_loc_mapping,
160165
fix_stat_std,
161166
n_multi_edge_message,
162167
precision,
@@ -166,6 +171,7 @@ def skip_pd(self) -> bool:
166171
or precision == "bfloat16"
167172
or use_exp_switch
168173
or use_dynamic_sel
174+
or use_loc_mapping
169175
) # not supported yet
170176

171177
@property
@@ -180,6 +186,7 @@ def skip_dp(self) -> bool:
180186
optim_update,
181187
use_exp_switch,
182188
use_dynamic_sel,
189+
use_loc_mapping,
183190
fix_stat_std,
184191
n_multi_edge_message,
185192
precision,
@@ -198,6 +205,7 @@ def skip_tf(self) -> bool:
198205
optim_update,
199206
use_exp_switch,
200207
use_dynamic_sel,
208+
use_loc_mapping,
201209
fix_stat_std,
202210
n_multi_edge_message,
203211
precision,
@@ -258,6 +266,7 @@ def setUp(self) -> None:
258266
optim_update,
259267
use_exp_switch,
260268
use_dynamic_sel,
269+
use_loc_mapping,
261270
fix_stat_std,
262271
n_multi_edge_message,
263272
precision,
@@ -339,6 +348,7 @@ def rtol(self) -> float:
339348
optim_update,
340349
use_exp_switch,
341350
use_dynamic_sel,
351+
use_loc_mapping,
342352
fix_stat_std,
343353
n_multi_edge_message,
344354
precision,
@@ -363,6 +373,7 @@ def atol(self) -> float:
363373
optim_update,
364374
use_exp_switch,
365375
use_dynamic_sel,
376+
use_loc_mapping,
366377
fix_stat_std,
367378
n_multi_edge_message,
368379
precision,

0 commit comments

Comments
 (0)