From 2d8a60f137237fe031b16b03c48f18b9e923b7b5 Mon Sep 17 00:00:00 2001 From: anyangml Date: Fri, 8 Mar 2024 07:13:50 +0000 Subject: [PATCH 01/10] chore: provide multiple typemap zbl torch --- deepmd/pt/model/model/__init__.py | 8 +-- examples/water/zbl/input_torch.json | 94 ++++++++++++++++++++++++++++ source/tests/pt/model/water/zbl.json | 9 +-- 3 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 examples/water/zbl/input_torch.json diff --git a/deepmd/pt/model/model/__init__.py b/deepmd/pt/model/model/__init__.py index 8e4352e60c..3f0b691d59 100644 --- a/deepmd/pt/model/model/__init__.py +++ b/deepmd/pt/model/model/__init__.py @@ -82,7 +82,7 @@ def get_spin_model(model_params): def get_zbl_model(model_params): model_params = copy.deepcopy(model_params) - ntypes = len(model_params["type_map"]) + ntypes = len(model_params["type_map"]["zbl"]) # descriptor model_params["descriptor"]["ntypes"] = ntypes descriptor = BaseDescriptor(**model_params["descriptor"]) @@ -99,14 +99,14 @@ def get_zbl_model(model_params): if "ener" in fitting_net["type"]: fitting_net["return_energy"] = True fitting = BaseFitting(**fitting_net) - dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map"]) + dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map"]["dp"]) # pairtab filepath = model_params["use_srtab"] pt_model = PairTabAtomicModel( filepath, model_params["descriptor"]["rcut"], model_params["descriptor"]["sel"], - type_map=model_params["type_map"], + type_map=model_params["type_map"]["pairtab"], ) rmin = model_params["sw_rmin"] @@ -118,7 +118,7 @@ def get_zbl_model(model_params): pt_model, rmin, rmax, - type_map=model_params["type_map"], + type_map=model_params["type_map"]["zbl"], atom_exclude_types=atom_exclude_types, pair_exclude_types=pair_exclude_types, ) diff --git a/examples/water/zbl/input_torch.json b/examples/water/zbl/input_torch.json new file mode 100644 index 0000000000..2f2291c617 --- /dev/null +++ b/examples/water/zbl/input_torch.json @@ -0,0 +1,94 @@ +{ + "_comment1": " model parameters", + "model": { + "use_srtab": "H2O_tab_potential.txt", + "smin_alpha": 0.1, + "sw_rmin": 0.8, + "sw_rmax": 1.0, + "type_map": { + "pairtab":["O","H"], + "dp": ["O", "H"], + "zbl": ["O", "H"] + }, + "descriptor": { + "type": "se_e2_a", + "sel": [ + 46, + 92 + ], + "rcut_smth": 0.50, + "rcut": 6.00, + "neuron": [ + 25, + 50, + 100 + ], + "resnet_dt": false, + "axis_neuron": 16, + "type_one_side": true, + "precision": "float64", + "seed": 1, + "_comment2": " that's all" + }, + "fitting_net": { + "neuron": [ + 240, + 240, + 240 + ], + "resnet_dt": true, + "precision": "float64", + "seed": 1, + "_comment3": " that's all" + }, + "_comment4": " that's all" + }, + + "learning_rate": { + "type": "exp", + "decay_steps": 5000, + "start_lr": 0.001, + "stop_lr": 3.51e-8, + "_comment5": "that's all" + }, + + "loss": { + "type": "ener", + "start_pref_e": 0.02, + "limit_pref_e": 1, + "start_pref_f": 1000, + "limit_pref_f": 1, + "start_pref_v": 0, + "limit_pref_v": 0, + "_comment6": " that's all" + }, + + "training": { + "training_data": { + "systems": [ + "../data/data_0/", + "../data/data_1/", + "../data/data_2/" + ], + "batch_size": "auto", + "_comment7": "that's all" + }, + "validation_data": { + "systems": [ + "../data/data_3" + ], + "batch_size": 1, + "numb_btch": 3, + "_comment8": "that's all" + }, + "numb_steps": 1000000, + "seed": 10, + "disp_file": "lcurve.out", + "disp_freq": 100, + "save_freq": 1000, + "_comment9": "that's all" + }, + + "_comment10": "that's all" + } + \ No newline at end of file diff --git a/source/tests/pt/model/water/zbl.json b/source/tests/pt/model/water/zbl.json index cb5602d92d..6258bba195 100644 --- a/source/tests/pt/model/water/zbl.json +++ b/source/tests/pt/model/water/zbl.json @@ -5,10 +5,11 @@ "smin_alpha": 0.1, "sw_rmin": 0.8, "sw_rmax": 1.0, - "type_map": [ - "O", - "H" - ], + "type_map": { + "pairtab":["O","H"], + "dp": ["O", "H"], + "zbl": ["O", "H"] + }, "descriptor": { "type": "se_e2_a", "sel": [ From 3bd8763f7c42a03874f5fbb42ef9324448b7ba33 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 07:15:03 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- deepmd/pt/model/model/__init__.py | 4 +- examples/water/zbl/input_torch.json | 186 ++++++++++++++------------- source/tests/pt/model/water/zbl.json | 15 ++- 3 files changed, 112 insertions(+), 93 deletions(-) diff --git a/deepmd/pt/model/model/__init__.py b/deepmd/pt/model/model/__init__.py index 3f0b691d59..7c6306264a 100644 --- a/deepmd/pt/model/model/__init__.py +++ b/deepmd/pt/model/model/__init__.py @@ -99,7 +99,9 @@ def get_zbl_model(model_params): if "ener" in fitting_net["type"]: fitting_net["return_energy"] = True fitting = BaseFitting(**fitting_net) - dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map"]["dp"]) + dp_model = DPAtomicModel( + descriptor, fitting, type_map=model_params["type_map"]["dp"] + ) # pairtab filepath = model_params["use_srtab"] pt_model = PairTabAtomicModel( diff --git a/examples/water/zbl/input_torch.json b/examples/water/zbl/input_torch.json index 2f2291c617..a01c5f8f0b 100644 --- a/examples/water/zbl/input_torch.json +++ b/examples/water/zbl/input_torch.json @@ -1,94 +1,102 @@ { - "_comment1": " model parameters", - "model": { - "use_srtab": "H2O_tab_potential.txt", - "smin_alpha": 0.1, - "sw_rmin": 0.8, - "sw_rmax": 1.0, - "type_map": { - "pairtab":["O","H"], - "dp": ["O", "H"], - "zbl": ["O", "H"] - }, - "descriptor": { - "type": "se_e2_a", - "sel": [ - 46, - 92 - ], - "rcut_smth": 0.50, - "rcut": 6.00, - "neuron": [ - 25, - 50, - 100 - ], - "resnet_dt": false, - "axis_neuron": 16, - "type_one_side": true, - "precision": "float64", - "seed": 1, - "_comment2": " that's all" - }, - "fitting_net": { - "neuron": [ - 240, - 240, - 240 - ], - "resnet_dt": true, - "precision": "float64", - "seed": 1, - "_comment3": " that's all" - }, - "_comment4": " that's all" + "_comment1": " model parameters", + "model": { + "use_srtab": "H2O_tab_potential.txt", + "smin_alpha": 0.1, + "sw_rmin": 0.8, + "sw_rmax": 1.0, + "type_map": { + "pairtab": [ + "O", + "H" + ], + "dp": [ + "O", + "H" + ], + "zbl": [ + "O", + "H" + ] }, - - "learning_rate": { - "type": "exp", - "decay_steps": 5000, - "start_lr": 0.001, - "stop_lr": 3.51e-8, - "_comment5": "that's all" + "descriptor": { + "type": "se_e2_a", + "sel": [ + 46, + 92 + ], + "rcut_smth": 0.50, + "rcut": 6.00, + "neuron": [ + 25, + 50, + 100 + ], + "resnet_dt": false, + "axis_neuron": 16, + "type_one_side": true, + "precision": "float64", + "seed": 1, + "_comment2": " that's all" }, - - "loss": { - "type": "ener", - "start_pref_e": 0.02, - "limit_pref_e": 1, - "start_pref_f": 1000, - "limit_pref_f": 1, - "start_pref_v": 0, - "limit_pref_v": 0, - "_comment6": " that's all" + "fitting_net": { + "neuron": [ + 240, + 240, + 240 + ], + "resnet_dt": true, + "precision": "float64", + "seed": 1, + "_comment3": " that's all" }, - - "training": { - "training_data": { - "systems": [ - "../data/data_0/", - "../data/data_1/", - "../data/data_2/" - ], - "batch_size": "auto", - "_comment7": "that's all" - }, - "validation_data": { - "systems": [ - "../data/data_3" - ], - "batch_size": 1, - "numb_btch": 3, - "_comment8": "that's all" - }, - "numb_steps": 1000000, - "seed": 10, - "disp_file": "lcurve.out", - "disp_freq": 100, - "save_freq": 1000, - "_comment9": "that's all" + "_comment4": " that's all" + }, + + "learning_rate": { + "type": "exp", + "decay_steps": 5000, + "start_lr": 0.001, + "stop_lr": 3.51e-8, + "_comment5": "that's all" + }, + + "loss": { + "type": "ener", + "start_pref_e": 0.02, + "limit_pref_e": 1, + "start_pref_f": 1000, + "limit_pref_f": 1, + "start_pref_v": 0, + "limit_pref_v": 0, + "_comment6": " that's all" + }, + + "training": { + "training_data": { + "systems": [ + "../data/data_0/", + "../data/data_1/", + "../data/data_2/" + ], + "batch_size": "auto", + "_comment7": "that's all" }, - - "_comment10": "that's all" - } - \ No newline at end of file + "validation_data": { + "systems": [ + "../data/data_3" + ], + "batch_size": 1, + "numb_btch": 3, + "_comment8": "that's all" + }, + "numb_steps": 1000000, + "seed": 10, + "disp_file": "lcurve.out", + "disp_freq": 100, + "save_freq": 1000, + "_comment9": "that's all" + }, + + "_comment10": "that's all" +} diff --git a/source/tests/pt/model/water/zbl.json b/source/tests/pt/model/water/zbl.json index 6258bba195..a01c5f8f0b 100644 --- a/source/tests/pt/model/water/zbl.json +++ b/source/tests/pt/model/water/zbl.json @@ -6,9 +6,18 @@ "sw_rmin": 0.8, "sw_rmax": 1.0, "type_map": { - "pairtab":["O","H"], - "dp": ["O", "H"], - "zbl": ["O", "H"] + "pairtab": [ + "O", + "H" + ], + "dp": [ + "O", + "H" + ], + "zbl": [ + "O", + "H" + ] }, "descriptor": { "type": "se_e2_a", From 2ae5626e32dc082a6534d527ad4f81a4b439f675 Mon Sep 17 00:00:00 2001 From: anyangml Date: Fri, 8 Mar 2024 07:30:30 +0000 Subject: [PATCH 03/10] doc: update pairtab doc --- doc/model/pairtab.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/model/pairtab.md b/doc/model/pairtab.md index fee4d754a6..31b04bd682 100644 --- a/doc/model/pairtab.md +++ b/doc/model/pairtab.md @@ -1,7 +1,7 @@ -# Interpolation or combination with a pairwise potential {{ tensorflow_icon }} +# Interpolation or combination with a pairwise potential {{ tensorflow_icon }} {{ pytorch_icon }} {{ dpmodel_icon }} :::{note} -**Supported backends**: TensorFlow {{ tensorflow_icon }} +**Supported backends**: TensorFlow {{ tensorflow_icon }}, PyTorch {{ pytorch_icon }}, DP {{ dpmodel_icon }} ::: ## Theory @@ -59,6 +59,9 @@ In instances where the interaction at the cut-off distance is not delineated wit ## Interpolation with a short-range pairwise potential +::::{tab-set} + +:::{tab-item} TensorFlow {{ tensorflow_icon }} ```json "model": { "use_srtab": "H2O_tab_potential.txt", @@ -68,10 +71,32 @@ In instances where the interaction at the cut-off distance is not delineated wit "_comment": "Below uses a normal DP model" } ``` +::: + +:::{tab-item} PyTorch {{ pytorch_icon }} + +```json +"model": { + "use_srtab": "H2O_tab_potential.txt", + "smin_alpha": 0.1, + "sw_rmin": 0.8, + "sw_rmax": 1.0, + "type_map":{ + "pairtab": ["H", "O"], + "dp": ["O", "H"], + "zbl": ["H", "O"] + }, + "_comment": "Below uses a normal DP model" +} +``` +In the PyTorch backend, the `ZBLModel` accommodates mismatched `type_map`. The ultimate `type_map` utilized by the combined model is a union of the `type_map` from the individual models. +::: + +:::: {ref}`sw_rmin ` and {ref}`sw_rmax ` must be smaller than the cutoff radius of the DP model. -## Combination with a pairwise potential +## Combination with a pairwise potential {{ tensorflow_icon }} To combine with a pairwise potential, use the [linear model](./linear.md): From 0f610b58b4b683744f2677298f6daa32da02c3a9 Mon Sep 17 00:00:00 2001 From: anyangml Date: Fri, 8 Mar 2024 10:09:09 +0000 Subject: [PATCH 04/10] fix: UTs --- source/tests/pt/model/test_permutation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/tests/pt/model/test_permutation.py b/source/tests/pt/model/test_permutation.py index 8ec5c375fd..0061d6d1ed 100644 --- a/source/tests/pt/model/test_permutation.py +++ b/source/tests/pt/model/test_permutation.py @@ -37,7 +37,11 @@ } model_zbl = { - "type_map": ["O", "H", "B"], + "type_map": { + "zbl":["O", "H", "B"], + "pairtab":["B", "O", "H"], + "dp": ["H", "B", "O"] + }, "use_srtab": "source/tests/pt/model/water/data/zbl_tab_potential/H2O_tab_potential.txt", "smin_alpha": 0.1, "sw_rmin": 0.2, From 79079dd9e3e00e92bb34139c9bacafeffa25195d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:09:39 +0000 Subject: [PATCH 05/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/tests/pt/model/test_permutation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/tests/pt/model/test_permutation.py b/source/tests/pt/model/test_permutation.py index 0061d6d1ed..911df2a331 100644 --- a/source/tests/pt/model/test_permutation.py +++ b/source/tests/pt/model/test_permutation.py @@ -38,9 +38,9 @@ model_zbl = { "type_map": { - "zbl":["O", "H", "B"], - "pairtab":["B", "O", "H"], - "dp": ["H", "B", "O"] + "zbl": ["O", "H", "B"], + "pairtab": ["B", "O", "H"], + "dp": ["H", "B", "O"], }, "use_srtab": "source/tests/pt/model/water/data/zbl_tab_potential/H2O_tab_potential.txt", "smin_alpha": 0.1, From af38266bd7ae2a3904e1199807954037add4a35c Mon Sep 17 00:00:00 2001 From: anyangml Date: Mon, 11 Mar 2024 03:59:48 +0000 Subject: [PATCH 06/10] fix: split type map --- deepmd/pt/model/model/__init__.py | 8 +++---- doc/model/pairtab.md | 8 +++---- examples/water/zbl/input_torch.json | 26 +++++++++++------------ source/tests/pt/model/test_permutation.py | 8 +++---- source/tests/pt/model/water/zbl.json | 26 +++++++++++------------ 5 files changed, 34 insertions(+), 42 deletions(-) diff --git a/deepmd/pt/model/model/__init__.py b/deepmd/pt/model/model/__init__.py index 7c6306264a..642c6f4eb6 100644 --- a/deepmd/pt/model/model/__init__.py +++ b/deepmd/pt/model/model/__init__.py @@ -82,7 +82,7 @@ def get_spin_model(model_params): def get_zbl_model(model_params): model_params = copy.deepcopy(model_params) - ntypes = len(model_params["type_map"]["zbl"]) + ntypes = len(model_params["type_map"]) # descriptor model_params["descriptor"]["ntypes"] = ntypes descriptor = BaseDescriptor(**model_params["descriptor"]) @@ -100,7 +100,7 @@ def get_zbl_model(model_params): fitting_net["return_energy"] = True fitting = BaseFitting(**fitting_net) dp_model = DPAtomicModel( - descriptor, fitting, type_map=model_params["type_map"]["dp"] + descriptor, fitting, type_map=model_params["type_map_dp"] ) # pairtab filepath = model_params["use_srtab"] @@ -108,7 +108,7 @@ def get_zbl_model(model_params): filepath, model_params["descriptor"]["rcut"], model_params["descriptor"]["sel"], - type_map=model_params["type_map"]["pairtab"], + type_map=model_params["type_map_pairtab"] ) rmin = model_params["sw_rmin"] @@ -120,7 +120,7 @@ def get_zbl_model(model_params): pt_model, rmin, rmax, - type_map=model_params["type_map"]["zbl"], + type_map=model_params["type_map"], atom_exclude_types=atom_exclude_types, pair_exclude_types=pair_exclude_types, ) diff --git a/doc/model/pairtab.md b/doc/model/pairtab.md index 31b04bd682..4ebf1123ee 100644 --- a/doc/model/pairtab.md +++ b/doc/model/pairtab.md @@ -81,11 +81,9 @@ In instances where the interaction at the cut-off distance is not delineated wit "smin_alpha": 0.1, "sw_rmin": 0.8, "sw_rmax": 1.0, - "type_map":{ - "pairtab": ["H", "O"], - "dp": ["O", "H"], - "zbl": ["H", "O"] - }, + "type_map":["H", "O"], + "type_map_dp": ["O", "H"], + "type_map_pairtab": ["O", "H"], "_comment": "Below uses a normal DP model" } ``` diff --git a/examples/water/zbl/input_torch.json b/examples/water/zbl/input_torch.json index a01c5f8f0b..878055fb5c 100644 --- a/examples/water/zbl/input_torch.json +++ b/examples/water/zbl/input_torch.json @@ -5,20 +5,18 @@ "smin_alpha": 0.1, "sw_rmin": 0.8, "sw_rmax": 1.0, - "type_map": { - "pairtab": [ - "O", - "H" - ], - "dp": [ - "O", - "H" - ], - "zbl": [ - "O", - "H" - ] - }, + "type_map": [ + "O", + "H" + ], + "type_map_dp": [ + "H", + "O" + ], + "type_map_pairtab": [ + "O", + "H" + ], "descriptor": { "type": "se_e2_a", "sel": [ diff --git a/source/tests/pt/model/test_permutation.py b/source/tests/pt/model/test_permutation.py index 911df2a331..fa0c80c9b2 100644 --- a/source/tests/pt/model/test_permutation.py +++ b/source/tests/pt/model/test_permutation.py @@ -37,11 +37,9 @@ } model_zbl = { - "type_map": { - "zbl": ["O", "H", "B"], - "pairtab": ["B", "O", "H"], - "dp": ["H", "B", "O"], - }, + "type_map": ["O", "H", "B"], + "type_map_dp":["H", "B", "O"], + "type_map_pairtab": ["B", "O", "H"], "use_srtab": "source/tests/pt/model/water/data/zbl_tab_potential/H2O_tab_potential.txt", "smin_alpha": 0.1, "sw_rmin": 0.2, diff --git a/source/tests/pt/model/water/zbl.json b/source/tests/pt/model/water/zbl.json index a01c5f8f0b..878055fb5c 100644 --- a/source/tests/pt/model/water/zbl.json +++ b/source/tests/pt/model/water/zbl.json @@ -5,20 +5,18 @@ "smin_alpha": 0.1, "sw_rmin": 0.8, "sw_rmax": 1.0, - "type_map": { - "pairtab": [ - "O", - "H" - ], - "dp": [ - "O", - "H" - ], - "zbl": [ - "O", - "H" - ] - }, + "type_map": [ + "O", + "H" + ], + "type_map_dp": [ + "H", + "O" + ], + "type_map_pairtab": [ + "O", + "H" + ], "descriptor": { "type": "se_e2_a", "sel": [ From 9ecb081d3b86a6758275791fd3e7b8d889124a3e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 04:00:19 +0000 Subject: [PATCH 07/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- deepmd/pt/model/model/__init__.py | 6 ++---- source/tests/pt/model/test_permutation.py | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/deepmd/pt/model/model/__init__.py b/deepmd/pt/model/model/__init__.py index 642c6f4eb6..dd4c88fded 100644 --- a/deepmd/pt/model/model/__init__.py +++ b/deepmd/pt/model/model/__init__.py @@ -99,16 +99,14 @@ def get_zbl_model(model_params): if "ener" in fitting_net["type"]: fitting_net["return_energy"] = True fitting = BaseFitting(**fitting_net) - dp_model = DPAtomicModel( - descriptor, fitting, type_map=model_params["type_map_dp"] - ) + dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map_dp"]) # pairtab filepath = model_params["use_srtab"] pt_model = PairTabAtomicModel( filepath, model_params["descriptor"]["rcut"], model_params["descriptor"]["sel"], - type_map=model_params["type_map_pairtab"] + type_map=model_params["type_map_pairtab"], ) rmin = model_params["sw_rmin"] diff --git a/source/tests/pt/model/test_permutation.py b/source/tests/pt/model/test_permutation.py index fa0c80c9b2..dd11483326 100644 --- a/source/tests/pt/model/test_permutation.py +++ b/source/tests/pt/model/test_permutation.py @@ -37,8 +37,8 @@ } model_zbl = { - "type_map": ["O", "H", "B"], - "type_map_dp":["H", "B", "O"], + "type_map": ["O", "H", "B"], + "type_map_dp": ["H", "B", "O"], "type_map_pairtab": ["B", "O", "H"], "use_srtab": "source/tests/pt/model/water/data/zbl_tab_potential/H2O_tab_potential.txt", "smin_alpha": 0.1, From 71b0fe4cbbfa66f0cb72cd3e421a23a1a3e58907 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:34:43 +0000 Subject: [PATCH 08/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/model/pairtab.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/model/pairtab.md b/doc/model/pairtab.md index 0e32f6be0b..0fdeb8949e 100644 --- a/doc/model/pairtab.md +++ b/doc/model/pairtab.md @@ -1,7 +1,7 @@ # Interpolation or combination with a pairwise potential {{ tensorflow_icon }} {{ pytorch_icon }} {{ dpmodel_icon }} :::{note} -**Supported backends**: TensorFlow {{ tensorflow_icon }}, PyTorch {{ pytorch_icon }}, DP {{ dpmodel_icon }} +**Supported backends**: TensorFlow {{ tensorflow_icon }}, PyTorch {{ pytorch_icon }}, DP {{ dpmodel_icon }} ::: ## Theory @@ -71,6 +71,7 @@ In instances where the interaction at the cut-off distance is not delineated wit ::::{tab-set} :::{tab-item} TensorFlow {{ tensorflow_icon }} + ```json "model": { "use_srtab": "H2O_tab_potential.txt", @@ -80,6 +81,7 @@ In instances where the interaction at the cut-off distance is not delineated wit "_comment": "Below uses a normal DP model" } ``` + ::: :::{tab-item} PyTorch {{ pytorch_icon }} @@ -96,6 +98,7 @@ In instances where the interaction at the cut-off distance is not delineated wit "_comment": "Below uses a normal DP model" } ``` + In the PyTorch backend, the `ZBLModel` accommodates mismatched `type_map`. The ultimate `type_map` utilized by the combined model is a union of the `type_map` from the individual models. ::: From e8287d1319e7ae36af2de3906929d1aa32cbd3cc Mon Sep 17 00:00:00 2001 From: Anyang Peng <137014849+anyangml@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:02:09 +0800 Subject: [PATCH 09/10] fix: revert changes --- deepmd/pt/model/model/__init__.py | 4 +- doc/model/pairtab.md | 27 +----- examples/water/zbl/input_torch.json | 100 ---------------------- source/tests/pt/model/test_permutation.py | 2 - source/tests/pt/model/water/zbl.json | 8 -- 5 files changed, 4 insertions(+), 137 deletions(-) delete mode 100644 examples/water/zbl/input_torch.json diff --git a/deepmd/pt/model/model/__init__.py b/deepmd/pt/model/model/__init__.py index 3b3af38558..da69650a21 100644 --- a/deepmd/pt/model/model/__init__.py +++ b/deepmd/pt/model/model/__init__.py @@ -121,14 +121,14 @@ def get_zbl_model(model_params): if "ener" in fitting_net["type"]: fitting_net["return_energy"] = True fitting = BaseFitting(**fitting_net) - dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map_dp"]) + dp_model = DPAtomicModel(descriptor, fitting, type_map=model_params["type_map"]) # pairtab filepath = model_params["use_srtab"] pt_model = PairTabAtomicModel( filepath, model_params["descriptor"]["rcut"], model_params["descriptor"]["sel"], - type_map=model_params["type_map_pairtab"], + type_map=model_params["type_map"], ) rmin = model_params["sw_rmin"] diff --git a/doc/model/pairtab.md b/doc/model/pairtab.md index 0fdeb8949e..81d0df5009 100644 --- a/doc/model/pairtab.md +++ b/doc/model/pairtab.md @@ -47,7 +47,7 @@ The pairwise potential $u^{\textrm{pair}}(r)$ is defined by a user-defined table [^1]: This section is built upon Jinzhe Zeng, Duo Zhang, Denghui Lu, Pinghui Mo, Zeyu Li, Yixiao Chen, Marián Rynik, Li'ang Huang, Ziyao Li, Shaochen Shi, Yingze Wang, Haotian Ye, Ping Tuo, Jiabin Yang, Ye Ding, Yifan Li, Davide Tisi, Qiyu Zeng, Han Bao, Yu Xia, Jiameng Huang, Koki Muraoka, Yibo Wang, Junhan Chang, Fengbo Yuan, Sigbjørn Løland Bore, Chun Cai, Yinnian Lin, Bo Wang, Jiayan Xu, Jia-Xin Zhu, Chenxing Luo, Yuzhi Zhang, Rhys E. A. Goodall, Wenshuo Liang, Anurag Kumar Singh, Sikai Yao, Jingchao Zhang, Renata Wentzcovitch, Jiequn Han, Jie Liu, Weile Jia, Darrin M. York, Weinan E, Roberto Car, Linfeng Zhang, Han Wang, [J. Chem. Phys. 159, 054801 (2023)](https://doi.org/10.1063/5.0155600) licensed under a [Creative Commons Attribution (CC BY) license](http://creativecommons.org/licenses/by/4.0/). -DeePMD-kit also supports combination with a pairwise potential: +DeePMD-kit also supports combination with a pairwise potential {{ tensorflow_icon }}: ```math E_i = E_i^{\mathrm{DP}} + E_i^{\mathrm{pair}}, @@ -68,9 +68,6 @@ In instances where the interaction at the cut-off distance is not delineated wit ## Interpolation with a short-range pairwise potential -::::{tab-set} - -:::{tab-item} TensorFlow {{ tensorflow_icon }} ```json "model": { @@ -82,32 +79,12 @@ In instances where the interaction at the cut-off distance is not delineated wit } ``` -::: - -:::{tab-item} PyTorch {{ pytorch_icon }} - -```json -"model": { - "use_srtab": "H2O_tab_potential.txt", - "smin_alpha": 0.1, - "sw_rmin": 0.8, - "sw_rmax": 1.0, - "type_map":["H", "O"], - "type_map_dp": ["O", "H"], - "type_map_pairtab": ["O", "H"], - "_comment": "Below uses a normal DP model" -} -``` - -In the PyTorch backend, the `ZBLModel` accommodates mismatched `type_map`. The ultimate `type_map` utilized by the combined model is a union of the `type_map` from the individual models. -::: - -:::: {ref}`sw_rmin ` and {ref}`sw_rmax ` must be smaller than the cutoff radius of the DP model. ## Combination with a pairwise potential {{ tensorflow_icon }} + To combine with a pairwise potential, use the [linear model](./linear.md): ```json diff --git a/examples/water/zbl/input_torch.json b/examples/water/zbl/input_torch.json deleted file mode 100644 index 878055fb5c..0000000000 --- a/examples/water/zbl/input_torch.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "_comment1": " model parameters", - "model": { - "use_srtab": "H2O_tab_potential.txt", - "smin_alpha": 0.1, - "sw_rmin": 0.8, - "sw_rmax": 1.0, - "type_map": [ - "O", - "H" - ], - "type_map_dp": [ - "H", - "O" - ], - "type_map_pairtab": [ - "O", - "H" - ], - "descriptor": { - "type": "se_e2_a", - "sel": [ - 46, - 92 - ], - "rcut_smth": 0.50, - "rcut": 6.00, - "neuron": [ - 25, - 50, - 100 - ], - "resnet_dt": false, - "axis_neuron": 16, - "type_one_side": true, - "precision": "float64", - "seed": 1, - "_comment2": " that's all" - }, - "fitting_net": { - "neuron": [ - 240, - 240, - 240 - ], - "resnet_dt": true, - "precision": "float64", - "seed": 1, - "_comment3": " that's all" - }, - "_comment4": " that's all" - }, - - "learning_rate": { - "type": "exp", - "decay_steps": 5000, - "start_lr": 0.001, - "stop_lr": 3.51e-8, - "_comment5": "that's all" - }, - - "loss": { - "type": "ener", - "start_pref_e": 0.02, - "limit_pref_e": 1, - "start_pref_f": 1000, - "limit_pref_f": 1, - "start_pref_v": 0, - "limit_pref_v": 0, - "_comment6": " that's all" - }, - - "training": { - "training_data": { - "systems": [ - "../data/data_0/", - "../data/data_1/", - "../data/data_2/" - ], - "batch_size": "auto", - "_comment7": "that's all" - }, - "validation_data": { - "systems": [ - "../data/data_3" - ], - "batch_size": 1, - "numb_btch": 3, - "_comment8": "that's all" - }, - "numb_steps": 1000000, - "seed": 10, - "disp_file": "lcurve.out", - "disp_freq": 100, - "save_freq": 1000, - "_comment9": "that's all" - }, - - "_comment10": "that's all" -} diff --git a/source/tests/pt/model/test_permutation.py b/source/tests/pt/model/test_permutation.py index eb1bd47026..110abd0d23 100644 --- a/source/tests/pt/model/test_permutation.py +++ b/source/tests/pt/model/test_permutation.py @@ -60,8 +60,6 @@ model_zbl = { "type_map": ["O", "H", "B"], - "type_map_dp": ["H", "B", "O"], - "type_map_pairtab": ["B", "O", "H"], "use_srtab": "source/tests/pt/model/water/data/zbl_tab_potential/H2O_tab_potential.txt", "smin_alpha": 0.1, "sw_rmin": 0.2, diff --git a/source/tests/pt/model/water/zbl.json b/source/tests/pt/model/water/zbl.json index 878055fb5c..cb5602d92d 100644 --- a/source/tests/pt/model/water/zbl.json +++ b/source/tests/pt/model/water/zbl.json @@ -9,14 +9,6 @@ "O", "H" ], - "type_map_dp": [ - "H", - "O" - ], - "type_map_pairtab": [ - "O", - "H" - ], "descriptor": { "type": "se_e2_a", "sel": [ From e407d39263a8f6b6599b60bac2bf27a3d04423fd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:02:44 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/model/pairtab.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/model/pairtab.md b/doc/model/pairtab.md index 81d0df5009..f52ad5dae7 100644 --- a/doc/model/pairtab.md +++ b/doc/model/pairtab.md @@ -68,7 +68,6 @@ In instances where the interaction at the cut-off distance is not delineated wit ## Interpolation with a short-range pairwise potential - ```json "model": { "use_srtab": "H2O_tab_potential.txt", @@ -79,12 +78,10 @@ In instances where the interaction at the cut-off distance is not delineated wit } ``` - {ref}`sw_rmin ` and {ref}`sw_rmax ` must be smaller than the cutoff radius of the DP model. ## Combination with a pairwise potential {{ tensorflow_icon }} - To combine with a pairwise potential, use the [linear model](./linear.md): ```json