Run the Example Notebooks#
The notebooks live under the notebooks/ folder and cover training,
fine-tuning, deployment and verification of every xnn model. The notebooks
are committed with their outputs and rendered in Examples, so you can
read them there first. This page is about running them on your own machine.
Launching the examples#
You can run the notebooks in a Python environment with xnn and the examples
extra dependency installed. The following command installs the extra dependency
and launches a Jupyter Lab server in the notebooks/ folder. The notebooks
will run in the environment where xnn is installed, so you can use your own
Python environment or a virtual one.
pip install -e ".[examples]"
jupyter lab notebooks/
Every training and MD notebook loads its data through the data hub (Download an Upstream Dataset). The argon dataset is bundled with the repository. Other datasets are downloaded and cached on their first use.
What is where?#
The three folders under notebooks/ follow the package layout, one
<family>/<model>/ folder per model, so the notebooks of a model sit at
matching paths:
notebooks/
examples/ training, MD, paper reproductions, tutorials
common/ data, models (hubs), deploy, benchmark, d3, d4, les
gnn/ dnn/ cnn/ ffnn/ hybnn/ sqmnn/ trfnn/
fidelity_checks/ each model against its reference code, block by block
common/ gnn/ dnn/ cnn/ ffnn/ hybnn/ sqmnn/ trfnn/
parity_checks/ the fast paths against the reference implementation
common/dispersion/ gnn/mace/ gnn/schnet/ gnn/painn/
For example, MACE has examples/gnn/mace/, fidelity_checks/gnn/mace/ and
parity_checks/gnn/mace/. In examples/:
common/dataandcommon/modelshold the data hub and model hub tutorials.gnn/<model>:MACE, NequIP, Allegro and CACE offer a train/test notebook and an argon NPT density notebook, each compares the performance of the model against the reference code.
MACE and AIMNet2 add their foundation models to the experiments, and MACE provides a fine-tuning notebook.
SchNet trains on rMD17, then runs a NVE dynamics.
DimeNet checks its performance against the tests in its original paper and trains on rMD17 while comparing its results against those of SchNet.
GemNet attempts to reproduce some of the experiments in its original paper and trains GemNet-T, -Q and -dT on the rMD17 data.
PaiNN checks its paper, reproduces its MD17 tables, the ferrocene rotation profiles and the ethanol IR and Raman spectra.
TensorNet checks its paper, trains on rMD17 aspirin, and compares its 0, 1 and 2 layer models with ET on a QM9 subset (TorchMD-Net 2.0 Table 1).
trfnn/etchecks the ET paper (sizes, attention weights, the cutoff fix of TorchMD-Net 2.0) and trains ET on rMD17 aspirin.trfnn/equiformerchecks the Equiformer paper (sizes, reflections, the attention variants) and trains Equiformer on rMD17 aspirin.trfnn/equiformer_v2checks the EquiformerV2 paper (sizes, edge frames, sphere sampling, liquid argon), compares Equiformer and EquiformerV2 on a QM9 subset, and trains EquiformerV2 on OC20 S2EF.cnn/se3cnnprovides the Tetris experiment of the SE(3) steerable CNN paper, then compares its performance against that of conventional 3D CNN potentials, trained on rMD17 under rotations.cnn/s2cnnfocuses on the QM7 atomization-energy experiment of the spherical CNN paper.dnncontains:the ANI experiments (training on rMD17 and the four published ANI datasets),
the PhysNet experiments and comparing the performance of the trained model against that in the original manuscript, and
the HDNNP generations (paper experiment checks, comparing the performance of 1G against 2G on rMD17, and attempting to reproduce the 2G / 3G / 4G benchmarks of the fourth-generation paper).
hybnnfocuses on:experiments involving BAMBOO charges and electrostatics,
reproducing experiments in the SpookyNet paper and reproducing its electronic-state, nonlocal and charge-transfer examples as well as MD17 dataset training.
ffnninvolves ReaxFF, OPLS, DREIDING, AMBER, CHARMM, AMOEBA and HIPPO trainings, refits, conformational energetics, water cluster energetics and normal modes.sqmnn/nddoreproduces the PM3, PM6, PM6-ORG and PM7 papers and refits the NDDO parameters.common/d3andcommon/d4hold the D3 and D4 paper experiment reproductions, benchmarks and a large-system study.common/lescreates long-range binding curves for charged and polar dimers.common/benchmarkscores four models on the argon dataset with one config file, andcommon/deployserves a checkpoint as an MDI engine, driven from Python and from LAMMPS.
Extra requirements#
Most notebooks run with the examples extra. The exceptions are:
The
cace_verificationandexamples/gnn/cace/*notebooks. You need to run:pip install git+https://github.com/BingqingCheng/cace
to have the CACE reference code installed.
The
schnet_verificationandpainn_verificationnotebooks needschnetpack. Thegemnet_verification,torchmdnet_verification,equiformer_verification,fairchem_verification,spookynet_verification,se3cnn_verificationands2cnn_verificationnotebooks need their reference codes installed. Thedimenet_verificationnotebook needs TensorFlow. Thehdnnp_verificationnotebook runs RuNNer, named byXNN_RUNNER. Thesqmnn_verificationnotebook runs MOPAC, named byXNN_MOPAC.The
parity_checksnotebooks need a CUDA GPU. Themace_cueq_paritynotebook also needs the cuEquivariance packages (see Run Models on Fused GPU Kernels).The
ani_verificationnotebook which requires the installation ofaniextra dependency.The
aimnet2_verificationnotebook. You should runpip install aimnet
in a separate environment (it needs torch 2.8 or newer).
The
examples/dnn/physnet/*andphysnet_verificationnotebooks require an environment with both TensorFlow and torch installed. The original PhysNet is cloned on demand.The
opls_verificationnotebooks uses theoplsextra dependency (and OpenMM).The
amber_verificationnotebook needs the LAMMPS Python module (import lammps, with the MOLECULE and EXTRA-MOLECULE packages); its comparison with the AMBER programs runs whentleapandsanderare on the path (or reachable through a wrapper script named byXNN_AMBER_WRAPPER) and is skipped otherwise.The
charmm_verificationnotebook needs the LAMMPS Python module too; its comparison withpsfgenand NAMD runs when VMD (text mode) and NAMD are reachable through the wrapper scripts named byXNN_VMD_WRAPPERandXNN_NAMD_WRAPPERand the CHARMM files byXNN_CHARMM_TOPPAR, and is skipped otherwise. Thecharmm_backbone_energeticsnotebook uses scipy.The
amoeba_verificationandhippo_verificationnotebooks compare with Tinker when itsanalyzeandtestgradprograms are on the path, and with the LAMMPS AMOEBA package when thelammpsPython module (with the AMOEBA package) is importable andXNN_TINKER2LMPnames thetinker2lmp.pyconverter of the LAMMPS distribution; each comparison is skipped otherwise. The AMOEBA protein example uses RDKit.The
examples/common/d4/*andd4_verificationnotebooks use thed4extra dependency. The paper examples also need RDKit (in theexamplesextra). The large-scale experiment notebook requires thevesinextra dependency to be able to calculate the neighborlists efficiently and a GPU with tens of GBs of memory.The
examples/common/d3/*andd3_verificationnotebooks use thed3extra dependency.The
examples/common/deploy/mdi_argon_mdnotebook uses themdiextra dependency. Themdi_argon_lammpsnotebook also needs a LAMMPS installation, built with the MDI package, found aslmponPATHor throughXNN_LMPenvironment variables.
Important notes#
The
schnet_ethanol_mdexample notebook loads the checkpoint written by theschnet_rmd17_trainnotebook. You need to run the latter notebook first to generate the checkpoint.The MDI library initializes once per process. So, you should restart the kernel before re-running
mdi_argon_md.The D4 notebooks import
dftd4beforetorch. The wheel’s OpenMP runtime returns wrong charges once torch’s thread pool is active.