Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的论文库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
DP-Gen based on a DPA-2 pretrained model
DPA
DPA
zjgemi
2043899742@qq.com
发布于 2023-12-21
推荐镜像 :deepmd-kit:stable-0411
推荐机型 :c12_m92_1 * NVIDIA V100
赞 4
4
4
dpa2-finetune-water-example(v3)

Finetuning based on DPA-2 pretrained model can reduce the amount of data required for training. Running DP-Gen with a DPA-2 pretrained model can also save first-principles labelling. DP-Gen with DPA-2 requires DP-Gen2. First, install the latest version of DP-Gen2.

代码
文本
[1]
!pip install git+https://github.com/deepmodeling/dpgen2
!pip install -U dpdata
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting git+https://github.com/deepmodeling/dpgen2
  Cloning https://github.com/deepmodeling/dpgen2 to /tmp/pip-req-build-_of6sxti
  Running command git clone --filter=blob:none --quiet https://github.com/deepmodeling/dpgen2 /tmp/pip-req-build-_of6sxti
  Resolved https://github.com/deepmodeling/dpgen2 to commit 8733ff57d441831a788ddfb7a47af5b73d217275
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... -Collecting pydflow>=1.6.57 (from dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/81/ca/d69cc1204efeaa91bbdfe84a7d9f096e32c4331efa575448dfdb21866b9d/pydflow-1.8.61-py3-none-any.whl (159 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 159.5/159.5 kB 19.1 MB/s eta 0:00:00
Requirement already satisfied: dargs>=0.3.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpgen2==0.0.8.dev84+g8733ff5) (0.4.4)
Requirement already satisfied: scipy in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpgen2==0.0.8.dev84+g8733ff5) (1.12.0)
Requirement already satisfied: lbg in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpgen2==0.0.8.dev84+g8733ff5) (1.2.24)
Requirement already satisfied: packaging in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpgen2==0.0.8.dev84+g8733ff5) (23.2)
Collecting fpop (from dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/0e/8cf4fa4c1abd303cbe42c5fb345dd1dd866f7b2a5ea7b59c911c9a7d1e79/fpop-0.0.7-py3-none-any.whl (32 kB)
Collecting dpgui (from dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f1/b7/d277585dd8868f4dd7c623a07b658aec8ccc9c8adfd8e0180615372ec0de/dpgui-1.0.0-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 39.2 MB/s eta 0:00:00a 0:00:01
Requirement already satisfied: typeguard>=4 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dargs>=0.3.1->dpgen2==0.0.8.dev84+g8733ff5) (4.1.5)
Requirement already satisfied: six in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (1.16.0)
Requirement already satisfied: python-dateutil in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (2.9.0)
Requirement already satisfied: urllib3 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (2.2.1)
Requirement already satisfied: certifi in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (2024.2.2)
Collecting argo-workflows==5.0.0 (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b1/6a/8f13d5124b111e8e054594d23782ea9c5dadda0517d1dd9ad08c7c055732/argo_workflows-5.0.0-py3-none-any.whl (452 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 452.5/452.5 kB 43.3 MB/s eta 0:00:00
Collecting jsonpickle (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/19/c3/453e4e2da82d5efad9e653916a120d94daf5062f7eae43e28f39fff1bc6a/jsonpickle-3.0.4-py3-none-any.whl (39 kB)
Collecting minio (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/45/a4/6f278051ad2bc03f3a0fdb4e182c9529009b0357631c2bb7c6ae70b4b0f6/minio-7.2.5-py3-none-any.whl (93 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 93.2/93.2 kB 17.5 MB/s eta 0:00:00
Collecting kubernetes (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6f/34/164e57fec8a9693d7e6ae2d1a345482020ea9e9b32eab95a90bb3eaea83d/kubernetes-29.0.0-py2.py3-none-any.whl (1.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 55.6 MB/s eta 0:00:00
Requirement already satisfied: pyyaml in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (6.0.1)
Collecting cloudpickle==2.2.0 (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cf/26/cd6c4177273ee35f7a31245893489c68bc340988f12ca315b392f1f18a93/cloudpickle-2.2.0-py3-none-any.whl (25 kB)
Requirement already satisfied: requests in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (2.31.0)
Requirement already satisfied: tqdm in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (4.66.2)
Requirement already satisfied: psutil in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (5.9.8)
Requirement already satisfied: monty in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata->dpgen2==0.0.8.dev84+g8733ff5) (2024.2.26)
Requirement already satisfied: h5py in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata->dpgen2==0.0.8.dev84+g8733ff5) (3.10.0)
Requirement already satisfied: wcmatch in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata->dpgen2==0.0.8.dev84+g8733ff5) (8.5)
Collecting waitress (from dpgui->dpgen2==0.0.8.dev84+g8733ff5)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5b/a9/485c953a1ac4cb98c28e41fd2c7184072df36bbf99734a51d44d04176878/waitress-3.0.0-py3-none-any.whl (56 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.7/56.7 kB 10.7 MB/s eta 0:00:00
Requirement already satisfied: werkzeug in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpgui->dpgen2==0.0.8.dev84+g8733ff5) (3.0.1)
Requirement already satisfied: oss2 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.18.4)
Requirement already satisfied: requests-toolbelt in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (1.0.0)
Requirement already satisfied: aliyun-python-sdk-core in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.14.0)
Requirement already satisfied: aliyun-python-sdk-kms in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.16.2)
Requirement already satisfied: aliyun-python-sdk-sts in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (3.1.2)
Requirement already satisfied: pytimeparse in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (1.1.8)
Requirement already satisfied: pandas in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.2.1)
Requirement already satisfied: colorama in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (0.4.6)
Requirement already satisfied: readchar in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (4.0.5)
Requirement already satisfied: pyreadline in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.1)
Requirement already satisfied: pyreadline3 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (3.4.1)
Requirement already satisfied: validators in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (0.22.0)
Requirement already satisfied: pyhumps in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (3.8.0)
Requirement already satisfied: argcomplete in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from lbg->dpgen2==0.0.8.dev84+g8733ff5) (3.2.2)
Requirement already satisfied: typing-extensions>=4.7.0 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from typeguard>=4->dargs>=0.3.1->dpgen2==0.0.8.dev84+g8733ff5) (4.10.0)
Requirement already satisfied: jmespath<1.0.0,>=0.9.3 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from aliyun-python-sdk-core->lbg->dpgen2==0.0.8.dev84+g8733ff5) (0.10.0)
Requirement already satisfied: cryptography>=2.6.0 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from aliyun-python-sdk-core->lbg->dpgen2==0.0.8.dev84+g8733ff5) (42.0.5)
Requirement already satisfied: google-auth>=1.0.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (2.28.1)
Requirement already satisfied: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (1.7.0)
Requirement already satisfied: requests-oauthlib in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (1.3.1)
Requirement already satisfied: oauthlib>=3.2.2 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (3.2.2)
Requirement already satisfied: argon2-cffi in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from minio->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (23.1.0)
Requirement already satisfied: pycryptodome in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from minio->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (3.20.0)
Requirement already satisfied: crcmod>=1.7 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from oss2->lbg->dpgen2==0.0.8.dev84+g8733ff5) (1.7)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from requests->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from requests->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (3.6)
Requirement already satisfied: pytz>=2020.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pandas->lbg->dpgen2==0.0.8.dev84+g8733ff5) (2024.1)
Requirement already satisfied: tzdata>=2022.7 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pandas->lbg->dpgen2==0.0.8.dev84+g8733ff5) (2024.1)
Requirement already satisfied: setuptools>=41.0 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from readchar->lbg->dpgen2==0.0.8.dev84+g8733ff5) (69.1.1)
Requirement already satisfied: bracex>=2.1.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from wcmatch->dpdata->dpgen2==0.0.8.dev84+g8733ff5) (2.2.1)
Requirement already satisfied: MarkupSafe>=2.1.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from werkzeug->dpgui->dpgen2==0.0.8.dev84+g8733ff5) (2.1.5)
Requirement already satisfied: cffi>=1.12 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from cryptography>=2.6.0->aliyun-python-sdk-core->lbg->dpgen2==0.0.8.dev84+g8733ff5) (1.16.0)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (5.3.3)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (0.3.0)
Requirement already satisfied: rsa<5,>=3.1.4 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from google-auth>=1.0.1->kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (4.9)
Requirement already satisfied: argon2-cffi-bindings in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from argon2-cffi->minio->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (21.2.0)
Requirement already satisfied: pycparser in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=2.6.0->aliyun-python-sdk-core->lbg->dpgen2==0.0.8.dev84+g8733ff5) (2.21)
Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from pyasn1-modules>=0.2.1->google-auth>=1.0.1->kubernetes->pydflow>=1.6.57->dpgen2==0.0.8.dev84+g8733ff5) (0.5.1)
Building wheels for collected packages: dpgen2
  Building wheel for dpgen2 (pyproject.toml) ... done
  Created wheel for dpgen2: filename=dpgen2-0.0.8.dev84+g8733ff5-py3-none-any.whl size=137288 sha256=93ace2c7228d0c87c3affead70d8aedd37899ee6113ac3b0772248cad6abb38c
  Stored in directory: /tmp/pip-ephem-wheel-cache-jepqed2_/wheels/97/ff/bf/0a0da3c722e0e1e39ca0f03f5fdc69ee7805c3330ee08c81b1
