Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvnmd-v1 with 31-type chemical species #2676

Merged
merged 59 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
182c6d5
nvnmd
May 13, 2022
31a1599
nvnmd
May 13, 2022
e6a977e
nvnmd
May 13, 2022
ea9c486
nvnmd
May 14, 2022
458baf2
nvnmd
May 14, 2022
fc027b2
nvnmd
May 15, 2022
67ced71
nvnmd
LiuGroupHNU May 16, 2022
939afdc
nvnmd
LiuGroupHNU May 17, 2022
4d49a4a
nvnmd
LiuGroupHNU May 17, 2022
a7b20c2
nvnmd
LiuGroupHNU May 17, 2022
1b653b9
nvnmd
LiuGroupHNU May 18, 2022
7e666d3
nvnmd
LiuGroupHNU May 18, 2022
b56df0e
Merge remote-tracking branch 'upstream/devel' into devel
LiuGroupHNU May 18, 2022
336f48d
Merge remote-tracking branch 'upstream/devel' into devel
LiuGroupHNU May 18, 2022
f648669
nvnmd
LiuGroupHNU May 18, 2022
f3c3afb
Merge remote-tracking branch 'upstream/devel' into devel
MoPinghui Jun 13, 2022
c186324
nvnmd
MoPinghui Jun 13, 2022
1abc02a
nvnmd
MoPinghui Jun 14, 2022
65fbec8
nvnmd
MoPinghui Jun 17, 2022
79a0454
nvnmd
MoPinghui Jun 20, 2022
e1f7e8a
nvnmd
MoPinghui Jun 22, 2022
cdd3be7
nvnmd
MoPinghui Jun 25, 2022
019c325
Merge branch 'devel' into devel
wanghan-iapcm Jun 27, 2022
13104e8
fix bug in elementary substance sample of compound system, add type_m…
MoPinghui Sep 7, 2022
401c78c
merge 019c325
MoPinghui Sep 7, 2022
648ce78
nvnmd
MoPinghui Sep 7, 2022
ed793ca
nvnmd
MoPinghui Sep 7, 2022
36db74f
nvnmd with floating point number
MoPinghui Dec 19, 2022
8a0380a
nvnmd with floating point number
MoPinghui Dec 20, 2022
f557783
nvnmd with floating point number
MoPinghui Dec 20, 2022
bb39348
nvnmd with floating point number
MoPinghui Jan 2, 2023
8e64871
Merge remote-tracking branch 'upstream/devel' into devel
MoPinghui Jan 3, 2023
8e02711
nvnmd with floating point number
MoPinghui Jan 4, 2023
d7361cb
nvnmd with floating point number
MoPinghui Jan 7, 2023
322b668
nvnmd with floating point number
MoPinghui Jan 9, 2023
215d2ab
nvnmd with floating point number
MoPinghui Jan 9, 2023
e2bb683
nvnmd with floating point number
MoPinghui Jan 9, 2023
c5fddf3
nvnmd with floating point number
MoPinghui Jan 9, 2023
b6d25d6
nvnmd with floating point number
MoPinghui Jan 24, 2023
c3b800a
nvnmd with floating point number
MoPinghui Feb 2, 2023
d623d94
nvnmd with floating point number
MoPinghui Feb 2, 2023
f6f70d7
nvnmd merge upstream/devel
MoPinghui Mar 26, 2023
d4d5930
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
8f85beb
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
fdd9e79
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
d5e533f
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
dbcd92d
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
12895f5
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
d23c5dd
nvnmd: fix some warning about matmul_flt_nvnmd
MoPinghui Mar 27, 2023
6aa8dfb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 28, 2023
ad89adc
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
MoPinghui Jun 28, 2023
750a538
nvnmd v0 with float and 4 types, nvnmd v1 with float and 31 types
MoPinghui Jul 7, 2023
76f75d8
change unit test for nvnmd v1
MoPinghui Jul 7, 2023
3fb6af1
fix error for map_flt_nvnmd
MoPinghui Jul 14, 2023
84e0deb
nvnmd, fix conflicts
MoPinghui Jul 19, 2023
191c72d
nvnmd
MoPinghui Jul 19, 2023
8e2c4e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 19, 2023
14d1fc1
nvnmd
MoPinghui Jul 20, 2023
95e79a2
Merge branch 'devel' of https://github.com/LiuGroupHNU/deepmd-kit int…
MoPinghui Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 38 additions & 5 deletions deepmd/descriptor/se_atten.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
op_module,
tf,
)
from deepmd.nvnmd.descriptor.se_atten import (
build_davg_dstd,
build_op_descriptor,
check_switch_range,
descrpt2r4,
filter_GR2D,
filter_lower_R42GR,
)
from deepmd.nvnmd.utils.config import (
nvnmd_cfg,
)
from deepmd.utils.graph import (
get_attention_layer_variables_from_graph_def,
get_pattern_nodes_from_graph_def,
Expand Down Expand Up @@ -149,9 +160,10 @@ def __init__(
"""
Constructor
"""
assert Version(TF_VERSION) > Version(
"2"
), "se_atten only support tensorflow version 2.0 or higher."
if not (nvnmd_cfg.enable and (nvnmd_cfg.version == 1)):
assert Version(TF_VERSION) > Version(
"2"
), "se_atten only support tensorflow version 2.0 or higher."
self.stripped_type_embedding = stripped_type_embedding
self.ntypes = ntypes
self.att_n = attn
Expand Down Expand Up @@ -524,6 +536,11 @@ def build(
"""
davg = self.davg
dstd = self.dstd
if nvnmd_cfg.enable:
nvnmd_cfg.set_ntype(self.ntypes)
if nvnmd_cfg.restore_descriptor:
davg, dstd = build_davg_dstd()
check_switch_range(davg, dstd)
with tf.variable_scope("descrpt_attr" + suffix, reuse=reuse):
if davg is None:
davg = np.zeros([self.ntypes, self.ndescrpt])
Expand Down Expand Up @@ -565,14 +582,17 @@ def build(
self.angular_weight = [None for i in range(self.attn_layer)]
self.attn_weight_final = [None for i in range(self.attn_layer)]

op_descriptor = (
build_op_descriptor() if nvnmd_cfg.enable else op_module.prod_env_mat_a_mix
)
(
self.descrpt,
self.descrpt_deriv,
self.rij,
self.nlist,
self.nei_type_vec,
self.nmask,
) = op_module.prod_env_mat_a_mix(
) = op_descriptor(
coord,
atype,
natoms,
Expand Down Expand Up @@ -644,7 +664,8 @@ def _pass_filter(
self.nei_type_vec, # extra input for atten
)
inputs_i *= mask

if nvnmd_cfg.enable and nvnmd_cfg.quantize_descriptor:
inputs_i = descrpt2r4(inputs_i, atype)
layer, qmat = self._filter(
inputs_i,
type_i,
Expand Down Expand Up @@ -1035,6 +1056,16 @@ def _filter_lower(
log.info(
"use the non-compressible model with stripped type embedding"
)
if nvnmd_cfg.enable:
if nvnmd_cfg.quantize_descriptor:
return filter_lower_R42GR(
inputs_i,
atype,
self.nei_type_vec,
)
elif nvnmd_cfg.restore_descriptor:
self.embedding_net_variables = nvnmd_cfg.get_dp_init_weights()
self.two_side_embeeding_net_variables = nvnmd_cfg.get_dp_init_weights()
if not self.compress:
xyz_scatter = embedding_net(
xyz_scatter,
Expand Down Expand Up @@ -1200,6 +1231,8 @@ def _filter(
reuse=reuse,
atype=atype,
)
if nvnmd_cfg.enable:
return filter_GR2D(xyz_scatter_1)
# natom x nei x outputs_size
# xyz_scatter = tf.concat(xyz_scatter_total, axis=1)
# natom x nei x 4
Expand Down
5 changes: 5 additions & 0 deletions deepmd/entrypoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ def main_parser() -> argparse.ArgumentParser:
choices=["s1", "s2"],
help="steps to train model of NVNMD: s1 (train CNN), s2 (train QNN)",
)
parser_train_nvnmd.add_argument(
"--skip-neighbor-stat",
action="store_true",
help="Skip calculating neighbor statistics. Sel checking, automatic sel, and model compression will be disabled.",
njzjz marked this conversation as resolved.
Show resolved Hide resolved
)
return parser


Expand Down
3 changes: 2 additions & 1 deletion deepmd/fit/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ def build(
)
atype_filter = tf.cast(self.atype_nloc >= 0, GLOBAL_TF_FLOAT_PRECISION)
self.atype_nloc = tf.reshape(self.atype_nloc, [-1])

if nvnmd_cfg.enable and nvnmd_cfg.quantize_descriptor and nvnmd_cfg.restore_descriptor and (nvnmd_cfg.version == 1):
type_embedding = nvnmd_cfg.map["t_ebd"]
if type_embedding is not None:
atype_embed = tf.nn.embedding_lookup(type_embedding, self.atype_nloc)
else:
Expand Down