

分子动力学模拟是理论化学、计算物理、分子生物学、材料科学等领域的基本研究方法,其中,对原子间势能函数的精确建模,一直是一个核心问题。深度势能(DP)等方法基于机器学习建模,实现了分子动力学模拟精度与速度的统一,在合金、半导体、电池材料、小分子等各个体系都有着广泛的应用。
然而,随着应用体系越来越复杂,在单一体系上从头生产数据、训练势函数的方式,其成本也越来越高,很大程度上阻碍了具体体系上的应用发展;另一方面,虽然有基于预训练模型的初步尝试来降低生产成本,其模型结构、生产范式迭代迅速,使用门槛也越来越高,用户也迫切需要使用更高效、自动化的势能函数生产方式,从而节省计算和操作成本。
为了更好地解决上述问题,我们推出了DP Combo APP,从机器学习操作平台(MLOps)和深度势能模型生命周期的角度,希望提供给用户一套自动化生产、评测、部署的系统。对于用户来说,可以一键使用DP系列最新模型方法和生产范式,根据不同的使用场景提供最优质的解决方案,从而加速解决具体体系的应用问题;对于开发者来说,可以让最新模型、生产范式以最快的速度上线,和用户使用无缝衔接,加速模型、产品迭代,从而进一步赋能微观模拟的上下游生态。
这篇notebook带大家体验和快速上手DP Combo APP。打开DP Combo APP的网页https://app.bohrium.dp.tech/dp-combo/ ,登陆自己的bohrium账号之后,首先可以看到一个下拉列表可以选择模式

- Train from scratch. 从头训练一个DP模型,即从已有的第一性原理标注的训练数据出发,训练一个可以直接用于DeePMD生产的模型。适用于已经有足够多的训练数据,可以得到精度满足要求的DP模型;或已有一些数据不确定够不够,尝试训一把看下精度效果。
- Finetune via training. 在DPA-2预训练模型上训练调优,获得的调优后的模型可以直接用于DeePMD生产的模型。适用于已有的数据量不足以从头训练一个DP模型,通过在预训练模型的基础上调优获得更高的精度。
- Finetune via DP-Gen. 在DPA-2预训练模型上通过DP-Gen数据生成器以迭代的方式调优,获得的调优后的模型可以直接用于DeePMD生产的模型。适用于仅有很少量的数据,通过边调优边标注的方式最小化所需的第一性原理的数据标注。
1. Train from scratch
首先要提供带标注的数据,其中训练数据必需,验证数据可选。文件需要tgz或zip格式的压缩包,数据的格式是deepmd/npy,对目录的层级无要求,应用会递归地搜索里面的体系。

DP-combo提供了样例数据,可以在Example Artifacts中找到

模型类型当前支持se_e2_a(光滑版的Deep Potential)和se_atten(DPA-1)

类型映射可以选择customize(自定义),或auto(自动生成)

其中自动生成可以选择all_elements(使用元素周期表序),或者auto_detect(从训练数据中自动检测出现的所有元素种类),类型映射影响最终得到的模型在生产时元素种类的对应关系,例如lammps输入文件中的类型顺序需要与模型的一致

此外提供了若干训练参数可以修改

如果以上参数修改不满足需求,可以在Train Config栏选择Custom Options,直接修改训练json文件

确认参数无误后即可点击next,最后点击submit提交,提交成功后会看到如下提示

可以点击Job Details跟踪任务详情。
任务进行中,可以在任务详情页底部实时查看学习曲线图

任务完成后,点击workspace中的outputs文件夹,可以获得任务的输出文件

其中graph.pb是输出的DP模型

2. Finetune via Training
数据上传同第1部分。上传数据后,需要选择一个分支作为调优的起点,默认是随机初始化的分支,选择与训练的目标体系尽量相近的分支能使调优更容易。这里用到的预训练模型是多个体系放在一起训练出来的一个模型,这个模型有一个多体系共享的descriptor(参数量最多的地方),以及后续各个体系自己的fitting net,这里选择的分支只是选择一个fitting net,也可以随机初始化这个fitting net,descriptor用的都是同一个

然后可以调整调优的训练参数

调优之后可以选择做蒸馏或不做,由于当前调优后的模型不能直接用于大规模生产,如果想获得一个能用于生产的模型,就需要做蒸馏。蒸馏的过程即使用教师模型作为标注器训练一个学生模型。蒸馏可调整的参数包括Distill Config(蒸馏的迭代过程的参数)、Train Config(学生模型的训练参数)和Lammps Config(MD采样的Lammps模板)。蒸馏完成后默认还会进行模型压缩,进一步提升模型在生产中的性能。

确认参数无误提交后首先进行模型调优,调优过程中可以在任务详情页看到类似第1部分的学习曲线图。调优结束后,若选择了做蒸馏,DP-Combo会提交一个工作流,可以在https://lbg-workflow-mlops.dp.tech/ 页面查看蒸馏工作流的进度

蒸馏工作流基于DP-Gen2项目,可以使用DP-Gen2的命令行工具查看蒸馏状态。这个过程需要本地安装dpgen2
Bohrium username: ········ Bohrium password: ········ Bohrium project_id: ········
100%|██████████| 1/1 [00:00<00:00, 5.55it/s] # stage id_stg. iter. accu. cand. fail. lvl_f_lo lvl_f_hi # Stage 0 -------------------- 0 0 0 0.8500 0.1496 0.0004 0.1357 0.5000 0 1 1 0.8250 0.1454 0.0296 0.0722 0.5000 0 2 2 0.6658 0.1173 0.2169 0.0638 0.5000 0 3 3 0.6200 0.1092 0.2708 0.0608 0.5000 0 4 4 0.6938 0.1223 0.1838 0.0577 0.5000 0 5 5 0.6981 0.1231 0.1788 0.0543 0.5000 0 6 6 0.7058 0.1242 0.1700 0.0510 0.5000 0 7 7 0.6635 0.1169 0.2196 0.0481 0.5000 0 8 8 0.6081 0.1069 0.2850 0.0469 0.5000
整个任务结束后,点击workspace中的outputs文件夹,可以获得任务的输出文件,其中包括调优后的模型model.pt,蒸馏后的模型distilled_model.pb,压缩后的模型compressed_model.pb

3. Finetune via DP-Gen
数据上传和调优的参数选择同第2部分。DP-Gen可调整的参数包括DP-Gen Config(DP-Gen迭代过程的参数)、Lammps Config(MD采样的Lammps模板)、VASP Config(第一性原理计算的VASP模板)。

DP-Gen完成之后同样可以选择做蒸馏或不做,如果做蒸馏,参数的选择同第2部分。
确认参数无误提交后首先会提交一个DP-Gen工作流,可以在https://lbg-workflow-mlops.dp.tech/ 页面查看工作流的进度。同样可以使用DP-Gen2的命令行工具查看蒸馏状态,同第2部分。如果做蒸馏,整个任务结束后,点击workspace中的outputs文件夹,可以获得任务的输出文件,其中包括调优后的模型model.pt,蒸馏后的模型distilled_model.pb,压缩后的模型compressed_model.pb








jianzhifu@vip.163.com
jianzhifu@vip.163.com