Successfully built dpgen2
Installing collected packages: argo-workflows, waitress, jsonpickle, cloudpickle, kubernetes, dpgui, minio, pydflow, fpop, dpgen2
  Attempting uninstall: cloudpickle
    Found existing installation: cloudpickle 3.0.0
    Uninstalling cloudpickle-3.0.0:
      Successfully uninstalled cloudpickle-3.0.0
Successfully installed argo-workflows-5.0.0 cloudpickle-2.2.0 dpgen2-0.0.8.dev84+g8733ff5 dpgui-1.0.0 fpop-0.0.7 jsonpickle-3.0.4 kubernetes-29.0.0 minio-7.2.5 pydflow-1.8.61 waitress-3.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: dpdata in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (0.2.17)
Collecting dpdata
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e8/22/d81cdd3fe3a936a705745730f2fbd2587f8bcb67ef7cca5ad4164a5a239c/dpdata-0.2.18-py3-none-any.whl (148 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.3/148.3 kB 5.2 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.14.3 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata) (1.26.4)
Requirement already satisfied: monty in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata) (2024.2.26)
Requirement already satisfied: scipy in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata) (1.12.0)
Requirement already satisfied: h5py in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata) (3.10.0)
Requirement already satisfied: wcmatch in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from dpdata) (8.5)
Requirement already satisfied: bracex>=2.1.1 in /opt/deepmd-kit-3.0.0/lib/python3.10/site-packages (from wcmatch->dpdata) (2.2.1)
Installing collected packages: dpdata
  Attempting uninstall: dpdata
    Found existing installation: dpdata 0.2.17
    Uninstalling dpdata-0.2.17:
      Successfully uninstalled dpdata-0.2.17
