xnn.cnn.fast.spherical#

Fast path of the SphericalCNN correlations (Triton kernels).

The reference layers transform with zero-padded spectra (b, 2b - 1, 2b - 1): the band of each FFT axis is cut out and pasted back with cat and zero fills, the contractions over beta and the spectral products are einsums over the padded entries (most of them zero) with layout copies around them. Here the spectra are compact and blocked by degree (see spherical_kernels): the forward contraction reads the FFT output at the band positions and writes the blocks, and the inverse contraction writes the whole FFT grid of the inverse transform (zeros off the band included), both as Triton kernels. A block of degree l is the matrix of that degree’s spectral product as a view, so the product is one complex matrix product per degree with the filter spectrum, (B (2l + 1), C_in (2l + 1)) @ (C_in (2l + 1), C_out (2l + 1)) for an SO(3) input and (B (2l + 1), C_in) @ (C_in, C_out (2l + 1)) for an S^2 one, whose result is the block of the output spectrum. The FFTs, the filter spectra (a small matrix product of the filter values with the basis) and everything outside the correlations stay as in the reference.

The contractions are linear and adjoint to each other, so each one’s backward is the other kernel and differentiable again; autograd differentiates the matrix products, keeping views of the compact spectra. Force training runs through the fused layers. The parameters and the state_dict are the reference ones.

Module Attributes

AUTO_POLICY

Edge counts above which use_fast="auto" takes the kernels in evaluation mode (energy and forces): every size, from a single molecule on they are faster than the reference.

AUTO_POLICY_TRAINING

The same for training mode (a step with a force loss, second derivatives included).

PADDED_MAX_BATCH

Batches (atoms) up to which float32 evaluation runs the correlations on padded blocks.

Functions

analyze(transform, x[, padded])

The degree-blocked spectra of grid signals: the fast counterpart of transform.analyze.

correlation(layer, x, so3)

The output of an S^2 (so3=False) or SO(3) correlation layer on its input x.

degree_matrices(w, L, so3[, padded])

The filter spectra w of filter_spectrum() as the per-degree matrices of the spectral product, one gather.

filter_spectrum(layer, dtype)

The conjugated filter spectra conj(psi) of a correlation layer, complex (n_in, n_out, K) with the entries of each channel pair ordered degree by degree ((k, n) within a degree of an SO(3) filter).

spectral_product(f, w, L, batch, so3[, padded])

The spectral product of a correlation: a complex matrix product per degree.

supported(device, dtype)

Triton kernels on a CUDA device in float32 or float64.

synthesize(transform, z, lead[, padded])

The real grid signals of degree-blocked spectra: the fast counterpart of transform.synthesize.