xnn#

Machine-Learning Interatomic Potentials in PyTorch#

xnn is a library of machine-learning interatomic potentials (MLIPs) for molecules and materials.

The x in xnn stands for the architecture family: graph neural networks (gnn), dense neural networks (dnn), convolutional neural networks on voxel grids (cnn), classical force field neural networks (ffnn), semiempirical quantum mechanics (sqmnn), transformers (trfnn), hybrid models (hybnn) and kernel-based models (krnn). Every model is implemented using the same PyTorch nn.Module interface. Thus, one data object, one trainer and one deployment path serve all model families.

Why xnn?#

xnn offers several benefits out-of-the-box:

  • Faithful implementations. Each model reproduces its reference code or paper to float32 and float64 round-off errors, verified block by block (Model Fidelity to Upstream Codes). Model support rates their speed against the upstream codes.

  • Classical force fields and semiempirical methods, modernized. ReaxFF, OPLS, DREIDING, AMBER, CHARMM, AMOEBA, HIPPO, GFN-FF, PM3 / PM6 / PM6-ORG / PM7 and GFN0-xTB / GFN1-xTB / GFN2-xTB use the same PyTorch interface as the MLIPs, so they train (reparameterize), evaluate and deploy the same way, on CPU or GPU.

  • One pipeline. Shared data object, config schema, trainer and deployment to ASE, LAMMPS and the MolSSI Driver Interface.

  • Access pre-trained models and benchmark data in one line. from_pretrained() loads the MACE and AIMNet2 foundation models and your own checkpoints; load_dataset() downloads and converts standard datasets into ML-ready formats.

  • Fine-tuning, benchmarking and multi-GPU training from a config file and the xnn command.

  • Physics add-ons for any model. Latent Ewald long-range electrostatics and D3 / D4 dispersion can be added to any short-range model.

  • Fast paths. Fused GPU kernels, compiled blocks, CUDA graphs and CPU kernels give the reference’s numbers and derivatives faster. use_fast="auto" takes them where they win, for evaluation and training.

Getting Started

Installing xnn and a first training run

To the Getting Started Guide

How-To Guides

Recipes for accomplishing common tasks

To the How-To Guides

Examples

Executed example notebooks, rendered with their outputs

To the Examples

User Guide

Reference information for using xnn

To the User Guide

Developer Guide

Extending xnn with new models and featurizers

To the Developer Guide

Background Information

The design of xnn and the models it implements

To the Background Information

API Reference

Documentation of the xnn Python API

To the API Reference

Equivariant GNNs with e3nn

A hands-on course for developing equivariant GNN interatomic potentials

To the Equivariant GNN Course

Models at a glance#

Family

Models

Graph neural networks (gnn)

MACE, NequIP, Allegro, CACE, AIMNet2, SchNet, DimeNet, DimeNet++, GemNet, PaiNN, TensorNet, QET, MEGNet (single- and multi-fidelity) and CGCNN (property models)

Dense neural networks (dnn)

ANI (ANI-1, ANI-1x, ANI-1ccx, ANI-2x), PhysNet, HDNNP (generations 1 to 4), QRNN

Convolutional neural networks (cnn)

SE(3) steerable CNN, 3D CNN, spherical CNN

Classical force fields (ffnn)

ReaxFF / ReaxFF-nn, OPLS-AA / L-OPLS, DREIDING / X6, AMBER (ff94), CHARMM22, AMOEBA, HIPPO, GFN-FF

Semi-empirical quantum mechanics (sqmnn)

PM3, PM6, PM6-ORG, PM7, GFN0-xTB, GFN1-xTB, GFN2-xTB, DFTB1, DFTB2 (SCC-DFTB), DFTB3

Transformer neural networks (trfnn)

ET (the TorchMD-Net equivariant transformer), Equiformer, EquiformerV2

Hybrid neural networks (hybnn)

BAMBOO, SpookyNet, ByteFF, ByteFF-Pol

Kernel-based neural networks (krnn)

GDML, sGDML

Add-ons for any model (common)

LES long-range electrostatics, D3 and D4 dispersion

Each model matches its reference code or paper to round-off (Model Fidelity to Upstream Codes); the MACE and AIMNet2 foundation models load through the hub. Every potential trains, evaluates and runs under ASE deployment interface. MEGNet and CGCNN predict a property per structure instead of an energy surface. SchNet, DimeNet, GemNet, PaiNN, TensorNet, QET, ET, Equiformer, EquiformerV2, SpookyNet, BAMBOO, NequIP, MACE, Allegro, CACE, AIMNet2, ANI, PhysNet, HDNNP, QRNN and PM3 / PM6 / PM6-ORG / PM7 also export to TorchScript for LAMMPS. OPLS, AMBER, CHARMM, DREIDING, classical ReaxFF, AMOEBA and HIPPO deploy as LAMMPS inputs. Any checkpoint can also serve as an MDI engine (Deployment).

xnn is developed by Mohammad Mostafanejad at The Molecular Sciences Software Institute (MolSSI). Visit the GitHub repository for the latest updates.