Successfully installed dpdata-0.2.18
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
代码
文本

This example provides pretrained model, the initial training data of water and PBE functional files required for VASP calculations in the dataset. Link them into the working directory.

代码
文本
[2]
!ln -s /bohr/dpa2-finetune-example-water-jbhv/v3/pretrained_model.pt pretrained_model.pt
!ln -s /bohr/dpa2-finetune-example-water-jbhv/v3/H2O-PBE0TS-MD/train train
!ln -s /bohr/dpa2-finetune-example-water-jbhv/v3/PBE PBE
代码
文本

First, we need initial training data. Then we prepare the initial configurations for MD exploration. Here we sample 100 configurations randomly from the training data.

代码
文本
[3]
import os
import random
import dpdata
from pathlib import Path

n_select = 100
m = dpdata.MultiSystems()

for f in Path("train").rglob("type.raw"):
sys = f.parent
mixed_type = len(list(sys.glob("*/real_atom_types.npy"))) > 0
if mixed_type:
m.load_systems_from_file(sys, fmt="deepmd/npy/mixed")
else:
s = dpdata.LabeledSystem(sys, fmt="deepmd/npy")
m.append(s)

m.to_deepmd_npy_mixed("train_mixed.tmp")
fs = os.listdir("train_mixed.tmp")
assert len(fs) == 1
os.rename(os.path.join("train_mixed.tmp", fs[0]), "train_mixed")
os.rmdir("train_mixed.tmp")

