xnn.dnn.fast.acsf_kernels#

Triton kernels and autograd functions of the HDNNP symmetry functions (see xnn.dnn.fast.acsf).

Imported only when the kernels run, so that triton is needed only there.

The radial functions (types 1 and 2) of an edge depend on its length r; the angular functions (types 3 and 9) of a triplet factor into A(c) h(r1) h(r2) h(r3), with c the cosine of the angle, A(c) = 2^(1-zeta) max(1 + lambda c, 0)^zeta, h(r) = exp(-eta r^2) fc(r) and no h(r3) for type 9. The kernels take the per-edge lengths and the per-triplet (r1, r2, r3, c); the geometry before them stays in PyTorch.

The edges (triplets) are sorted by center and neighbor species (species pair), and one program sums a segment: the lanes are the functions of that center element and neighbor species (pair), so no lane is masked, and every program writes its own output columns (no atomic adds, the same result in every run). The cutoff values of the at most two declared cutoffs are evaluated once per edge or triplet and shared by the lanes. Each order has its own kernels: the values, the first derivatives (the gradient with respect to the inputs and the sums of a tangent’s first derivatives) and the second derivatives (contracted with a tangent). The gradient is therefore differentiable once, which is what a force loss needs for training.

Module Attributes

BLOCK

Edges or triplets per step of the segment kernels and per program of the per-item kernels.

Functions

segments(center, q, n, n_q)

The order that sorts items by (center, q) and the segment pointers (n n_q + 1,).

Classes

AngularFunction(*args, **kwargs)

The angular symmetry functions (N, D) from the triplets' (r1, r2, r3, cos) in segment order.

AngularGradFunction(*args, **kwargs)

The gradient of AngularFunction with respect to (r1, r2, r3, cos), differentiable once.

RadialFunction(*args, **kwargs)

The radial symmetry functions (N, D) from the edge lengths (E,) in segment order (row (E,): each edge's table row, center the edge's center, ptr the segment pointers, sp the atoms' species).

RadialGradFunction(*args, **kwargs)

The gradient of RadialFunction with respect to the lengths, differentiable once.