Module contents
Lesson 25 of 30Advanced 120 min

SO(3) in depth: spherical harmonics, Clebsch-Gordan and tensor field networks

Use SO(3) irreps, spherical harmonics and Clebsch-Gordan products to build equivariant tensor field networks and analyze their computational cost.

After this lesson you can

  • Describe SO(3) irreps, Wigner matrices and O(3) parity.
  • Compute and transform real spherical harmonics through degree two.
  • Apply Clebsch-Gordan coupling rules and multiplicity counts.
  • Explain tensor field convolution, higher body order and SO(2) reduction.
  • Interpret measured molecular-force experiments with explicit resource limits.

Before you start

Beyond a vector

Energy is a scalar; a dipole has three components rotating together; a quadrupole or stress tensor contains higher-order directional information. Treating each component as an independent scalar channel would lose the rule linking them under rotation. The previous lesson built vector channels; now we generalize that idea while retaining equivariance.

SO(3) irreducible representations and Wigner matrices classify the integer types appearing here: for each l=0,1,2,…l=0,1,2,\ldots, space VlV_l has dimension 2l+12l+1 and a rotation RR acts through Dl(R)D^l(R). In a real orthonormal basis those matrices are real and orthogonal. l=0l=0 is scalar, l=1l=1 vectorial and l=2l=2 corresponds to symmetric traceless matrices of dimension five. A network can have multiple copies of each type; coefficients of one copy mix under rotation, but different degrees do not mix.

For O(3)O(3), parity p∈{+1,−1}p\in\{+1,-1\} is added, the sign under spatial inversion. A position vector is 1o1o (odd), angular momentum is 1e1e (axial, even) and a pseudoscalar is 0o0o. Restricted to SO(3), both parity types of the same ll have the same rotational action; under reflection they are no longer interchangeable. Chirality requires retaining this distinction.

Parity refers to simultaneous coordinate inversion, not the sign of one component. Any reflection QQ with negative determinant can be written Q=(−I)RQ=(-I)R with R=−Q∈SO(3)R=-Q\in SO(3). Its action on type (l,p)(l,p) is then pDl(R)pD^l(R). Thus knowing the rotation representation and inversion sign suffices to reconstruct the action of all O(3)O(3). Absolute position also shifts when translating the origin, so relative edge vectors rather than raw positions are normally coupled.

Multiplicity is not an extra spatial dimension. A state with cc copies of l=2l=2 contains 5c5c numbers: each block of five transforms by the same matrix D2(R)D^2(R), while an equivariant linear map can freely mix cc copies with a channel matrix. An arbitrary matrix on the 5c5c numbers, however, could treat orientations unequally and break the transformation law. Counting copies, components and weights separately is essential for interpreting cost and capacity.

Harmonics as direction coordinates

Spherical harmonics of degree ll form a basis of the angular-function space transforming as VlV_l. For unit direction r^\hat{\vb r}, vector Yl(r^)\vb Y^l(\hat{\vb r}) satisfies

Yl(Rr^)=Dl(R)Yl(r^).\vb Y^l(R\hat{\vb r})=D^l(R)\vb Y^l(\hat{\vb r}).

The equality depends on a coherent basis, ordering and normalization convention. A convenient real basis for l=1l=1 is (x,y,z)(x,y,z); for l=2l=2 five polynomials r^⊤Eir^\hat{\vb r}\T E_i\hat{\vb r} result, where EiE_i is an orthonormal basis of symmetric traceless matrices. In the lab integral normalization multiplies those polynomials by 15/(8π)\sqrt{15/(8\pi)}; the interactive uses the same basis up to a common factor per degree. Basis-change coefficients do not change when every function of one degree is multiplied by the same constant.

InteractiveA harmonic rotates by mixing components

Coefficients after rotation: (0.766, 0.000, −0.643). Blue: negative sign; red: positive.

Degree l
0
40
Degree and dimension1, 3
Choose degree and component; drag the sphere horizontally or use the angle control. The surface shows harmonic sign on the visible hemisphere; coefficients are calculated in the lesson's Cartesian real basis.

