Design of xnn#
xnn is organized by model family, with everything shared in common:
src/xnn/
common/
data/ AtomicGraph, neighbor lists, AtomicDataset, hub/ (load_dataset)
featurizers/ Featurizer base, GaussianRBF, ExpNormalSmearing, CosineCutoff
config/ Config schema, YAML / argparse / Hydra loaders, key translation
models/ InteratomicPotential, registry, ForceStressOutput, les, d3, d4,
blocks (gated equivariant block), hub/ (from_pretrained),
fast (use_fast, AutoPolicy), compiled (torch.compile blocks),
dispersion_fast/ (GPU and CPU kernels)
finetune/ LoRA, multi-head replay, freezing, reference energies
train/ Trainer, losses, callbacks, loggers, captured CUDA-graph steps
benchmark/ scoring pre-trained models
deploy/ ASE calculator, TorchScript export, MDI engine
cli/ the xnn command
cpu_kernels.py Triton kernels as C++ / OpenMP loops on CPUs
gnn/
featurizers/ spherical harmonics, Cartesian monomials, Bessel, spherical Bessel, polynomial cutoff
models/ schnet, dimenet, gemnet, painn, tensornet, qet, megnet, nequip, mace, allegro, cace,
aimnet2 (+ foundation loaders)
fast/ Triton kernels; cuEquivariance for MACE and NequIP
cnn/
featurizers/ voxel grids and spherical signals of the atomic environment
models/ steerable (SE(3) CNN), cnn3d, spherical (S^2 / SO(3) correlations)
dnn/
common/ RuNNer model files (input.nn, weights, scaling)
featurizers/ atom-centered symmetry functions, AEV
models/ hdnnp (1G to 4G), ani, physnet, qrnn
ffnn/
common/ .frc force-field reader, SMARTS atom typing
data/ the shipped .frc files
models/ reaxff, opls, dreiding, amber, charmm, amoeba (AMOEBA, HIPPO),
topology, MD steppers, fused kernels
sqmnn/
common/ MOPAC EXTERNAL reader/writer, published values (downloaded), element data
models/ nddo (SCF, integrals), pm3, pm6, pm6-org, pm7
trfnn/
models/ et (the TorchMD-Net equivariant transformer), equiformer, equiformer_v2
fast/ fused attention kernels, compiled transformer blocks
attention.py edge multi-head attention
hybnn/
featurizers/ exponential Bernstein radial basis
models/ bamboo, spookynet
Four ideas hold it together.
One data object. Every model takes an
AtomicGraphand returns{"node_energy", "energy"}. Periodicity lives only in the edge vectors, \(\mathbf{r}_{ij} = \mathbf{r}_j - \mathbf{r}_i + \mathbf{s}_{ij} \cdot \mathbf{h}\), so molecules and crystals look the same to a model and forces and stress stay differentiable.Featurizers are first-class. Descriptors and equivariant edge features are standalone
Featurizermodules that models compose and you can inspect on their own.Physics in wrappers.
ForceStressOutputdifferentiates any model’s energy for forces and stress; models never implement them. Long-range electrostatics (LES) and dispersion (D3, D4) wrap any model the same way. Fast paths sit inside a model next to its reference code, on the same parameters, anduse_fastchooses between them.One config, one registry.
@register_modelplusfrom_configexpose a model to the YAML, argparse and Hydra frontends, which all fill oneConfig. Datasets and pre-trained models register the same way behindload_dataset()andfrom_pretrained().