xnn.trfnn.models.equiformer_v2#
EquiformerV2, the equivariant Transformer for higher-degree representations (Liao et al., ICLR 2024).
An implementation of
Y.-L. Liao, B. Wood, A. Das, T. Smidt, “EquiformerV2: Improved Equivariant Transformer for Scaling to Higher-Degree Representations”, ICLR 2024 (arXiv:2306.12059),
written from the paper and consistent with the conventions of the reference code
(fairchem-core 1.x, models/equiformer_v2: feature layout, normalizations,
initialization, parameter names) without copying it.
Every atom carries C channels of a full spherical-harmonic expansion,
x_i of shape ((L + 1)^2, C). The equivariant graph attention of
Equiformer is rebuilt on eSCN convolutions (section 3.1): the features of the
two endpoints of an edge are concatenated and rotated into a frame whose y axis
is the edge direction, where the tensor product with the edge harmonics reduces
to an SO(2) linear map over the orders |m| <= m_max; the result is rotated
back. On top of that (sections 3.2 to 3.4):
attention re-normalization: a layer norm on the scalars before the MLP attention;
separable S2 activation: SiLU on scalars, a SiLU on sphere samples for the higher degrees (also in the feed-forward networks, as a grid MLP);
separable layer norm: degree 0 and the degrees above 0 normalized separately.
The degree embedding rotates the m = 0 output of a radial function back from the
edge frames and sums it over the neighbors (divided by avg_degree); the energy
is a feed-forward network of the final features summed over the atoms and divided
by avg_num_nodes. With direct_forces a final attention block predicts the
forces from its degree-1 output (the OC20 S2EF models).
Conventions worth knowing:
The edge frames rotate
r_j - r_i(center to neighbor), the negative of the xnn edge vector, onto the y axis (the e3nn polar axis). The reference picks a random roll about the edge for every evaluation; here the frame is the minimal rotation, deterministic and differentiable. The model depends on the roll only through the sampling of the sphere in the S2 activation.The reference detaches the rotation matrices from the positions, which leaves the gradient of the energy incomplete; here the energy is differentiated through them, so forces and stress from autograd are the exact derivatives.
smooth_cutoff=Truemakes the energy continuous at the cutoff (not part of the paper), as inEquiformer. The reference’s truncation to the nearestmax_neighborsatoms is not supported (it makes the energy discontinuous); use the radius instead.
Functions
|
The minimal rotation taking each edge direction onto the y axis, |
|
Samples in latitude and longitude: |
|
The reduced coefficients reordered by order: |
|
|
|
Positions of the coefficients with |
Classes
|
Equivariant layer norm of Equiformer on |
|
The degree embedding: radial |
|
Wigner-D blocks of the edge rotations, degree by degree, from Clebsch-Gordan recursion. |
|
EquiformerV2: equivariant graph attention on eSCN convolutions. |
|
The feed-forward network (Figure 1d): SO(3) linear, separable S2 activation, SO(3) linear. |
|
SiLU on degree 0, the sigmoid of extra scalars (one per channel and degree) on the others. |
|
RMS norm over all degrees (degree-balanced), with degree 0 centered and given a bias. |
|
Projection of |
|
eSCN convolution in the edge frame: one linear map per order |
|
Equivariant graph attention on eSCN convolutions (section 3.5, Figure 1b). |
|
Linear map per degree of |
|
Separable layer norm (section 3.4): a layer norm on degree 0, one RMS over all degrees above 0. |
|
SiLU on separate degree-0 scalars, S2 activation (SiLU on the sphere) for the higher degrees. |
|
Pre-norm block: norm, SO(2) graph attention, residual; norm, feed-forward, residual. |