For l=2l=2, identify a five-coefficient vector with matrix T=∑iciEiT=\sum_i c_iE_i. Under rotation T↦RTR⊤T\mapsto RTR\T and entry (i,j)(i,j) of D2(R)D^2(R) is tr⁡(Ei⊤REjR⊤)\operatorname{tr}(E_i\T R E_jR\T). Orthogonal conjugation preserves the Frobenius product, so D2(R)D^2(R) is orthogonal. This construction avoids confusing one library’s convention with another; an orthogonal basis change conjugates every DlD^l matrix and also transforms coupling coefficients.

The group law is also checked in this representation. With two rotations RR and SS, applying SS first and then RR takes TT to (RS)T(RS)⊤(RS)T(RS)\T. By uniqueness of coordinates in basis EiE_i, D2(RS)=D2(R)D2(S)D^2(RS)=D^2(R)D^2(S). Orthogonality alone does not define a representation: an arbitrary family of orthogonal matrices might not respect composition.

Integral normalization allows comparing functions of different degrees without depending on arbitrary polynomial amplitude. On the unit sphere, ∫xixj dΩ=(4π/3)δij\int x_i x_j\,d\Omega=(4\pi/3)\delta_{ij} and rotational symmetry also fixes fourth-order moments. This gives the l=1l=1 and l=2l=2 factors used below. If one package normalizes to constant sum of squares per direction and another to unit integral, outputs differ by a known factor; equivariance is unchanged if the same convention is used throughout.

A useful check integrates each function’s square over the sphere: with this normalization it should be one, and the product integral of distinct functions zero. For example, Y0=1/4πY^0=1/\sqrt{4\pi} has square integral one because the sphere’s area is 4π4\pi. The three degree-one functions are proportional to direction coordinates; their sphere average is zero. A zero direction has no corresponding sphere point, so the lab rejects it instead of inventing an orientation.

To distinguish a function from a representation, take f(r^)=c⊤Yl(r^)f(\hat{\vb r})=c\T Y^l(\hat{\vb r}). Actively rotating the pattern gives fR(r^)=f(R−1r^)f_R(\hat{\vb r})=f(R\inv\hat{\vb r}). Because DlD^l is orthogonal, rotated-pattern coefficients are Dl(R)cD^l(R)c. By contrast, changing axes without moving the object introduces the inverse. This difference explains many apparently contradictory signs in harmonic visualizations.

Clebsch-Gordan: which products are allowed

The Clebsch-Gordan tensor product decomposes two SO(3) irreps without multiplicities:

Vl1⊗Vl2≅⨁l=∣l1−l2∣l1+l2Vl.V_{l_1}\otimes V_{l_2}\cong\bigoplus_{l=|l_1-l_2|}^{l_1+l_2}V_l.

For O(3)O(3) the output must also have parity p1p2p_1p_2. Thus 1o⊗1o1o\otimes1o can produce 0e0e, 1e1e and 2e2e: dot product, axial cross product and symmetric traceless part. Their dimensions 1+3+5=91+3+5=9 match 3⋅33\cdot3. If there are c1,c2,c3c_1,c_2,c_3 copies of input and output types, each allowed triple of copies admits a scalar weight, yielding c1c2c3c_1c_2c_3 weights for that path. This counts mixing parameters; it does not automatically equal implementation operation count.

InteractiveAllowed paths and dense cost

For the chosen inputs, the chart shows output degrees satisfying the triangle rule with parity o; each bar counts possible dense operations, not measured FLOPs.

0200400600800100000136026003840405060