if m.get_nframes() <= n_select:
m.to_deepmd_npy_mixed("init")
else:
ratio = n_select / m.get_nframes()
new = dpdata.MultiSystems()
for s in m:
n = int(len(s)*ratio)
if random.random() < len(s)*ratio - n:
n += 1
if n > 0:
new.append(s.sub_system(random.sample(range(len(s)), n)))
new.to_deepmd_npy_mixed("init")
代码
文本

Below we will prepare the input file for DP-Gen2. You can specify a name for the workflow in the field name. By default, the workflow server https://workflows.deepmodeling.com is used. In bohrium_config, fill in your Bohrium username, password, and project ID. Specify init_data_sys with the list of system paths for the initial training data. The training, exploration and first-principle sections each require input file templates for DP, LAMMPS and VASP, which will be provided later. In train, paths of the pretrained models are required for init_models_paths. Here we provide 4 identical paths. In explore, configurations should be passed with the initial configuration files we just prepared. stages specifies the settings for MD simulations, n_sample determines how many configurations to sample from the initial configurations per iteration, and revisions specifies the values of the variables in the LAMMPS input file template. Each variable's value can be a list, and the final combinations are the Cartesian product of all lists. For more usage of parameters, please refer to the documentation at https://docs.deepmodeling.com/projects/dpgen2/en/latest/.

