xnn.gnn.fast.gemnet#

Fast path of the GemNet efficient bilinear layer (Triton kernels).

The reference gathers the down-projected features onto every triplet (or quadruplet), scatters them into a zero-padded (E, K_max, F) neighbor matrix and multiplies it with the padded angular basis. Here the items of every output edge are split into chunks: one kernel gathers the features of a chunk’s input rows and forms its partial sum sum_t s_t (x) x[in_t], and a second adds the partial sums of every output edge in order. Neither the per-item features nor the padded matrices are formed, and autograd keeps the edge-sized features and the per-item basis only. The radial contraction and the bilinear weights stay matrix products. The sums are bilinear in the features and the basis: their gradients are one kernel over the items of every input row, and the derivatives of that kernel are the two kernels again, so forces and the weight gradients of a force loss take the fused path at any derivative order.

Module Attributes

NEVER

"auto" keeps the reference.

AUTO_POLICY

Edge counts above which use_fast="auto" takes the triplet kernels in evaluation mode (energy and forces).

AUTO_POLICY_TRAINING

The same for training mode (a step with a force loss, second derivatives included): on an A100 the kernels were faster from about 5k edges on in float32 and at no size measured in float64 (on the T4, V100 and L40S they win in float64 as well).

QUADRUPLET_AUTO_POLICY

in float32 faster than the reference from a few thousand edges (the long rows of quadruplets split over many programs), in float64 at no size measured.

Functions

supported(device, dtype)

Triton kernels on a CUDA device in float32 or float64.