Skip to content

Commit

Permalink
fix: DPA1 should use masked gate when excluded_types (#3815)
Browse files Browse the repository at this point in the history
Fix #3707.
  • Loading branch information
iProzd authored May 24, 2024
1 parent 0e67a7e commit 8cd3cba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions deepmd/dpmodel/descriptor/dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,8 @@ def call(
else:
raise NotImplementedError

input_r = dmatrix.reshape(-1, nnei, 4)[:, :, 1:4] / np.maximum(
np.linalg.norm(
dmatrix.reshape(-1, nnei, 4)[:, :, 1:4], axis=-1, keepdims=True
),
input_r = rr.reshape(-1, nnei, 4)[:, :, 1:4] / np.maximum(
np.linalg.norm(rr.reshape(-1, nnei, 4)[:, :, 1:4], axis=-1, keepdims=True),
1e-12,
)
gg = self.dpa1_attention(
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/descriptor/se_atten.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def forward(
raise NotImplementedError

input_r = torch.nn.functional.normalize(
dmatrix.reshape(-1, self.nnei, 4)[:, :, 1:4], dim=-1
rr.reshape(-1, self.nnei, 4)[:, :, 1:4], dim=-1
)
gg = self.dpa1_attention(
gg, nlist_mask, input_r=input_r, sw=sw
Expand Down
2 changes: 0 additions & 2 deletions source/tests/consistent/descriptor/test_dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,13 @@ def skip_tf(self) -> bool:
precision,
use_econf_tebd,
) = self.param
# TODO (excluded_types != [] and attn_layer > 0) need fix
return (
CommonTest.skip_tf
or (
env_protection != 0.0
or smooth_type_embedding
or not normalize
or temperature != 1.0
or (excluded_types != [] and attn_layer > 0)
or (type_one_side and tebd_input_mode == "strip") # not consistent yet
)
or self.is_meaningless_zero_attention_layer_tests(
Expand Down

0 comments on commit 8cd3cba

Please sign in to comment.