代码
文本
[5]
%%file input.json
{
"name": "water-dpgen",
"bohrium_config": {
"username": "<your-bohrium-username>",
"password": "<your-bohrium-password>",
"project_id": "<your-bohrium-project-id>",
"_comment": "all"
},
"default_step_config": {
"template_config": {
"image": "registry.dp.tech/dptech/prod-11881/dpgen2-utils:1.2",
"_comment": "all"
},
"_comment": "all"
},
"step_configs": {
"run_train_config": {
"template_config": {
"image": "registry.dp.tech/dptech/prod-11106/deepmd-kit:stable-0411",
"_comment": "all"
},
"executor": {
"type": "dispatcher",
"retry_on_submission_error": 10,
"image_pull_policy": "IfNotPresent",
"machine_dict": {
"batch_type": "Bohrium",
"context_type": "Bohrium",
"remote_profile": {
"input_data": {
"job_type": "container",
"platform": "ali",
"on_demand": 1,
"scass_type": "c12_m92_1 * NVIDIA V100"
}
}
}
},
"_comment": "all"
},
"run_explore_config": {
"template_config": {
"image": "registry.dp.tech/dptech/prod-11106/deepmd-v3-lammps:6ca3c",
"_comment": "all"
},
"continue_on_success_ratio": 0.8,
"executor": {
"type": "dispatcher",
"retry_on_submission_error": 10,
"image_pull_policy": "IfNotPresent",
"machine_dict": {
"batch_type": "Bohrium",
"context_type": "Bohrium",
"remote_profile": {
"input_data": {
"job_type": "container",
"platform": "ali",
"on_demand": 1,
"scass_type": "c12_m92_1 * NVIDIA V100"
}
}
}
},
"template_slice_config": {
"group_size": 1,
"pool_size": 1
},
"_comment": "all"
},
"run_fp_config": {
"template_config": {
"image": "registry.dp.tech/dptech/vasp:5.4.4",
"_comment": "all"
},
"continue_on_success_ratio": 0.8,
"executor": {
"type": "dispatcher",
"retry_on_submission_error": 10,
"image_pull_policy": "IfNotPresent",
"machine_dict": {
"batch_type": "Bohrium",
"context_type": "Bohrium",
"remote_profile": {
"input_data": {
"job_type": "container",
"platform": "ali",
"scass_type": "c8_m32_cpu"
}
}
}
},
"template_slice_config": {
"group_size": 1,
"pool_size": 1
},
"_comment": "all"
},
"_comment": "all"
},
"upload_python_packages": [
"/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpgen2",
"/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata"
],
"inputs": {
"type_map": [
"H",
"He",
"Li",
"Be",
"B",
"C",
"N",
"O",
"F",
"Ne",
"Na",
"Mg",
"Al",
"Si",
"P",
"S",
"Cl",
"Ar",
"K",
"Ca",
"Sc",
"Ti",
"V",
"Cr",
"Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
"Rb",
"Sr",
"Y",
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
"In",
"Sn",
"Sb",
"Te",
"I",
"Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
"Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
"Yb",
"Lu",
"Hf",
"Ta",
"W",
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
"At",
"Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U",
"Np",
"Pu",
"Am",
"Cm",
"Bk",
"Cf",
"Es",
"Fm",
"Md",
"No",
"Lr",
"Rf",
"Db",
"Sg",
"Bh",
"Hs",
"Mt",
"Ds",
"Rg",
"Cn",
"Nh",
"Fl",
"Mc",
"Lv",
"Ts",
"Og"
],
"mixed_type": true,
"do_finetune": true,
"mass_map": [
4.0,
4.0026,
6.94,
9.0122,
10.81,
12.011,
14.007,
15.999,
18.998,
20.18,
22.99,
24.305,
26.982,
28.0855,
30.974,
32.06,
35.45,
39.95,
39.098,
40.078,
44.956,
47.867,
50.942,
51.996,
54.938,
55.845,
58.933,
58.693,
63.546,
65.38,
69.723,
72.63,
74.922,
78.971,
79.904,
83.798,
85.468,
87.62,
88.906,
91.224,
92.906,
95.95,
97,
101.07,
102.91,
106.42,
107.87,
112.41,
114.82,
118.71,
121.76,
127.6,
126.9,
131.29,
132.91,
137.33,
138.91,
140.12,
140.91,
144.24,
145,
150.36,
151.96,
157.25,
158.93,
162.5,
164.93,
167.26,
168.93,
173.05,
174.97,
178.49,
180.95,
183.84,
186.21,
190.23,
192.22,
195.08,
196.97,
200.59,
204.38,
207.2,
208.98,
209,
210,
222,
223,
226,
227,
232.04,
231.04,
238.03,
237,
244,
243,
247,
247,
251,
252,
257,
258,
259,
262,
267,
268,
269,
270,
269,
277,
281,
282,
285,
286,
290,
290,
293,
294,
294
],
"init_data_prefix": null,
"init_data_sys": [
"train_mixed"
],
"_comment": "all"
},
"train": {
"type": "dp",
"numb_models": 4,
"init_models_paths": [
"pretrained_model.pt",
"pretrained_model.pt",
"pretrained_model.pt",
"pretrained_model.pt"
],
"config": {
"impl": "pytorch",
"finetune_args": "--model-branch H2O_H2O-PD",
"init_model_policy": "yes",
"init_model_old_ratio": 0.9,
"init_model_numb_steps": 100000,
"init_model_start_lr": 2e-05,
"init_model_start_pref_e": 0.25,
"init_model_start_pref_f": 100,
"_comment": "all"
},
"template_script": "train.json",
"_comment": "all"
},
"explore": {
"type": "lmp",
"config": {
"command": "lmp -var restart 0"
},
"convergence": {
"type": "adaptive-lower",
"conv_tolerance": 0.005,
"_numb_candi_f": 3000,
"rate_candi_f": 0.15,
"level_f_hi": 0.5,
"n_checked_steps": 8,
"_command": "all"
},
"max_numb_iter": 16,
"fatal_at_max": false,
"configuration_prefix": null,
"configurations": [
{
"type": "file",
"files": [
"init"
],
"fmt": "deepmd/npy/mixed"
}
],
"stages": [
[
{
"type": "lmp-template",
"lmp": "template.lammps",
"trj_freq": 200,
"revisions": {
"V_NSTEPS": [
1000
],
"V_TEMP": [
330
],
"V_DUMPFREQ": [
200
]
},
"sys_idx": [
0
],
"n_sample": 4
}
]
],
"_comment": "all"
},
"fp": {
"type": "vasp",
"task_max": 300,
"inputs_config": {
"pp_files": {
"O": "PBE/O/POTCAR",
"H": "PBE/H/POTCAR"
},
"incar": "INCAR",
"kspacing": 0.32,
"kgamma": true
},
"run_config": {
"command": "source /opt/intel/oneapi/setvars.sh && mpirun -n 16 vasp_std"
},
"_comment": "all"
}
}
Overwriting input.json
代码
文本

Here is a simple LAMMPS input template for NVT simulations, where the number of steps, temperature, and output frequency are provided as variables.

代码
文本
[6]
%%file template.lammps
variable NSTEPS equal V_NSTEPS
variable TEMP equal V_TEMP
variable THERMO_FREQ equal V_DUMPFREQ
variable TAU_T equal 0.100000

