​一、软件介绍

文末提供程序和源码下载

TorchMD-NET 提供最先进的神经网络电位 (NNP) 和训练它们的机制。如果有多个 NNP,它可提供高效、快速的实现,并且它集成在 GPU 加速的分子动力学代码中,如 ACEMD、OpenMM 和 TorchMD。TorchMD-NET 将其 NNP 公开为 PyTorch 模块。

二、Available architectures 可用的架构

  • Equivariant Transformer (ET)
  • 等变变压器 (ET)
  • Transformer (T) 变压器 (T)
  • Graph Neural Network (GN)
  • 图神经网络 (GN)
  • TensorNet 张量网

三、Installation 安装

TorchMD-Net 可用作 pip 可安装轮,也可用于 conda-forge

TorchMD-Net provides builds for CPU-only, CUDA 11.8 and CUDA 12.4. CPU versions are only provided as reference, as the performance will be extremely limited. Depending on which variant you wish to install, you can install it with one of the following commands:
TorchMD-Net 提供纯 CPU、CUDA 11.8 和 CUDA 12.4 的构建。CPU 版本仅供参考,因为性能将非常有限。根据您要安装的变体,您可以使用以下命令之一进行安装:

# The following will install the CUDA 12.4 version by default
pip install torchmd-net 
# The following will install the CUDA 11.8 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu118/simple
# The following will install the CUDA 12.4 version
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cu124 --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cu124/simple
# The following will install the CPU only version (not recommended)
pip install torchmd-net --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://us-central1-python.pkg.dev/pypi-packages-455608/cpu/simple   

Alternatively it can be installed with conda or mamba with one of the following commands. We recommend using Miniforge instead of anaconda.
或者,可以使用以下命令之一使用 conda 或 mamba 进行安装。我们建议使用 Miniforge 而不是 anaconda。

mamba install torchmd-net cuda-version=11.8
mamba install torchmd-net cuda-version=12.4

Install from source 从源码安装

TorchMD-Net is installed using pip, but you will need to install some dependencies before. Check this documentation page.
TorchMD-Net 是使用 pip 安装的,但您需要先安装一些依赖项。查看此文档页面。

四、Usage 用法

指定训练参数可以通过配置 yaml 文件或直接通过命令行参数完成。可以在 examples/ 中找到某些模型和数据集的架构和训练规范的几个示例。请注意,如果 yaml 文件和命令行中都存在参数,则命令行版本优先。可以通过设置 CUDA_VISIBLE_DEVICES 环境变量来选择 GPU。否则,该参数 --ngpus 可用于选择要训练的 GPU 数量(默认值 -1 使用所有可用的 GPU 或 中指定的 CUDA_VISIBLE_DEVICES GPU)。请记住,nvidia-smi 报告的 GPU ID 可能与 CUDA_VISIBLE_DEVICES 使用的 GPU ID 不同。
For example, to train the Equivariant Transformer on the QM9 dataset with the architectural and training hyperparameters described in the paper, one can run:
例如,要使用论文中描述的架构和训练超参数在 QM9 数据集上训练等变变换器,可以运行:

mkdir output
CUDA_VISIBLE_DEVICES=0 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml --log-dir output/

Run torchmd-train --help to see all available options and their descriptions.
Run (运行 torchmd-train --help ) 可查看所有可用选项及其描述。

Creating a new dataset 创建新数据集

If you want to train on custom data, first have a look at torchmdnet.datasets.Custom, which provides functionalities for loading a NumPy dataset consisting of atom types and coordinates, as well as energies, forces or both as the labels. Alternatively, you can implement a custom class according to the torch-geometric way of implementing a dataset. That is, derive the Dataset or InMemoryDataset class and implement the necessary functions (more info here). The dataset must return torch-geometric Data objects, containing at least the keys z (atom types) and pos (atomic coordinates), as well as y (label), neg_dy (negative derivative of the label w.r.t atom coordinates) or both.
如果您想使用自定义数据进行训练,请首先查看 torchmdnet.datasets.Custom ,它提供了加载由原子类型和坐标以及能量和/或力组成的 NumPy 数据集的功能。或者,您可以根据实现数据集的 torch-geometric 方式实现自定义类。也就是说,派生 Dataset or InMemoryDataset 类并实现必要的函数(更多信息在这里)。数据集必须返回 torch-geometric Data 对象,至少包含键 z (原子类型) 和 pos (原子坐标) 以及 y (标签) neg_dy (标签 w.r.t 原子坐标的负导数) 或两者。