Mixture decomposition: 11 type paths and 18 weights between copies.

  • 2×0e ⊗ 1×0e → 2×0e: 4 weights
  • 2×0e ⊗ 1×1o → 1×1o: 2 weights
  • 2×0e ⊗ 1×2e → 1×2e: 2 weights
  • 1×1o ⊗ 1×0e → 1×1o: 1 weight
  • 1×1o ⊗ 1×1o → 2×0e: 2 weights
  • 1×1o ⊗ 1×1o → 1×2e: 1 weight
  • 1×1o ⊗ 1×2e → 1×1o: 1 weight
  • 1×2e ⊗ 1×0e → 1×2e: 1 weight
  • 1×2e ⊗ 1×1o → 1×1o: 1 weight
  • 1×2e ⊗ 1×2e → 2×0e: 2 weights
  • 1×2e ⊗ 1×2e → 1×2e: 1 weight
2
2
2
Allowed pathYes
Scalar weights8
Dense products, bound600
Choose two types, their multiplicity and output. Triangle rule and parity determine whether the path exists; bars show an explicit dense bound for degrees through 6.

By Schur’s lemma, an equivariant linear map between two irreducible copies of the same type is a scalar multiple of identity in this real case. Since each VlV_l appears once in the preceding decomposition, bilinear projection Vl1×Vl2→VlV_{l_1}\times V_{l_2}\to V_l is unique up to scale when the path is allowed, and zero otherwise. The claim assumes integer SO(3) irreps and one copy of each input and output; multiplicities introduce weight matrices between copies.

This uniqueness does not say a numerical coefficient table has identical signs in every library. If input bases change by invertible matrices B1,B2B_1,B_2 and output basis by B3B_3, the intertwiner in new coordinates transforms as C′=B3C(B1−1⊗B2−1)C'=B_3 C(B_1\inv\otimes B_2\inv). Wigner matrices also change by conjugation. A table from one convention and rotation matrix from another can yield a large residual even if each is separately correct. The exercise therefore fits and checks everything in the same basis and the e3nn cell uses only e3nn conventions.

For two ordinary vectors a,b\vb a,\vb b you can see the three pieces without a table. The scalar part is a⊤b/3\vb a\T\vb b/\sqrt3. The antisymmetric part corresponds to a×b/2\vb a\times\vb b/\sqrt2 and is axial: inverting both vectors leaves their cross product unchanged. The degree-two part is the symmetric traceless matrix

12(ab⊤+ba⊤)−a⊤b3I.\frac12(\vb a\vb b\T+\vb b\vb a\T)-\frac{\vb a\T\vb b}{3}\mat I.

Its projection onto the five EiE_i gives five numbers. The three pieces are orthogonal in the Frobenius product and reconstruct tensor ab⊤\vb a\vb b\T. Each piece’s scaling factor depends on the chosen intertwiner convention; changing it does not change type or parity. These products turn an abstract angular description into familiar geometric operations.

As a second example, 1o⊗2e1o\otimes2e allows outputs 1o1o, 2o2o and 3o3o. Their dimensions sum to 3+5+7=153+5+7=15, equal to 3×53\times5, and all have odd parity. If the architecture retains only degrees through L=2L=2, it discards degree-three output: it remains equivariant because a whole decomposition block is removed, although that information is lost. Truncating individual components of one irrep, however, generally does not respect rotation action.

Tensor field networks

A tensor field network (TFN) converts each edge into direction and distance, computes harmonic Yl(r^ij)Y^l(\hat{\vb r}_{ij}), multiplies by learned radial functions and couples that type with neighbor channels using Clebsch-Gordan. Sum aggregation preserves permutations. Radial coefficients are scalars and introduce no preferred orientation. Thomas et al. use harmonic filters to build layers transforming as scalars, vectors and higher-order tensors.

A steerable kernel condition is K(Rr)=Dout(R)K(r)Din(R)−1K(R\vb r)=D_{\mathrm{out}}(R)K(\vb r)D_{\mathrm{in}}(R)\inv. If both edge direction and input state are transformed, the two input factors cancel and output rotates by Dout(R)D_{\mathrm{out}}(R). Radial functions depend only on ∥r∥\|\vb r\| and harmonics supply angular dependence; intertwiners let those parts satisfy the condition. At zero edge length unit direction is undefined, so coincidences must be excluded or a compatible extension defined and its derivatives checked.