# Initialization
units metal
dimension 3
atom_style atomic
boundary p p p

read_data conf.lmp
mass 1 4.000
mass 2 4.003
mass 3 6.940
mass 4 9.012
mass 5 10.810
mass 6 12.011
mass 7 14.007
mass 8 15.999
mass 9 18.998
mass 10 20.180
mass 11 22.990
mass 12 24.305
mass 13 26.982
mass 14 28.085
mass 15 30.974
mass 16 32.060
mass 17 35.450
mass 18 39.950
mass 19 39.098
mass 20 40.078
mass 21 44.956
mass 22 47.867
mass 23 50.942
mass 24 51.996
mass 25 54.938
mass 26 55.845
mass 27 58.933
mass 28 58.693
mass 29 63.546
mass 30 65.380
mass 31 69.723
mass 32 72.630
mass 33 74.922
mass 34 78.971
mass 35 79.904
mass 36 83.798
mass 37 85.468
mass 38 87.620
mass 39 88.906
mass 40 91.224
mass 41 92.906
mass 42 95.950
mass 43 97.000
mass 44 101.070
mass 45 102.910
mass 46 106.420
mass 47 107.870
mass 48 112.410
mass 49 114.820
mass 50 118.710
mass 51 121.760
mass 52 127.600
mass 53 126.900
mass 54 131.290
mass 55 132.910
mass 56 137.330
mass 57 138.910
mass 58 140.120
mass 59 140.910
mass 60 144.240
mass 61 145.000
mass 62 150.360
mass 63 151.960
mass 64 157.250
mass 65 158.930
mass 66 162.500
mass 67 164.930
mass 68 167.260
mass 69 168.930
mass 70 173.050
mass 71 174.970
mass 72 178.490
mass 73 180.950
mass 74 183.840
mass 75 186.210
mass 76 190.230
mass 77 192.220
mass 78 195.080
mass 79 196.970
mass 80 200.590
mass 81 204.380
mass 82 207.200
mass 83 208.980
mass 84 209.000
mass 85 210.000
mass 86 222.000
mass 87 223.000
mass 88 226.000
mass 89 227.000
mass 90 232.040
mass 91 231.040
mass 92 238.030
mass 93 237.000
mass 94 244.000
mass 95 243.000
mass 96 247.000
mass 97 247.000
mass 98 251.000
mass 99 252.000
mass 100 257.000
mass 101 258.000
mass 102 259.000
mass 103 262.000
mass 104 267.000
mass 105 268.000
mass 106 269.000
mass 107 270.000
mass 108 269.000
mass 109 277.000
mass 110 281.000
mass 111 282.000
mass 112 285.000
mass 113 286.000
mass 114 290.000
mass 115 290.000
mass 116 293.000
mass 117 294.000
mass 118 294.000

# Interatomic potentials - DeepMD
pair_style deepmd
pair_coeff * *

timestep 0.001 # ps
velocity all create ${TEMP} 1815191 mom yes rot yes dist gaussian

run_style verlet
fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}
thermo_style custom step temp pe etotal press
thermo ${THERMO_FREQ} # Ouput thermodynamic properties
dump dpgen_dump
run ${NSTEPS}

Writing template.lammps
代码
文本

This is a DP training input template for DPA-2.

