xnn.gnn.fast.tensornet#

Fast path of the TensorNet embedding and interaction layers (Triton kernels).

The reference layers gather the neighbors’ tensor parts to the pairs, multiply them with the filters and sum the products onto the centers as separate tensor operations, each writing a (P, F), (P, 3, F) or (P, 3, 3, F) tensor that autograd keeps for the backward pass (P pairs, the self pairs included); the embedding does the same with the radial projections and the direction products. Here the networks stay as they are (the pair embedding per atom, the radial projections and the filter networks), and one kernel per layer gathers, multiplies and adds onto the centers, applying the cutoff on the way: no pair-sized tensor is written. The symmetric parts travel as their six distinct entries. The backward pass is one kernel per layer that adds the gradients of the atom-wise inputs onto the neighbors (and centers) and writes those of the filter networks’ outputs, the cutoff and the directions.

The gradient reaches positions, cell and the networks’ weights, and the backward kernels are differentiable once more, by kernels of the same form (the pair sums are linear in each input), so that a force loss trains through the fused layers. Third derivatives are not supported. The atom-wise stages are compiled, in training mode with their first and second derivatives compiled as well.

Module Attributes

AUTO_POLICY

Edge counts above which use_fast="auto" takes the kernels in evaluation mode (energy and forces): every size, since the fused layers were faster than the reference from a single small molecule on, in both precisions, and use less memory.

AUTO_POLICY_TRAINING

every size, since the fused layers were faster than the reference from a single small molecule on (A100, A30, V100 and T4), in both precisions.

Functions

compose_rows(I, v, S)

The (N, 3, 3, F) tensors I 1 + [v]_x + S.

embedding_parts(rows)

The embedding's parts from the fused pair sums (N, 10, F): I, v, the traceless S and the squared Frobenius norm of I 1 + [v]_x + S.

interaction_parts(X)

X / (|X|^2 + 1) and its parts I, v, S.

interaction_product(I, v, S, m, q, o3)

The parts of C = (1 + q / 10)(Y M + M Y) (O(3)) or 2 Y M (SO(3)), each divided by |C|^2 + 1; Y from its parts, M from the message rows (N, 10, F).

interaction_update(Xn, I, v, S, q)

X + dX + (1 + q / 10) dX^2 with dX from its parts.

stage(name, like[, training])

The atom-wise stage name: for CUDA tensors compiled, in training mode twice differentiable (see compile_twice_differentiable()); as written otherwise.

supported(device, dtype)

Triton kernels on a CUDA device in float32 or float64.