Custom prior models 自定义先前模型

In addition to implementing a custom dataset class, it is also possible to add a custom prior model to the model. This can be done by implementing a new prior model class in torchmdnet.priors and adding the argument --prior-model <PriorModelName>. As an example, have a look at torchmdnet.priors.Atomref.
除了实现自定义数据集类之外,还可以向模型添加自定义先验模型。这可以通过在 中 torchmdnet.priors 实现一个新的先前模型类并添加参数 --prior-model <PriorModelName> 来完成。例如,请查看 torchmdnet.priors.Atomref 。

Multi-Node Training 多节点训练

In order to train models on multiple nodes some environment variables have to be set, which provide all necessary information to PyTorch Lightning. In the following we provide an example bash script to start training on two machines with two GPUs each. The script has to be started once on each node. Once torchmd-train is started on all nodes, a network connection between the nodes will be established using NCCL.
为了在多个节点上训练模型,必须设置一些环境变量,这些变量为 PyTorch Lightning 提供所有必要的信息。在下文中,我们提供了一个示例 bash 脚本,用于在两台每台机器上开始训练,每台机器有两个 GPU。该脚本必须在每个节点上启动一次。在所有节点上启动后 torchmd-train ,将使用 NCCL 在节点之间建立网络连接。

In addition to the environment variables the argument --num-nodes has to be specified with the number of nodes involved during training.
除了环境变量之外, --num-nodes 还必须指定参数以及训练期间涉及的节点数。

export NODE_RANK=0
export MASTER_ADDR=hostname1
export MASTER_PORT=12910mkdir -p output
CUDA_VISIBLE_DEVICES=0,1 torchmd-train --conf torchmd-net/examples/ET-QM9.yaml.yaml --num-nodes 2 --log-dir output/
  • NODE_RANK : Integer indicating the node index. Must be 0 for the main node and incremented by one for each additional node.
    NODE_RANK :表示节点索引的整数。必须用于 0 主节点,并且每增加一个节点,其增量为 1。
  • MASTER_ADDR : Hostname or IP address of the main node. The same for all involved nodes.
    MASTER_ADDR :主节点的主机名或 IP 地址。所有相关节点都是一样的。
  • MASTER_PORT : A free network port for communication between nodes. PyTorch Lightning suggests port 12910 as a default.
    MASTER_PORT :用于节点之间通信的空闲网络端口。PyTorch Lightning 建议将 port 12910 作为默认值。

Known Limitations 已知限制

  • Due to the way PyTorch Lightning calculates the number of required DDP processes, all nodes must use the same number of GPUs. Otherwise training will not start or crash.
    由于 PyTorch Lightning 计算所需 DDP 进程数量的方式,所有节点都必须使用相同数量的 GPU。否则,训练将无法开始或崩溃。
  • We observe a 50x decrease in performance when mixing nodes with different GPU architectures (tested with RTX 2080 Ti and RTX 3090).
    我们观察到,当混合使用具有不同 GPU 架构的节点时,性能下降了 50 倍(使用 RTX 2080 Ti 和 RTX 3090 测试)。
  • Some CUDA systems might hang during a multi-GPU parallel training. Try export NCCL_P2P_DISABLE=1, which disables direct peer to peer GPU communication.
    某些 CUDA 系统可能会在多 GPU 并行训练期间挂起。Try export NCCL_P2P_DISABLE=1 ,这将禁用直接的对等 GPU 通信。

Cite 引用

If you use TorchMD-NET in your research, please cite the following papers:
如果您在研究中使用 TorchMD-NET,请引用以下论文:

