AIMNet2 wB97M-D3 是一种神经网络原子间势,在 wB97M-D3 泛函水平训练,用于快速
准确的分子模拟——输出能量、力、原子电荷、偶极矩、四极矩,适用于平衡结构
分子动力学(MD)、构象能量差等。模型包含 4 个集成成员用于不确定性估计,
并外接 D3BJ 色散校正(本模型 needs_dispersion: true,不可禁用)。
本仓库为昇腾 Model-Agent 模型适配大赛交付物,已将模型完整适配到 Ascend NPU
(Ascend-910 系列)推理,交付 inference.py 推理脚本、readme.md 部署说明与
requirements.txt 依赖清单。
| 项目 | 值 |
|---|---|
| 模型 | isayevlab/aimnet2-wb97m-d3(AIMNet2) |
| 任务 | 分子能量 / 力 / 原子电荷预测(神经网络原子间势) |
| 架构 | AIMNet2(原子环境向量 AEV + 消息传递 MLP + dipole/quadrupole 头),4 集成成员 |
| 参数量 | 约 2.2M/成员(ensemble_*.safetensors 各 8.8MB,4 成员共 34MB) |
| 参考方法 | wB97M-D3 / def2-TZVPP 水平,含 D3BJ 色散(s8=0.3908 a1=0.566 a2=3.128) |
| 元素范围 | H B C N O F Si P S Cl As Se Br I(14 种) |
| 能量单位 | eV(按元素偏移标度,约 -1100 eV;仅用于同原子组成几何间的能量差) |
| 原始仓库 | https://huggingface.co/isayevlab/aimnet2-wb97m-d3 |
aimnet(PyPI 包,含 nvalchemiops 邻居列表/DFTD3 与 warp 运行时)pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple/本机 Python 3.11 + torch 2.9.0+cpu + torch_npu 2.9.0.post1 实测通过。
原 aimnet 包中 nvalchemiops 的邻居列表与 DFTD3 内核均依赖 NVIDIA warp 运行时,
NPU 上无法直接运行。本适配在 inference.py 中自动应用三处修改(仅 NPU 设备生效,
CPU 行为不变):
neighbor_list 在非 CUDA 设备上强制走 warp
(Invalid device identifier: npu:0)→ 索引矩阵(不参与梯度)在 CPU 计算后搬回 NPU,
模型主体仍全量运行在 NPU;needs_dispersion: true(wB97M-D3 含 D3BJ 色散,
不可禁用),nvalchemiops 的 DFTD3 内核同样依赖 warp → 输入 detach 转 CPU 计算
后搬回 NPU,能量/力数值与 CPU 一致(实测能量差 <0.006 eV);mol_sizes 在 nse() 内就地 +=1/-1,在 NPU 上触发
autograd 版本冲突(modified by an inplace operation),改为 clone 后修改,
语义完全不变。# 默认用例:甲烷 CH4 单点 + 力,NPU 推理(自动应用 NPU 适配)
python3 inference.py --device npu:0
# 指定本地权重目录与输出文件
python3 inference.py --device npu:0 --weights-dir ./weights --output result.json
# CPU 推理(对比基线)
python3 inference.py --device cpu
# 4 个集成成员取平均(不确定性估计)
python3 inference.py --device npu:0 --ensemble-size 4
# 自定义分子(原子序数与坐标,单位 Å)
python3 inference.py --device npu:0 --numbers 6 1 1 1 1 \
--coord 0,0,0 1.089,0,0 -0.363,-1.026,0 -0.363,0.513,0.889 -0.363,0.513,-0.889权重目录不存在时,脚本会自动从 hf-mirror(或 GitCode 镜像兜底)下载
config.json 与 ensemble_0~3.safetensors。
| 项目 | CPU | NPU (npu:0) |
|---|---|---|
| 能量 energy (eV) | -1103.029512 | -1103.034854 |
| 力 forces (eV/Å) | 见 cpu_result.json | 见 npu_result.json |
| 原子电荷 charges (e) | 见 cpu_result.json | 见 npu_result.json |
| 单点推理耗时 | 0.083s | 0.433s |
| 数值有限性 finite_all | True | True |
4 成员集成(NPU):energy = -1103.037324 eV,finite_all = True,推理耗时 0.502s。
注:能量为按元素偏移标度(约 -1100 eV),仅用于同原子组成几何结构之间的 能量差(构象能量、反应能等),孤立的单点能量无物理意义;不可与其他 AIMNet2 系列 模型(如 aimnet2-rxn,~-0.5 eV 标度)混用比较。
coord(N×3 坐标,Å,float)+ numbers(N 原子序数,int)+ charge(净电荷,
本模型支持带电体系,默认 0)energy(eV)、forces(eV/Å,--forces 开启,默认开启)、charges(e,
部分原子电荷);集成模式(--ensemble-size>1)自动对多个成员取平均├── inference.py # 推理脚本(必选,含 NPU 适配)
├── readme.md # 部署说明文档(必选)
├── requirements.txt # 环境依赖清单
└── weights/ # 模型权重(config.json + ensemble_0~3.safetensors)@article{aimnet2,
title = {AIMNet2: A generalist neural network for molecular simulations},
author = {Zubatiuk, Roman and others},
journal = {Journal of Chemical Theory and Computation},
year = {2025}
}