A numerical test must transform all involved objects in the same direction: relative positions, input features and expected output. For convolution over an edge set, jointly permute indices and features when renumbering nodes too. Compare absolute and relative error and test multiple rotations, reflections if included in the group, and configurations near cutoff. Tolerance depends on numeric type and output magnitude: small rounding error does not prove the law for all group elements, but can reveal an implementation mixing conventions.

A componentwise nonlinearity on l>0l>0 generally does not commute with Dl(R)D^l(R). Scalar gates, norms and tensor products are compatible ways to introduce nonlinearity. NequIP uses equivariant convolutions for interatomic potentials and forces derived from energy. Its published accuracy depends on data, training and architecture; this lesson’s small potential is illustrative and does not reproduce that evaluation.

For example, with polar vector vv and even scalar gate gg, operation v↦σ(g)vv\mapsto\sigma(g)v remains polar. Scalar function σ\sigma may be sigmoid because its input does not change under rotation; it is not applied independently to the three coordinates of vv. Conversely, multiplying an odd pseudoscalar gate by a polar vector gives an axial vector: its parity changes. A norm is an even scalar, but its derivative near zero needs numerical treatment when training forces.

When building energy, internal channels may have many degrees, but final readout must produce an even scalar 0e0e if energy is reflection invariant. For a vector property the head must have appropriate type and parity; for a chiral response an odd channel may be needed. These rules do not replace examining the physical environment: an external field, for example, must also transform as input or breaks the symmetry being imposed.

Body order and cost

The higher body order of MACE is built by combining symmetric tensor products of an atomic-environment basis. Multiplying several neighbor sums introduces correlations among multiple neighbors at once, without explicitly enumerating every tuple in naive form. In MACE, four-body messages permit two iterations in the described experiments. This does not prove two layers suffice for every task or data distribution.

The idea can be seen without expanding all Clebsch-Gordan indices. Form local descriptor Ai=∑jϕ(rij)A_i=\sum_j\phi(\vb r_{ij}). Its cubic product contains terms ∑j,k,qϕ(rij)ϕ(rik)ϕ(riq)\sum_{j,k,q}\phi(\vb r_{ij})\phi(\vb r_{ik})\phi(\vb r_{iq}): combining three neighbors with center ii produces correlations of up to four bodies. Some indices can coincide, so the product also contains lower-order terms. Atomic cluster expansion (ACE) couples these bases with symmetrization and representation rules; MACE incorporates those correlations into learned messages. “Up to four bodies” does not mean four layers or require every term to contain four distinct atoms.

The SO(3)-to-SO(2) convolution reduction aligns an edge with axis zz. The group fixing that direction consists of rotations about zz; in a complex basis an operator commuting with them connects only components with the same mm. After operating in that frame it transforms back. Alignment rotation is not unique, but SO(2) equivariance makes the result independent of residual rotation around the edge.

InteractiveAligning the edge reveals blocks by m
zAligned edge

Rows and columns cover (l, m) pairs. In the aligned complex basis, a map commuting with SO(2) connects only the same m. “Global” shows the possible dense pattern after basis change, not measured FLOPs.

45
3
Frame
Components16
Allowed entries in local frame44
Dense matrix entries256
Increase L and switch frames. Blue cells show allowed connections in the local complex basis; the global matrix can become dense after basis change.

With one copy per degree through LL there are (L+1)2(L+1)^2 components. A dense matrix has (L+1)4(L+1)^4 entries; an SO(2) intertwiner matrix in this case has (L+1)2+2∑k=1Lk2(L+1)^2+2\sum_{k=1}^L k^2 allowed entries, growing as O(L3)O(L^3). This simple count alone is not full convolution cost. Passaro and Zitnick reduce dominant tensor-product formulation cost from O(L6)O(L^6) to O(L3)O(L^3) under their analysis conventions; alignment, channels, radial functions and memory count too.