代码
文本
[7]
%%file train.json
{
"model": {
"type_map": [
"H",
"He",
"Li",
"Be",
"B",
"C",
"N",
"O",
"F",
"Ne",
"Na",
"Mg",
"Al",
"Si",
"P",
"S",
"Cl",
"Ar",
"K",
"Ca",
"Sc",
"Ti",
"V",
"Cr",
"Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
"Rb",
"Sr",
"Y",
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
"In",
"Sn",
"Sb",
"Te",
"I",
"Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
"Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
"Yb",
"Lu",
"Hf",
"Ta",
"W",
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
"At",
"Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U",
"Np",
"Pu",
"Am",
"Cm",
"Bk",
"Cf",
"Es",
"Fm",
"Md",
"No",
"Lr",
"Rf",
"Db",
"Sg",
"Bh",
"Hs",
"Mt",
"Ds",
"Rg",
"Cn",
"Nh",
"Fl",
"Mc",
"Lv",
"Ts",
"Og"
],
"descriptor": {
"type": "dpa2",
"tebd_dim": 8,
"repinit_rcut": 9.0,
"repinit_rcut_smth": 8.0,
"repinit_nsel": 120,
"repformer_rcut": 4.0,
"repformer_rcut_smth": 3.5,
"repformer_nsel": 40,
"repinit_neuron": [
25,
50,
100
],
"repinit_axis_neuron": 12,
"repinit_activation": "tanh",
"repformer_nlayers": 12,
"repformer_g1_dim": 128,
"repformer_g2_dim": 32,
"repformer_attn2_hidden": 32,
"repformer_attn2_nhead": 4,
"repformer_attn1_hidden": 128,
"repformer_attn1_nhead": 4,
"repformer_axis_dim": 4,
"repformer_update_h2": false,
"repformer_update_g1_has_conv": true,
"repformer_update_g1_has_grrg": true,
"repformer_update_g1_has_drrd": true,
"repformer_update_g1_has_attn": true,
"repformer_update_g2_has_g1g1": true,
"repformer_update_g2_has_attn": true,
"repformer_attn2_has_gate": true,
"repformer_add_type_ebd_to_seq": false
},
"fitting_net": {
"neuron": [
240,
240,
240
],
"resnet_dt": true,
"seed": 1,
"_comment": " that's all"
},
"_comment": " that's all"
},
"learning_rate": {
"type": "exp",
"decay_steps": 10,
"start_lr": 0.0002,
"stop_lr": 3.51e-08,
"_comment": "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,
"_comment": " that's all"
},
"training": {
"stat_file": "./dpa2",
"training_data": {
"systems": [],
"batch_size": 1,
"_comment": "that's all"
},
"validation_data": {
"systems": [],
"batch_size": 1,
"_comment": "that's all"
},
"numb_steps": 100000,
"warmup_steps": 0,
"gradient_max_norm": 5.0,
"seed": 10,
"disp_file": "lcurve.out",
"disp_freq": 100,
"save_freq": 2000,
"_comment": "that's all"
}
}
Writing train.json
代码
文本

Here is a VASP input template

代码
文本
[8]
%%file INCAR
PREC=A
ENCUT=600
ISYM=0
ALGO=fast
EDIFF=1.000000e-06
LREAL=A
NPAR=1
KPAR=1
NELMIN=4
ISIF=2
ISMEAR=1
SIGMA=1.000000
IBRION=-1
NSW=0
LWAVE=F
LCHARG=F
PSTRESS=0
KSPACING=0.160000
KGAMMA=.FALSE.
Writing INCAR
代码
文本

Finally, submit the DP-Gen workflow

代码
文本
[9]
!dpgen2 submit input.json
Workflow has been submitted (ID: water-dpgen-5mwgq, UID: 43c1bcb7-2d25-4612-8f72-cf84e6dbdf1f)
Workflow link: https://workflows.deepmodeling.com/workflows/argo/water-dpgen-5mwgq
代码
文本

The progress of the workflow can be tracked through the link printed above. The metrics for each iteration of DP-Gen can be obtained through the dpgen2 command line

代码
文本
[6]
!dpgen2 status input.json dpgen-j2z4w
WARNING:root:Exploration scheduler not found in the global outputs
WARNING:root:no scheduler is finished
代码
文本
DPA
DPA
已赞4
本文被以下合集收录
good notebooks collected by Taiping Hu
TaipingHu
更新于 2024-09-10
33 篇14 人关注
DPA2
zhiwei_wang
更新于 2024-09-09
5 篇0 人关注
推荐阅读
公开
Distillation of DPA-2 models
DPA
DPA
zjgemi
发布于 2023-12-19
4 赞12 转存文件2 评论
公开
DP-Gen2中使用cp2k计算fp任务
CP2KDP-GENDPA-2DeePMD-kitAI4S
CP2KDP-GENDPA-2DeePMD-kitAI4S
AndyX
更新于 2024-07-11
1 赞
评论
 %%file input.json { ...

zhb

04-24 08:04
dpgen2的fp什么时候可以支持cp2k

AndyX

07-08 22:19
回复 zhb 已经支持了,见:https://bohrium.dp.tech/notebooks/22458876824
评论