From cf67ea89bc995cc0c31e4d2fc48fdaed9672612e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:54:14 +0800 Subject: [PATCH 1/7] [pre-commit.ci] pre-commit autoupdate (#1568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.7 → v0.4.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.7...v0.4.8) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a9a2d699..1becae128 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.7 + rev: v0.4.8 hooks: - id: ruff args: ["--fix"] From 7812b33c485ba618338aff9ce10ad431717a18bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:39:50 -0400 Subject: [PATCH 2/7] [pre-commit.ci] pre-commit autoupdate (#1569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.8 → v0.4.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.8...v0.4.10) --------- Signed-off-by: Jinzhe Zeng Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jinzhe Zeng --- .pre-commit-config.yaml | 2 +- pyproject.toml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1becae128..66aef5765 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.8 + rev: v0.4.10 hooks: - id: ruff args: ["--fix"] diff --git a/pyproject.toml b/pyproject.toml index d5997f6a6..709cb0ca3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ 'paramiko', 'custodian', 'GromacsWrapper>=0.8.0', + 'GromacsWrapper>=0.9.0; python_version >= "3.12"', 'dpdispatcher>=0.3.11', 'netCDF4', 'dargs>=0.4.0', @@ -64,8 +65,9 @@ test = [ "dpgui", "coverage", "pymatgen-analysis-defects<2023.08.22", - # To be fixed: https://github.com/Becksteinlab/GromacsWrapper/issues/263 - 'setuptools; python_version >= "3.12"', + # https://github.com/materialsproject/pymatgen/issues/3882 + # https://github.com/kuelumbus/rdkit-pypi/issues/102 + "numpy<2", ] gui = [ "dpgui", From 8782483b6de93b845fb252c7ec42aaa4da6ac12c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:19:40 +0800 Subject: [PATCH 3/7] [pre-commit.ci] pre-commit autoupdate (#1574) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66aef5765..f7783e65e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.10 + rev: v0.5.0 hooks: - id: ruff args: ["--fix"] From e9a25fbc897fb70f65a61766505ee0cf2e1cfc27 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sat, 6 Jul 2024 11:36:19 -0400 Subject: [PATCH 4/7] chore: add the `mlp_engine` option (#1576) I am going to use DP-GEN to develop models trained by other MLP software. This may or may not be merged into the main branch, but I think a general `mlp_engine` option can be added anyway. ## Summary by CodeRabbit - **New Features** - Introduced handling for multiple ML potential engines with specialized training argument functions. - **Improvements** - Enhanced training initialization by splitting into common and engine-specific functions. - Improved error handling for unsupported ML potential engines. - **Bug Fixes** - Corrected logic to differentiate between `dp` and other engine values during training and model initialization. --------- Signed-off-by: Jinzhe Zeng Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- dpgen/generator/arginfo.py | 32 ++++++++++++++++++++++----- dpgen/generator/run.py | 44 +++++++++++++++++++++++++++++++------- dpgen/simplify/arginfo.py | 4 +++- dpgen/simplify/simplify.py | 8 +++++++ 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/dpgen/generator/arginfo.py b/dpgen/generator/arginfo.py index 92097af89..6cc38bbed 100644 --- a/dpgen/generator/arginfo.py +++ b/dpgen/generator/arginfo.py @@ -79,7 +79,14 @@ def data_args() -> list[Argument]: # Training -def training_args() -> list[Argument]: +def training_args_common() -> list[Argument]: + doc_numb_models = "Number of models to be trained in 00.train. 4 is recommend." + return [ + Argument("numb_models", int, optional=False, doc=doc_numb_models), + ] + + +def training_args_dp() -> list[Argument]: """Traning arguments. Returns @@ -90,7 +97,6 @@ def training_args() -> list[Argument]: doc_train_backend = ( "The backend of the training. Currently only support tensorflow and pytorch." ) - doc_numb_models = "Number of models to be trained in 00.train. 4 is recommend." doc_training_iter0_model_path = "The model used to init the first iter training. Number of element should be equal to numb_models." doc_training_init_model = "Iteration > 0, the model parameters will be initilized from the model trained at the previous iteration. Iteration == 0, the model parameters will be initialized from training_iter0_model_path." doc_default_training_param = "Training parameters for deepmd-kit in 00.train. You can find instructions from `DeePMD-kit documentation `_." @@ -133,7 +139,6 @@ def training_args() -> list[Argument]: default="tensorflow", doc=doc_train_backend, ), - Argument("numb_models", int, optional=False, doc=doc_numb_models), Argument( "training_iter0_model_path", list[str], @@ -224,6 +229,19 @@ def training_args() -> list[Argument]: ] +def training_args() -> Variant: + doc_mlp_engine = "Machine learning potential engine. Currently, only DeePMD-kit (defualt) is supported." + doc_dp = "DeePMD-kit." + return Variant( + "mlp_engine", + [ + Argument("dp", dict, training_args_dp(), doc=doc_dp), + ], + default_tag="dp", + doc=doc_mlp_engine, + ) + + # Exploration def model_devi_jobs_template_args() -> Argument: doc_template = ( @@ -987,7 +1005,11 @@ def run_jdata_arginfo() -> Argument: return Argument( "run_jdata", dict, - sub_fields=basic_args() + data_args() + training_args() + fp_args(), - sub_variants=model_devi_args() + [fp_style_variant_type_args()], + sub_fields=basic_args() + data_args() + training_args_common() + fp_args(), + sub_variants=[ + training_args(), + *model_devi_args(), + fp_style_variant_type_args(), + ], doc=doc_run_jdata, ) diff --git a/dpgen/generator/run.py b/dpgen/generator/run.py index 1e3e0e3fa..d376d467a 100644 --- a/dpgen/generator/run.py +++ b/dpgen/generator/run.py @@ -128,15 +128,19 @@ def _get_model_suffix(jdata) -> str: """Return the model suffix based on the backend.""" - suffix_map = {"tensorflow": ".pb", "pytorch": ".pth"} - backend = jdata.get("train_backend", "tensorflow") - if backend in suffix_map: - suffix = suffix_map[backend] + mlp_engine = jdata.get("mlp_engine", "dp") + if mlp_engine == "dp": + suffix_map = {"tensorflow": ".pb", "pytorch": ".pth"} + backend = jdata.get("train_backend", "tensorflow") + if backend in suffix_map: + suffix = suffix_map[backend] + else: + raise ValueError( + f"The backend {backend} is not available. Supported backends are: 'tensorflow', 'pytorch'." + ) + return suffix else: - raise ValueError( - f"The backend {backend} is not available. Supported backends are: 'tensorflow', 'pytorch'." - ) - return suffix + raise ValueError(f"Unsupported engine: {mlp_engine}") def get_job_names(jdata): @@ -270,6 +274,14 @@ def dump_to_deepmd_raw(dump, deepmd_raw, type_map, fmt="gromacs/gro", charge=Non def make_train(iter_index, jdata, mdata): + mlp_engine = jdata.get("mlp_engine", "dp") + if mlp_engine == "dp": + return make_train_dp(iter_index, jdata, mdata) + else: + raise ValueError(f"Unsupported engine: {mlp_engine}") + + +def make_train_dp(iter_index, jdata, mdata): # load json param # train_param = jdata['train_param'] train_input_file = default_train_input_file @@ -714,6 +726,14 @@ def get_nframes(system): def run_train(iter_index, jdata, mdata): + mlp_engine = jdata.get("mlp_engine", "dp") + if mlp_engine == "dp": + return make_train_dp(iter_index, jdata, mdata) + else: + raise ValueError(f"Unsupported engine: {mlp_engine}") + + +def run_train_dp(iter_index, jdata, mdata): # print("debug:run_train:mdata", mdata) # load json param numb_models = jdata["numb_models"] @@ -899,6 +919,14 @@ def run_train(iter_index, jdata, mdata): def post_train(iter_index, jdata, mdata): + mlp_engine = jdata.get("mlp_engine", "dp") + if mlp_engine == "dp": + return post_train_dp(iter_index, jdata, mdata) + else: + raise ValueError(f"Unsupported engine: {mlp_engine}") + + +def post_train_dp(iter_index, jdata, mdata): # load json param numb_models = jdata["numb_models"] # paths diff --git a/dpgen/simplify/arginfo.py b/dpgen/simplify/arginfo.py index 516b27e60..53507b2f6 100644 --- a/dpgen/simplify/arginfo.py +++ b/dpgen/simplify/arginfo.py @@ -12,6 +12,7 @@ fp_style_siesta_args, fp_style_vasp_args, training_args, + training_args_common, ) @@ -201,10 +202,11 @@ def simplify_jdata_arginfo() -> Argument: *data_args(), *general_simplify_arginfo(), # simplify use the same training method as run - *training_args(), + *training_args_common(), *fp_args(), ], sub_variants=[ + training_args(), fp_style_variant_type_args(), ], doc=doc_run_jdata, diff --git a/dpgen/simplify/simplify.py b/dpgen/simplify/simplify.py index 02fe54d79..24205fda3 100644 --- a/dpgen/simplify/simplify.py +++ b/dpgen/simplify/simplify.py @@ -103,6 +103,14 @@ def get_multi_system(path: Union[str, list[str]], jdata: dict) -> dpdata.MultiSy def init_model(iter_index, jdata, mdata): + mlp_engine = jdata.get("mlp_engine", "dp") + if mlp_engine == "dp": + init_model_dp(iter_index, jdata, mdata) + else: + raise TypeError(f"unsupported engine {mlp_engine}") + + +def init_model_dp(iter_index, jdata, mdata): training_init_model = jdata.get("training_init_model", False) if not training_init_model: return From 41a8d1b105d1254d328c176e88a88e6d2da3c204 Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" <48687836+njzjz-bot@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:14:31 -0400 Subject: [PATCH 5/7] fix: remove ref-names from .git_archival.txt (#1578) Removing ref-names is now suggested by setuptools-scm, per https://setuptools-scm.readthedocs.io/en/latest/usage/#git-archives, as it may lead to the git archive checksum changing. Generated by the task: https://github.com/njzjz-bot/njzjz-bot/issues/6. --- .git_archival.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/.git_archival.txt b/.git_archival.txt index 8fb235d70..7c5100942 100644 --- a/.git_archival.txt +++ b/.git_archival.txt @@ -1,4 +1,3 @@ node: $Format:%H$ node-date: $Format:%cI$ describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ -ref-names: $Format:%D$ From 2f39d12c28e2001bbff78e192aef42d6b91075ce Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:09:27 +0800 Subject: [PATCH 6/7] [pre-commit.ci] pre-commit autoupdate (#1579) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.0 → v0.5.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.0...v0.5.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f7783e65e..535025f7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: # Python - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.5.1 hooks: - id: ruff args: ["--fix"] From 30bc1e5dd6476d5b70aa40ad969a460132d69753 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 10 Jul 2024 09:54:47 -0400 Subject: [PATCH 7/7] fix: fix typo in run_train (#1581) ## Summary by CodeRabbit - **Refactor** - Renamed internal function `make_train_dp` to `run_train_dp` for better clarity and consistency within the codebase. (Note: This change does not impact end-user functionalities directly.) Signed-off-by: Jinzhe Zeng --- dpgen/generator/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpgen/generator/run.py b/dpgen/generator/run.py index d376d467a..b9642dda3 100644 --- a/dpgen/generator/run.py +++ b/dpgen/generator/run.py @@ -728,7 +728,7 @@ def get_nframes(system): def run_train(iter_index, jdata, mdata): mlp_engine = jdata.get("mlp_engine", "dp") if mlp_engine == "dp": - return make_train_dp(iter_index, jdata, mdata) + return run_train_dp(iter_index, jdata, mdata) else: raise ValueError(f"Unsupported engine: {mlp_engine}")