Block count follows from each frequency’s multiplicity. For m=0m=0 there are L+1L+1 possible degrees, hence a block of (L+1)2(L+1)^2 entries. For each m=1,…,Lm=1,\ldots,L there are L−m+1L-m+1 degrees for both mm and −m-m, yielding factor two. In a real basis each opposite-frequency pair is represented by a two-dimensional real block; the pattern is written differently but describes the same action.

For example, L=1L=1 has modes (0,0)(0,0) and (1,−1),(1,0),(1,1)(1,-1),(1,0),(1,1). Zero frequency forms an 2×22\times2 block and each nonzero frequency an 1×11\times1 block: six allowed entries versus sixteen in a dense matrix. This counts a generic complex SO(2) intertwiner with one copy per degree. Additional reality, parity or specific-kernel restrictions can reduce independent parameters; the counter is not GPU time or a universal learnable-weight count.

Three-dimensional equivariant attention combines invariant scalar attention weights with values transforming as irreps and geometric kernels. If score sijs_{ij} is an invariant scalar, αij=softmax⁡j(sij)\alpha_{ij}=\operatorname{softmax}_j(s_{ij}) is too. If every value vijv_{ij} transforms as the same irrep, ∑jαijvij\sum_j\alpha_{ij}v_{ij} transforms as it because Dl(R)D^l(R) factors out of the sum. Normalization must permute with neighbors and values must be built without absolute orientation. This derivation does not imply every score obtained from raw coordinates is invariant.

SE(3)-Transformer combines attention with equivariant kernels for point clouds and graphs. Equiformer uses irreps, tensor products and an attention variant with nonlinear messages for atomistic graphs. Both are specific families: group, parity, neighborhood and output still need choosing. In particular, guaranteeing proper-rotation equivariance does not automatically add reflection invariance.

Lab: real irreps through degree two

Lab functions use an orthonormal matrix basis EiE_i. To normalize harmonics with respect to sphere area measure, factors 1/4π1/\sqrt{4\pi}, 3/(4π)\sqrt{3/(4\pi)} and 15/(8π)\sqrt{15/(8\pi)} are used for l=0,1,2l=0,1,2 respectively. In code vectors are stored as rows, so active rotation is x @ R.T.

[ ]Real basis and Wigner matricesBrowser
import numpy as np
from scipy.spatial.transform import Rotation
sqrt=np.sqrt
E=np.array([[[1/sqrt(2),0,0],[0,-1/sqrt(2),0],[0,0,0]],
 [[1/sqrt(6),0,0],[0,1/sqrt(6),0],[0,0,-2/sqrt(6)]],
 [[0,1/sqrt(2),0],[1/sqrt(2),0,0],[0,0,0]],
 [[0,0,1/sqrt(2)],[0,0,0],[1/sqrt(2),0,0]],
 [[0,0,0],[0,0,1/sqrt(2)],[0,1/sqrt(2),0]]])
def real_sph_harm(l,xyz):
    xyz=np.asarray(xyz,float);r=np.linalg.norm(xyz,axis=-1,keepdims=True)
    if np.any(r==0): raise ValueError('dirección nula')
    x=xyz/r
    if l==0: return np.ones(x.shape[:-1]+(1,))/sqrt(4*np.pi)
    if l==1: return x*sqrt(3/(4*np.pi))
    if l==2: return np.einsum('...i,kij,...j->...k',x,E,x)*sqrt(15/(8*np.pi))
    raise ValueError('solo grados 0, 1 y 2')
def wigner(l,R):
    if l==0:return np.ones((1,1))
    if l==1:return R
    if l==2:return np.einsum('iab,ac,jcd,bd->ij',E,R,E,R)
    raise ValueError('solo grados 0, 1 y 2')
