本仓库将 isayevlab/aimnet2-rxn —— 一个 用于有机反应建模的神经网络势 (Neural Network Potential) —— 适配并部署到华为昇腾 (Ascend) NPU 之上。模型能以接近 omegaB97M-V/def2-TZVPP 的精度预测沿反应坐标的能量、原子力、原子电荷、 分子偶极矩与四极矩, 支持键断裂/成键、过渡态和最低能量路径 (MEP) 搜索, 无需针对体系微调。
本项目为非 LLM 科学计算模型, 因此不依赖 vLLM-Ascend, 而是直接使用
torch_npu加载 权重在昇腾 NPU 上完成纯张量级推理。
1 kcal/mol, 反应能 1.6 kcal/mol, 能垒 2 kcal/mol(论文报道精度)。energy, forces (数值求导), charges, dipole, quadrupole。implemented_species=[1,6,7,8])。| 项 | 值 |
|---|---|
| 类型 | 神经网络势 (AIMNet2, 反应专用) |
| 参数量 | 2.206 M (单 member) |
| 输入 | 原子坐标 (Angstrom) + 原子序数 + 分子电荷 |
| 输出 | 能量 (eV)、力、电荷、偶极矩、四极矩 |
| 元素覆盖 | H, C, N, O |
| 集成数 | 4 (ensemble_0..3.safetensors) |
| 截止半径 | 5.0 Angstrom |
| 参考精度 | `1 kcal/mol (IRC/reaction energy) |
nb_mode=0 (full-pair einsum) 路径, 模型内部仅使用
einsum / index_select 等纯 PyTorch 算子, 完全绕开 warp/nvalchemiops。mode0 einsum 输出做 autograd 会触发 aclnnCat 存储格式
(NCL vs NCHW) 报错 (ERR00100), 故 forces 采用中心有限差分数值求导, 自包含且稳定。atomic_shift 的 float64 参考能精度。torch_npu 加载推理。| 部件 | 版本 |
|---|---|
| 硬件 | Ascend 910 系列 (>=1 卡) |
| CANN | 8.2+ (本仓验证于 8.5.1) |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| Python | 3.11+ |
| aimnet | >=0.2.0 |
| safetensors | 任意 |
| numpy | 1.26.x |
安装 (含华为镜像源):
source /usr/local/Ascend/ascend-toolkit/set_env.sh
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
pip install "aimnet>=0.2.0" safetensors numpy==1.26.4torch_npu 需与 PyTorch 版本配套安装 (参考华为版本配套表)。
仓库已内置 models/ (config.json + ensemble_0..3.safetensors)。
也可从 ModelScope 或 HF 镜像下拉:
python -c "
from huggingface_hub import snapshot_download
snapshot_download('isayevlab/aimnet2-rxn', local_dir='/opt/atomgit/models/aimnet2-rxn')
"python3 inference.py \
--model-dir /opt/atomgit/models/aimnet2-rxn \
--ensemble 0 \
--device npu:0 \
--coord '8 0 0 0.1173 1 0 0.7572 -0.4692 1 0 -0.7572 -0.4692' \
--forces默认 (无 --coord) 使用内置 H2O 示例。--forces 启用有限差分原子力。
| 指标 | CPU (对照) | Ascend NPU | 一致性 |
|---|---|---|---|
| E (eV) | 5.661770 | 5.695580 | abs diff 3.4e-2 |
| charges | -0.7016 | -0.7035 | cos 1.000000 |
| dipole | -0.4115 | -0.4126 | cos 1.000000 |
| 单轮耗时 | — | 4.28 ms | — |
| 参数量 | — | 2.206 M | — |
电荷/偶极在 CPU/NPU 完全一致 (cos=1.0); 能量绝对差 ~0.034 eV 源于昇腾将 double-precision 库仑能降为 float32, 远小于模型自身 ~1 kcal/mol 标称精度。
| 截图 | 说明 |
|---|---|
assets/agent_workflow.png | Agent 适配流程总览 |
assets/npu_device_call.png | NPU 设备调用 (torch_npu) |
assets/model_result.png | 推理结果 (H2O) |
截图由使用者自行上传。