Equivariant Networks for 3D Geometry
Rotation-equivariant message passing for molecules, materials and proteins.
Rotate a water molecule and its energy does not change, but the forces on its atoms rotate with it. Every regularity a model learns from molecules, materials or proteins carries this symmetry of space, and networks can be built to respect it exactly instead of learning it approximately from data. This lesson builds them, from invariant models on distances and angles to EGNN's equivariant coordinate updates and the spherical-harmonic tensor products of NequIP and MACE, and then weighs exact equivariance against scale, a question AlphaFold 3 reopened.
What you’ll learn
- Define the Euclidean group E(3) and its action on point clouds, and prove that the force field of an invariant energy is automatically equivariant.
- Describe invariant networks on distances and angles (SchNet, DimeNet) and what invariant message passing provably cannot detect.
- Prove that EGNN's coordinate update is E(n)-equivariant, and implement and test it numerically.
- Explain irreducible representations, spherical harmonics and Clebsch–Gordan tensor products, how tensor field networks, NequIP and MACE use them, and what they cost.
- Describe what AlphaFold 2, equivariant diffusion and RFdiffusion report, and weigh exact equivariance against learning the symmetry at scale.
The symmetry group of space
Write and . Invariance holds for every , so differentiate both sides with respect to ; by the chain rule the left side picks up a factor :
Multiply by , using . The translation has dropped out entirely:
A model therefore only needs an invariant energy: forces computed by automatic differentiation are equivariant for free and, being a gradient, conserve energy in a molecular dynamics simulation. SchNet was trained on energies and forces in exactly this way (Schütt et al., 2017).
E(3) includes reflections, so an E(3)-invariant model gives a molecule and its mirror image identical outputs. That is right for the energy of an isolated molecule, which is the same for both mirror images; a property that tells mirror-image molecules apart needs a model invariant under SE(3) only.
Think first Why not train an ordinary network on randomly rotated copies of each molecule instead?
You can, and it works better than one might expect, as the last step shows. But augmentation teaches the symmetry only approximately and only where the data reach, it costs extra training, and the learned energy is then only approximately invariant, so its forces are only approximately equivariant. An equivariant network satisfies the symmetry exactly for every input, and each training example informs the model about all of its rotated copies at once, which saves data. A Theory of Data Augmentation compares the two approaches in general, and Rotation-Equivariant & Steerable CNNs builds the 2D version for images.
Invariant networks: distances and angles
The simplest route to invariance is to feed the network only invariant quantities. SchNet (Schütt et al., 2017) weights its messages by learned functions of interatomic distance, a continuous-filter convolution , whose filter network sees each distance expanded in Gaussians with centers every 0.1 Å from 0 to 30 Å. Distances are unchanged by rotations, reflections and translations, so the network is invariant, and it pools atomwise energies into the total.
Distances alone miss angles, which chemistry needs: classical force fields have explicit angle terms. DimeNet (Gasteiger, Groß & Günnemann, 2020) embeds messages on directed edges, for , and updates each one from the messages arriving at , combined with the angle through a joint basis of spherical Bessel functions and spherical harmonics. Distances and angles are still invariant. In the authors' experiments DimeNet improved on earlier GNNs by 76% on average on MD17 and by 31% on QM9.
Even the local description has a gap. It was widely believed that the distances and angles around an atom, its 3-body descriptors, specify its environment up to rotation and permutation. Pozdnyakov et al. (2020) constructed counterexamples: distinct environments with identical 3-body and even 4-body features, which every model built on those features must treat as the same. Writing a total energy as a sum of many atom-centered contributions mitigates the problem but does not remove it.
A model predicts each atom's force as , a 3-vector. What is wrong with it?
- Nothing: distances are invariant, so the forces come out right
- Its output is invariant, so it cannot rotate with the molecule: a rotated input gives the same force vectors, which is wrong for vectors
- Distances are not invariant under translations
- The MLP makes the model non-differentiable
Show the answer
B. Its output is invariant, so it cannot rotate with the molecule: a rotated input gives the same force vectors, which is wrong for vectors
Invariant inputs give invariant outputs, but a force must turn with the molecule, . The two standard fixes are to predict an invariant energy and differentiate it, or to build vector outputs from relative positions, as EGNN does next.
Equivariant message passing with vectors: EGNN
To output vectors, or to let geometric information travel beyond one hop, the layers must carry quantities that rotate with the input. EGNN (Satorras, Hoogeboom & Welling, 2021) does it with relative positions alone. Each node carries invariant features and a position , which can live in any dimension, hence the name E(n), and a layer computes:
Squared distances are unchanged, , so every message, and with it every new feature vector, is invariant:
Differences of positions lose the translation and rotate with , while the weights are invariant scalars:
The sums run over all with shared functions, so permuting the nodes permutes the outputs. Layers compose, and an invariant readout of the , or the final positions themselves, give invariant or equivariant predictions as needed.
import torch
import torch.nn as nn
class EGNNLayer(nn.Module):
def __init__(self, d, m=32):
super().__init__()
self.phi_e = nn.Sequential(nn.Linear(2 * d + 1, m), nn.SiLU(), nn.Linear(m, m), nn.SiLU())
self.phi_x = nn.Linear(m, 1)
self.phi_h = nn.Sequential(nn.Linear(d + m, m), nn.SiLU(), nn.Linear(m, d))
def forward(self, h, x): # h: (n, d) invariant features, x: (n, 3) positions
n = h.size(0)
diff = x[:, None] - x[None, :] # x_i - x_j, shape (n, n, 3)
d2 = (diff ** 2).sum(-1, keepdim=True) # squared distances: invariant
pair = torch.cat([h[:, None].expand(n, n, -1), h[None].expand(n, n, -1), d2], -1)
m_ij = self.phi_e(pair) * (1 - torch.eye(n))[..., None] # messages, j != i
x = x + (diff * self.phi_x(m_ij)).sum(1) / (n - 1) # coordinate update
h = self.phi_h(torch.cat([h, m_ij.sum(1)], -1)) # feature update
return h, x
layer = EGNNLayer(d=8)
h, x = torch.randn(5, 8), torch.randn(5, 3)
Q, _ = torch.linalg.qr(torch.randn(3, 3)) # random orthogonal matrix
t = torch.randn(3)
h1, x1 = layer(h, x @ Q.T + t) # transform, then apply the layer
h2, x2 = layer(h, x) # apply the layer, then transform
print((h1 - h2).abs().max(), (x1 - (x2 @ Q.T + t)).abs().max()) # both below 1e-6An EGNN layer on a fully connected point cloud, with the equivariance test as a few lines of code: transforming and then applying the layer agrees with applying and then transforming, up to float32 rounding. The same test with a permutation of the points checks permutation equivariance.
EGNN costs little more than an ordinary GNN, since it uses only scalars and vectors. What it cannot build directly are features that transform like higher-order tensors, such as the five components of a quadrupole moment. Those need the representation theory of the rotation group.
Higher-order features: spherical harmonics and tensor products
In the plane, Rotation-Equivariant & Steerable CNNs described how features rotate by phases . In three dimensions the rotation group SO(3) is not commutative, and its irreducible representations are matrices: for each degree there is a -dimensional one, given by the Wigner matrices . A feature of degree is a list of numbers that rotates by : scalars for , ordinary 3-vectors for , symmetric traceless matrices (5 numbers) for . The real spherical harmonics turn a direction into a degree- feature, , with .
The tensor product of features of degrees and is again equivariant, and it splits into irreducible pieces of every degree from to , extracted with fixed Clebsch–Gordan coefficients. The dimensions agree:
Two vectors (, 9 numbers) give a scalar, a vector and a degree-2 tensor, : the dot product, the cross product (the antisymmetric part) and the symmetric traceless part of the outer product:
A tensor field network layer (Thomas et al., 2018) convolves with filters , a learned radial function times a spherical harmonic, and couples filter and input features by this rule into outputs of degree . Both factors are equivariant, and so is the layer:
A feature stores one copy of every degree . How many numbers is that?
Show the answer
16
for : one scalar, 3 vector components, 5 numbers of degree 2 and 7 of degree 3. The size grows only quadratically with , but a full tensor product between two such features grows much faster, as the next paragraph explains.
NequIP (Batzner et al., 2022) built interatomic potentials from such E(3)-equivariant convolutions and reported state-of-the-art accuracy with remarkable data efficiency, outperforming existing models with up to three orders of magnitude fewer training data. MACE (Batatia, Kovács, Simm, Ortner & Csányi, 2022) attacked the cost of depth. Standard message passing sends two-body messages, so many-body interactions have to be assembled over many layers; MACE expands each message in body order, coupling products of neighborhood features with generalized Clebsch–Gordan coefficients in the spirit of the atomic cluster expansion. With four-body messages it needs only two message-passing layers, and it reached or exceeded the state of the art on its benchmarks.
The price is computation. A full Clebsch–Gordan product between features up to degree costs . eSCN (Passaro & Zitnick, 2023) rotates each edge onto a fixed axis, where the product becomes a set of SO(2) operations, and cuts the cost to .
| Model | What moves between atoms | Equivariant hidden features | Notable result |
|---|---|---|---|
| SchNet (2017) | messages weighted by functions of distance | none (invariant) | continuous filters; energy-conserving forces by differentiation |
| DimeNet (2020) | directed-edge messages with angles | none (invariant) | angular information; large gains on MD17 and QM9 |
| EGNN (2021) | invariant messages plus position updates | vectors (positions) | E(n)-equivariant at GNN cost |
| Tensor field networks, NequIP (2018, 2022) | Clebsch–Gordan products of spherical-harmonic filters and features | all degrees up to | data efficiency of interatomic potentials |
| MACE (2022) | many-body messages built from products of neighborhood features | all degrees up to | two layers suffice with four-body messages |
Proteins, generative models and the equivariance debate
Proteins brought these ideas to their largest stage. AlphaFold 2 (Jumper et al., 2021) treats the entries of its pair representation as directed edges between residues and views structure prediction as "a graph inference problem in 3D space". Its structure module represents each residue as a rigid body, a "residue gas" of frames, and updates them with invariant point attention: queries, keys and values are augmented with 3D points produced in each residue's local frame, affinities use squared distances between those points, and coordinate transformations make the module invariant to the global frame; an equivariant update then moves the frames.
Equivariance also shapes generative models. The E(3)-equivariant diffusion model of Hoogeboom, Satorras, Vignac & Welling (2022) denoises atom coordinates and atom types jointly with an EGNN. Because no distribution on positions can be invariant to translations and still integrate to one, it works on the subspace of configurations whose center of gravity is zero, and it admits likelihood computation; it outperformed earlier 3D molecular generative models in sample quality and training efficiency. RFdiffusion (Watson et al., 2023) fine-tuned the RoseTTAFold structure-prediction network on protein-structure denoising and designed binders, symmetric assemblies and enzyme active-site scaffolds. The authors characterized hundreds of designs experimentally, and a cryo-electron-microscopy structure of a designed binder bound to influenza hemagglutinin was nearly identical to the design model. Diffusion Models develops the generative side.
Must the symmetry be built in? AlphaFold 3 (Abramson et al., 2024) answered no for its own case: its diffusion module operates on raw atom coordinates "without rotational frames or any equivariant processing", and the authors report that no invariance or equivariance to global rotations and translations was required in the architecture. Brehmer, Behrends, de Haan & Cohen (2024) measured the trade-off on a rigid-body interaction benchmark with transformer models. Equivariance improved data efficiency, but non-equivariant models trained with data augmentation closed the gap given enough epochs; with compute, both followed power laws, with the equivariant models ahead at every budget tested; and the compute-optimal split between model size and training time differed between the two. For interatomic potentials, Qu & Krishnapriyan (2024) argued that strict constraints inhibit scaling, and reported an attention-based potential, EScAIP, with at least 10 times faster inference and 5 times less memory than existing models and state-of-the-art accuracy on catalyst, molecular and materials datasets.
Middle grounds exist. Frame averaging (Puny et al., 2022) makes any backbone network exactly invariant or equivariant by averaging its outputs over a small, input-dependent set of group elements, a frame, instead of the whole group.
Key takeaways
- E(3) is rotations, reflections and translations. Energies must be invariant and forces equivariant, and the gradient of an invariant energy is automatically an equivariant, conservative force field.
- Invariant models (SchNet on distances, DimeNet on distances and angles) are simple and effective, but invariant message passing cannot see past identical 1-hop neighborhoods (no dihedral angles or global shape), and even 3- and 4-body descriptors are incomplete.
- EGNN moves positions along relative vectors weighted by invariant scalars, , which is provably E(n)-equivariant at the cost of an ordinary GNN.
- Higher-order networks carry degree- features ( numbers) combined by Clebsch–Gordan products, . NequIP reported large gains in data efficiency, MACE reached the state of the art with two layers of four-body messages, and eSCN cut the product's cost from to .
- AlphaFold 2 used invariant point attention, equivariant diffusion generates molecules and RFdiffusion designs proteins. AlphaFold 3 dropped equivariant processing, and scaling studies find that equivariance saves data while unconstrained models with augmentation can catch up, so the right trade-off is open.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A network predicts an E(3)-invariant energy, and the forces are computed as by automatic differentiation. What do you know about these forces without any further design?
- Nothing: they must be made equivariant separately
- They are E(3)-equivariant and conservative
- They are invariant, like the energy
- They are equivariant to translations only
Show the answer
B. They are E(3)-equivariant and conservative
Differentiating gives : forces rotate with the molecule and ignore translations. As the gradient of an energy they are conservative, which keeps molecular dynamics simulations energy-preserving.
Which change to EGNN's update breaks its equivariance?
- Restricting the sums to neighbors within a cutoff distance
- Feeding instead of the squared distance to
- Adding a layer to the MLP
- Replacing by
Show the answer
D. Replacing by
Sums of positions do not cancel translations: , so the update picks up an extra term proportional to . Rotations alone would still be respected. The other changes keep every weight an invariant scalar.
A Clebsch–Gordan tensor product combines a degree-2 feature with a degree-1 feature. Which degrees can the output contain?
- Only degree 3, since degrees add
- Degrees 0, 1, 2 and 3
- Degrees 1, 2 and 3
- Only degree 2
Show the answer
C. Degrees 1, 2 and 3
The rule gives every degree from to , and the dimensions check: .
What did AlphaFold 3 report about equivariance in its diffusion module?
- It works on raw atom coordinates without rotational frames or equivariant processing; the authors found built-in invariance or equivariance to global rotations and translations unnecessary
- It uses EGNN layers for exact E(3)-equivariance
- It keeps AlphaFold 2's invariant point attention unchanged
- It averages its predictions over all rotations at inference time
Show the answer
A. It works on raw atom coordinates without rotational frames or equivariant processing; the authors found built-in invariance or equivariance to global rotations and translations unnecessary
Abramson et al. (2024) replaced AlphaFold 2's structure module, with its frames and invariant point attention, by a diffusion module on raw coordinates, and reported that no invariance or equivariance to global rotations and translations was required in the architecture. It is one data point in the debate on strict equivariance versus scale.
Further reading
- V. G. Satorras, E. Hoogeboom & M. Welling, "E(n) equivariant graph neural networks," ICML (2021).
- S. Batzner, A. Musaelian, L. Sun, M. Geiger, J. P. Mailoa, M. Kornbluth, N. Molinari, T. E. Smidt & B. Kozinsky, "E(3)-equivariant graph neural networks for data-efficient and accurate interatomic potentials," Nature Communications 13, 2453 (2022).
- I. Batatia, D. P. Kovács, G. N. C. Simm, C. Ortner & G. Csányi, "MACE: higher order equivariant message passing neural networks for fast and accurate force fields," NeurIPS (2022).
- J. Jumper et al., "Highly accurate protein structure prediction with AlphaFold," Nature 596, 583–589 (2021).
- M. M. Bronstein, J. Bruna, T. Cohen & P. Veličković, Geometric Deep Learning: Grids, Groups, Graphs, Geodesics, and Gauges (2021).