R=Rotation.from_euler('xyz',[.4,.2,-.7]).as_matrix();rng=np.random.default_rng(25);x=rng.normal(size=(30,3))
for l in range(3):
    D=wigner(l,R);err=np.max(np.abs(real_sph_harm(l,x@R.T)-real_sph_harm(l,x)@D.T))
    print('l',l,'equivariancia',err,'ortogonalidad',np.max(np.abs(D.T@D-np.eye(2*l+1))))
    assert err<1e-12 and np.allclose(D.T@D,np.eye(2*l+1))

We can also recover Dl(R)D^l(R) by least squares from directions and check agreement with the geometric construction. This is a numerical test for the chosen rotation, not an independent definition of every Wigner matrix.

[ ]Recover D by fittingBrowser
for l in range(3):
    Y=real_sph_harm(l,x);Yr=real_sph_harm(l,x@R.T)
    Dfit=np.linalg.lstsq(Y,Yr,rcond=None)[0].T
    print('l',l,'diferencia D',np.max(np.abs(Dfit-wigner(l,R))))
    assert np.allclose(Dfit,wigner(l,R),atol=1e-12)

To obtain an intertwiner without memorizing coefficients, solve Dl(R)C=C(D1(R)⊗D1(R))D^l(R)C=C(D^1(R)\otimes D^1(R)) for several rotations. Numerical nullity is evaluated with tolerance; a finite rotation set is a check, while the Clebsch-Gordan rule is the general result.

[ ]Intertwiners by null spaceBrowser
rotations=[Rotation.from_euler('xyz',v).as_matrix() for v in ([.2,.5,-.3],[-.7,.1,.4],[.9,-.6,.2])]
def solve_intertwiner(l):
    out=2*l+1; cols=out*9; blocks=[]
    for R in rotations:
        D=wigner(l,R);K=np.kron(R,R); M=np.empty((out*9,cols))
        for j in range(cols):
            C=np.zeros((out,9));C.flat[j]=1
            M[:,j]=(D@C-C@K).ravel()
        blocks.append(M)
    _,s,Vh=np.linalg.svd(np.vstack(blocks),full_matrices=False)
    return s,Vh[-1].reshape(out,9)
for l in range(3):
    s,C=solve_intertwiner(l);print('salida',l,'nulidad',int(np.sum(s<1e-10)),'residuo',s[-1])
    assert np.sum(s<1e-10)==1
    Rtest=Rotation.from_euler('xyz',[.6,-.3,.8]).as_matrix()
    assert np.linalg.norm(wigner(l,Rtest)@C-C@np.kron(Rtest,Rtest))<1e-10

A minimal convolution applies a radial weight to each coupled product and sums neighbors. Here we combine an input vector with an edge harmonic l=1l=1; direction is kept away from zero.

[ ]A minimal TFN convolutionBrowser
_,C=solve_intertwiner(2)
direction=np.array([.4,-.2,.8]);direction/=np.linalg.norm(direction)
v=np.array([.2,.7,-.3]); radial_weight=np.exp(-1.2)
out=radial_weight*(C@np.kron(v,direction))
rotated=radial_weight*(C@np.kron(R@v,R@direction))
print('error convolución',np.max(np.abs(rotated-wigner(2,R)@out)))
assert np.allclose(rotated,wigner(2,R)@out,atol=1e-10)

The next count bounds a deliberately dense contraction: it multiplies even Clebsch-Gordan coefficients that could be zero. The filter has one copy per degree and input and output have 32 channels per degree. The SO(2) count is for a generic block matrix at that width; it excludes rotations aligning edges and does not prove an implementation achieves that time ratio.

[ ]Count paths and operationsBrowser
L=4;channels=32
paths=[(a,b,c) for a in range(L+1) for b in range(L+1) for c in range(L+1) if abs(a-b)<=c<=a+b]
dense=sum((2*a+1)*(2*b+1)*(2*c+1) for a,b,c in paths)*channels**2
local=((L+1)**2+2*sum(k*k for k in range(1,L+1)))*channels**2
print('caminos SO(3)',len(paths),'productos densos',dense,'productos bloques SO(2)',local)
assert (len(paths),dense,local)==(65,13388800,87040)