Main reference 主要参考
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@misc{pelaez2024torchmdnet,
title={TorchMD-Net 2.0: Fast Neural Network Potentials for Molecular Simulations}, 
author={Raul P. Pelaez and Guillem Simeon and Raimondas Galvelis and Antonio Mirarchi and Peter Eastman and Stefan Doerr and Philipp Thölke and Thomas E. Markland and Gianni De Fabritiis},
year={2024},
eprint={2402.17660},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
</code></span></span></span></span>
TensorNet 张量网
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@inproceedings{simeon2023tensornet,
title={TensorNet: Cartesian Tensor Representations for Efficient Learning of Molecular Potentials},
author={Guillem Simeon and Gianni De Fabritiis},
booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
year={2023},
url={https://openreview.net/forum?id=BEHlPdBZ2e}
}
</code></span></span></span></span>
Equivariant Transformer
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@inproceedings{
tholke2021equivariant,
title={Equivariant Transformers for Neural Network based Molecular Potentials},
author={Philipp Th{\"o}lke and Gianni De Fabritiis},
booktitle={International Conference on Learning Representations},
year={2022},
url={https://openreview.net/forum?id=zNHzqZ9wrRB}
}
</code></span></span></span></span>
Graph Network Graph 网络
<span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><span style="color:#1f2328"><span style="color:var(--fgColor-default, var(--color-fg-default))"><span style="background-color:var(--bgColor-muted, var(--color-canvas-subtle))"><code>@article{Majewski2023,title = {Machine learning coarse-grained potentials of protein thermodynamics},volume = {14},ISSN = {2041-1723},url = {http://dx.doi.org/10.1038/s41467-023-41343-1},DOI = {10.1038/s41467-023-41343-1},number = {1},journal = {Nature Communications},publisher = {Springer Science and Business Media LLC},author = {Majewski,  Maciej and Pérez,  Adrià and Th\"{o}lke,  Philipp and Doerr,  Stefan and Charron,  Nicholas E. and Giorgino,  Toni and Husic,  Brooke E. and Clementi,  Cecilia and Noé,  Frank and De Fabritiis,  Gianni},year = {2023},month = sep 
}
</code></span></span></span></span>

Developer guide 开发人员指南

Implementing a new architecture
实施新架构

To implement a new architecture, you need to follow these steps:
要实施新架构,您需要执行以下步骤:
1. Create a new class in torchmdnet.models that inherits from torch.nn.Model. Follow TorchMD_ET as a template. This is a minimum implementation of a model:
1. 在 中 torchmdnet.models 创建一个继承自 torch.nn.Model 的新类。以 TorchMD_ET 为模板。这是模型的最低实现:

class MyModule(nn.Module):def __init__(self, parameter1, parameter2):super(MyModule, self).__init__()# Define your model hereself.layer1 = nn.Linear(10, 10)...# Initialize your model parameters hereself.reset_parameters()def reset_parameters(self):# Initialize your model parameters herenn.init.xavier_uniform_(self.layer1.weight)...def forward(self,z: Tensor, # Atomic numbers, shape (n_atoms, 1)pos: Tensor, # Atomic positions, shape (n_atoms, 3)batch: Tensor, # Batch vector, shape (n_atoms, 1). All atoms in the same molecule have the same value and are contiguous.q: Optional[Tensor] = None, # Atomic charges, shape (n_atoms, 1)s: Optional[Tensor] = None, # Atomic spins, shape (n_atoms, 1)) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]:# Define your forward pass herescalar_features = ...vector_features = ...# Return the scalar and vector features, as well as the atomic numbers, positions and batch vectorreturn scalar_features, vector_features, z, pos, batch

2. Add the model to the __all__ list in torchmdnet.models.__init__.py. This will make the tests pick your model up.
2. 将模型添加到 中的 __all__ torchmdnet.models.__init__.py 列表中。这将使测试选取您的模型。
3. Tell models.model.create_model how to initialize your module by adding a new entry, for instance:
3. 通过添加新条目来告诉models.model.create_model如何初始化您的模块,例如:

    elif args["model"] == "mymodule":from torchmdnet.models.torchmd_mymodule import MyModuleis_equivariant = False # Set to True if your model is equivariantrepresentation_model = MyModule(parameter1=args["parameter1"],parameter2=args["parameter2"],**shared_args, # Arguments typically shared by all models)

4. Add any new parameters required to initialize your module to scripts.train.get_args. For instance:
4. 添加将模块初始化为 scripts.train.get_args 所需的任何新参数。例如:

  parser.add_argument('--parameter1', type=int, default=32, help='Parameter1 required by MyModule')...

5. Add an example configuration file to torchmd-net/examples that uses your model.
5. 添加一个使用您的模型 torchmd-net/examples 的示例配置文件。
6. Make tests use your configuration file by adding a case to tests.utils.load_example_args. For instance:
6. 通过向 tests.utils.load_example_args 添加 case 来使测试使用您的配置文件。例如:

if model_name == "mymodule":config_file = join(dirname(dirname(__file__)), "examples", "MyModule-QM9.yaml")

At this point, if your module is missing some feature the tests will let you know, and you can add it. If you add a new feature to the package, please add a test for it.
此时,如果您的模块缺少某些功能,测试会通知您,您可以添加它。如果您向包中添加了新功能,请为其添加测试。

Code style 代码样式

We use black. Please run black on your modified files before committing.
我们使用黑色。请在提交之前运行 black 您修改的文件。

Testing 测试

To run the tests, install the package and run pytest in the root directory of the repository. Tests are a good source of knowledge on how to use the different components of the package.
要运行测试,请安装软件包并在存储库的根目录中运行 pytest 。测试是有关如何使用包的不同组件的良好知识来源。

五、软件下载

夸克网盘分享

本文信息来源于GitHub作者地址:https://github.com/torchmd/torchmd-net

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/diannao/88058.shtml
繁体地址,请注明出处:http://hk.pswp.cn/diannao/88058.shtml
英文地址,请注明出处:http://en.pswp.cn/diannao/88058.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在Docker上安装Mongo及Redis-NOSQL数据库

应用环境 Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-139-generic x86_64) Docker version 28.1.1, build 4eba377 文章目录 一、部署Mongo1. 拉取容器镜像2. 生成Run脚本2.1 准备条件2.2 参数解读2.3 实例脚本 3. 实例操作3.1 Mongo bash控制台3.2 库表操作 4. MongoDB Compass (G…

Java 编程之责任链模式

一、什么是责任链模式&#xff1f; 责任链模式&#xff08;Chain of Responsibility Pattern&#xff09; 是一种行为型设计模式&#xff0c;它让多个对象都有机会处理请求&#xff0c;从而避免请求的发送者和接收者之间的耦合关系。将这些对象连成一条链&#xff0c;沿着这条…

1、做中学 | 一年级上期 Golang简介和安装环境

一、什么是golang Golang&#xff0c;通常简称 Go&#xff0c;是由 Google 公司的 Robert Griesemer、Rob Pike 和 Ken Thompson 于 2007 年创建的一种开源编程语言&#xff0c;并在 2009 年正式对外公布。 已经有了很多编程语言&#xff0c;为什么还要创建一种新的编程语言&…

Linux--迷宫探秘:从路径解析到存储哲学

上一篇博客我们说完了文件系统在硬件层面的意义&#xff0c;今天我们来说说文件系统在软件层是怎么管理的。 Linux--深入EXT2文件系统&#xff1a;数据是如何被组织、存储与访问的&#xff1f;-CSDN博客 &#x1f30c; 引言&#xff1a;文件系统的宇宙观 "在Linux的宇宙中…

淘宝商品数据实时获取方案|API 接口开发与安全接入

在电商数据获取领域&#xff0c;除了官方 API&#xff0c;第三方数据 API 接入也是高效获取淘宝商品数据的重要途径。第三方数据 API 凭借丰富的功能、灵活的服务&#xff0c;为企业和开发者提供了多样化的数据解决方案。本文将聚焦第三方数据 API 接入&#xff0c;详细介绍其优…

什么是防抖和节流?它们有什么区别?

文章目录 一、防抖&#xff08;Debounce&#xff09;1.1 什么是防抖&#xff1f;1.2 防抖的实现 二、节流&#xff08;Throttle&#xff09;2.1 什么是节流&#xff1f;2.2 节流的实现方式 三、防抖与节流的对比四、总结 在前端开发中&#xff0c;我们经常会遇到一些高频触发的…

Springboot集成阿里云OSS上传

Springboot集成阿里云OSS上传 API 接口描述 DEMO提供的四个API接口&#xff0c;支持不同方式的文件和 JSON 数据上传&#xff1a; 1. 普通文件上传接口 上传任意类型的文件 2. JSON 字符串上传接口 上传 JSON 字符串 3. 单个 JSON 压缩上传接口 上传并压缩 JSON 字符串…

删除大表数据注意事项

数据库是否会因删除操作卡死&#xff0c;没有固定的 “安全删除条数”&#xff0c;而是受数据库配置、表结构、操作方式、当前负载等多种因素影响。以下是关键影响因素及实践建议&#xff1a; 一、导致数据库卡死的核心因素 硬件与数据库配置 CPU / 内存瓶颈&#xff1a;删除…

Redis 是单线程模型?|得物技术

一、背景 使用过Redis的同学肯定都了解过一个说法&#xff0c;说Redis是单线程模型&#xff0c;那么实际情况是怎样的呢&#xff1f; 其实&#xff0c;我们常说Redis是单线程模型&#xff0c;是指Redis采用单线程的事件驱动模型&#xff0c;只有并且只会在一个主线程中执行Re…

[特殊字符] AIGC工具深度实战:GPT与通义灵码如何彻底重构企业开发流程

&#x1f50d; 第一模块&#xff1a;理念颠覆——为什么AIGC不是“玩具”而是“效能倍增器”&#xff1f; ▍企业开发的核心痛点图谱&#xff08;2025版&#xff09; ​​研发效能瓶颈​​&#xff1a;需求膨胀与交付时限矛盾持续尖锐&#xff0c;传统敏捷方法论已触天花板​…

(LeetCode 面试经典 150 题) 169. 多数元素(哈希表 || 二分查找)

题目&#xff1a;169. 多数元素 方法一&#xff1a;二分法&#xff0c;最坏的时间复杂度0(nlogn)&#xff0c;但平均0(n)即可。空间复杂度为0(1)。 C版本&#xff1a; int nnums.size();int l0,rn-1;while(l<r){int mid(lr)/2;int ans0;for(auto x:nums){if(xnums[mid]) a…

(17)java+ selenium->自动化测试-元素定位大法之By css上

1.简介 CSS定位方式和xpath定位方式基本相同,只是CSS定位表达式有其自己的格式。CSS定位方式拥有比xpath定位速度快,且比CSS稳定的特性。下面详细介绍CSS定位方式的使用方法。相对CSS来说,具有语法简单,定位速度快等优点。 2.CSS定位优势 CSS定位是平常使用过程中非常重要…

【软考高级系统架构论文】企业集成平台的技术与应用

论文真题 企业集成平台是一个支持复杂信息环境下信息系统开发、集成和协同运行的软件支撑环境。它基于各种企业经营业务的信息特征,在异构分布环境(操作系统、网络、数据库)下为应用提供一致的信息访问和交互手段,对其上运行的应用进行管理,为应用提供服务,并支持企业信息…

i.MX8MP LVDS 显示子系统全解析:设备树配置与 DRM 架构详解

&#x1f525; 推荐&#xff1a;《Yocto项目实战教程&#xff1a;高效定制嵌入式Linux系统》 京东正版促销&#xff0c;欢迎支持原创&#xff01; 链接&#xff1a;https://item.jd.com/15020438.html i.MX8MP LVDS 显示子系统全解析&#xff1a;设备树配置与 DRM 架构详解 在…

keep-alive实现原理及Vue2/Vue3对比分析

一、keep-alive基本概念 keep-alive是Vue的内置组件&#xff0c;用于缓存组件实例&#xff0c;避免重复渲染。它具有以下特点&#xff1a; 抽象组件&#xff1a;自身不会渲染DOM&#xff0c;也不会出现在父组件链中包裹动态组件&#xff1a;缓存不活动的组件实例&#xff0c;…

安卓jetpack compose学习笔记-Navigation基础学习

目录 一、Navigation 二、BottomNavigation Compose是一个偏向静态刷新的UI组件&#xff0c;如果不想要自己管理页面切换的复杂状态&#xff0c;可以以使用Navigation组件。 页面间的切换可以NavHost&#xff0c;使用底部页面切换栏&#xff0c;可以使用脚手架的bottomBarNav…

基于大数据技术的在UGC数据分析与路线推荐的研究

博主介绍&#xff1a;java高级开发&#xff0c;从事互联网行业六年&#xff0c;熟悉各种主流语言&#xff0c;精通java、python、php、爬虫、web开发&#xff0c;已经做了六年的毕业设计程序开发&#xff0c;开发过上千套毕业设计程序&#xff0c;没有什么华丽的语言&#xff0…

flask通过表单自动产生get请求的参数、form表单实现POST请求的自动提交

通过表单自动产生get请求的参数 相关代码如下&#xff1a; import flaskapp flask.Flask(__name__)app.route(/) def login():html <!DOCTYPE html><html lang"en"><head><meta charset"UTF-8"><title>flask表单实现get…

《情感反诈模拟器》2025学习版

1.2 专业内容支持 67篇情感诈骗案例研究14万字心理学分析资料783条专业配音对白 二、安装与运行 2.1 系统要求 最低配置&#xff1a; 显卡&#xff1a;GTX 1060CPU&#xff1a;i5-8400存储&#xff1a;25GB空间 2.2 运行步骤 解压游戏文件&#xff08;21.7GB&#xff09;…

预训练 vs. 微调:大模型落地的核心两步,究竟有何不同?

在人工智能领域&#xff0c;尤其是自然语言处理&#xff08;NLP&#xff09;和计算机视觉&#xff08;CV&#xff09;&#xff0c;大型模型如GPT系列、BERT、Stable Diffusion等取得了令人瞩目的成就。支撑这些模型广泛应用的关键技术流程&#xff0c;通常包含两个核心阶段&…