Local lab: e3nn and rMD17

In this cell the library uses its own real basis and normalization. Never mix its DlD^l or coefficients with the preceding Cartesian basis without the corresponding basis change.

[ ]Irreps, harmonics and tensor product in e3nnLocal GPU
import torch
from e3nn import o3
torch.manual_seed(25)
device=torch.device('cuda' if torch.cuda.is_available() else 'cpu')
irreps=o3.Irreps('1x0e + 1x1o + 1x2e')
Rcpu=o3.rand_matrix();R=Rcpu.to(device);x=torch.randn(16,3,device=device)
Y=o3.spherical_harmonics(irreps,x,normalize=True,normalization='component')
YR=o3.spherical_harmonics(irreps,x@R.T,normalize=True,normalization='component')
D=irreps.D_from_matrix(Rcpu).to(device)
error_y=(YR-Y@D.T).abs().max().item()
out_ir=o3.Irreps('1x0e + 1x1e + 1x2e')
tp=o3.FullyConnectedTensorProduct('1x1o','1x1o',out_ir).to(device)
a=torch.randn(16,3,device=device);b=torch.randn(16,3,device=device)
out=tp(a,b);rotated=tp(a@R.T,b@R.T);expected=out@out_ir.D_from_matrix(Rcpu).to(device).T
error_tp=(rotated-expected).abs().max().item()
print('dispositivo',device,'dimensión armónicos',irreps.dim,'pesos producto',tp.weight_numel)
print('errores armónicos y producto',error_y,error_tp)
assert error_y<1e-4 and error_tp<1e-4
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

Download so3_potencial.py, potenciales.py and checkpoint.py into the same folder. The first requires PyTorch, e3nn and NumPy; the second manages downloading and checking the aspirin split described in the preceding lesson. The small model uses two layers, four channels per irrep, radial filters and FullyConnectedTensorProduct. It is a teaching TFN with energy and forces, not full NequIP or MACE.

In this implementation internal channels have natural parity (−1)l(-1)^l: 0e0e, 1o1o, 2e2e and, if included, 3o3o. Increasing LL adds degrees but not automatically opposite parities, such as axial vector 1e1e; energy output is an even scalar. SiLU activation applies only to even scalar channels, while higher-degree channels update through tensor products and residual connections. Energy is invariant under reflections as well as rotations, and forces are calculated as −∇rE-\nabla_{\vb r}E: respecting symmetry alone does not guarantee potential accuracy.

As a numerical check the model trained with L=1L=1 and 200 configurations was evaluated on eight test conformations and five transformations combining rotation, translation, permutation and sometimes reflection. In float32 maximum discrepancies were 1,18×10−41{,}18\times10^{-4} kcal/mol for energy and 8,11×10−48{,}11\times10^{-4} kcal/mol/Å for forces. With the same weights converted to float64 they were 3,90×10−133{,}90\times10^{-13} and 1,48×10−121{,}48\times10^{-12} in those units. Precision and magnitude scale affect numerical-test tolerance; this sample does not show all possible errors are equally small.

python so3_potencial.py --root rmd17 --sizes 50 200 800 --lmax 1 2 3 --epochs 100 --output so3-results.json

The program uses the same splits, loss and validation selection as the preceding lesson’s potentials. It saves energy and force errors, time and maximum allocated memory for each LL. Compare result files carefully: channel sizes and architecture parameter counts differ. Hardware available for this run may differ from any reference budget; record its actual GPU and do not attribute measurements to another card model.

With seed 42 the original 1000 training configurations are permuted: the first 50, 200 or 800 are used to fit and the last 200 for validation; the test file supplies another 1000. Loss sums mean squared energy error centered on training mean and one hundred times mean squared force error per component. Factor 100 is a weighting choice for these units, not a physical constant. Best epoch is chosen by validation force MAE; energy MAE in kcal/mol and force MAE in kcal/mol/Å are reported on test. Since conformations come from trajectories, a random configuration split is not a test on independent molecules or trajectories.

The following experiment ran all nine combinations of three sizes and L=1,2,3L=1,2,3 for 100 epochs each, comparing them with EGNN and the preceding lesson’s teaching PaiNN variant under the same data protocol. TFN results and baseline results include individual errors and times. One seed and one molecule cannot establish a general ranking; architectures differ in parameters, operations and structure.

InteractiveForces by data and maximum degree
  • TFN L=1
  • EGNN
  • PaiNN
TFN maximum degree
TFN parameters5905
TFN, 800 examples: time on NVIDIA GeForce RTX 30601001.1 s
TFN allocated CUDA peak35.9 MiB
Force MAE per component in kcal/mol/Å on 1000 test configurations. Change L to compare TFN with EGNN and PaiNN. One seed is used; model sizes are not matched. Displayed time and memory correspond to the TFN run with 800 examples, not equal compute budgets.

With 800 configurations TFN obtains MAE 4.7682, 3.9358 and 3.3182 kcal/mol/Å for L=1,2,3L=1,2,3, while EGNN gets 3.5515 and PaiNN 1.6053 in these runs. Results for 50 and 200 examples do not retain that ordering across every degree; increasing LL cannot be inferred to always improve accuracy. TFN has 5905, 13 297 and 25 969 parameters respectively, so increasing degree also changes capacity.

The three L=1L=1 runs used an NVIDIA GeForce RTX 3060. L=2L=2 with 50 examples combined 65 GPU and 35 CPU epochs after interruption; other TFN runs with L=2L=2 and L=3L=3 used one-thread CPU. For 800 examples, recorded times were 1001.1 s on GPU for L=1L=1, 1554.5 s on CPU for L=2L=2 and 4593.4 s on CPU for L=3L=3. These are not a same-hardware speed comparison across degrees; L=1L=1 time excludes waiting and work lost to interruption. Its peak allocated CUDA memory was 35.9 MiB. As a separate reference, one L=3L=3 training step with batch eight on that GPU reached 108.9 MiB allocated and 136.0 MiB reserved: a brief measurement, not a full campaign or global memory. CPU-only runs do not measure CUDA peak.

Each epoch saves a checkpoint per degree and size beside JSON with weights, optimizer and random generators. If interrupted, repeat the same command to continue from the last complete epoch. To continue on CPU add --device cpu --threads 1: the checkpoint retains CUDA state and separately records GPU and CPU segments. Arithmetic differences between devices can slightly alter numerical trajectory. Accumulated time resumes from the last saved epoch: it excludes waiting and work in an interrupted epoch, so it is not elapsed wall time from first start to finish. Completed results remain in JSON; use a new path to change budget, seed or batch. Option --telemetry records process allocated and reserved memory and a global sample at each epoch end and on errors; these points need not capture peaks between samples and global values include other processes.

Exercises

Proof
Prove: Justify uniqueness up to scale of an equivariant bilinear coupling among three SO(3) irreps.
0
Degrees are integers, each input and output has one copy, and the Clebsch-Gordan decomposition is known.

Step 1 of 3. How is a bilinear map converted into a linear one?

Numeric
In the decomposition of 2 tensor-multiplied by 2, what is the sum of dimensions of all output irreps?
Numeric
For input and output degrees 0 through 4 in SO(3), counting each ordered degree triple allowed by the triangle rule, how many paths are there?
Numeric
With one copy of each degree through L=4, how many entries are allowed in a matrix commuting with SO(2) in the complex basis?
Quiz
Which output can result from coupling two polar vectors 1o in O(3)?
Code
Implement real_sph_harm(l,xyz) for l=0,1,2 and row vectors of shape (...,3). Use the lesson’s basis and integral normalization, reject zero directions and return (...,2l+1).
import numpy as np
def real_sph_harm(l,xyz):
  pass
Shift+Enter to run

Key ideas

Key idea
Harmonics encode directions as irreps, Clebsch-Gordan combines allowed types, and a TFN preserves transformation laws end to end.