xnn.trfnn.fast.et_kernels#

Triton kernels and multilinear blocks of the ET fast path (see xnn.trfnn.fast.et).

Imported only when the fast path runs, so that triton is needed only there.

Features are F = H D wide (H heads of D); a kernel holds them as an (H, D) tile, padded to powers of two. One program handles one atom and walks its pairs in a sorted order (compressed rows: by center for the sums onto centers, by neighbor for the gradients onto neighbors), accumulating in registers, so the sums need no atomic adds and are the same in every run.

Two blocks, each linear in every operand:

  • the logits l[e, h] = sum_(f in h) q[i, f] k[j, f] dk[e, f] of every pair e (center i, neighbor j);

  • the messages, dx[i] = sum_e a[e, h] s3[e] and dv[i, c] = sum_e v[j, c] s1[e] + s2[e] u[e, c], with the values s_k[e] = w_k[j] dw_k[e] cw[e] (w the value projections, dw the value filters, cw the cutoff of the values, u the pair directions), returned as four rows per atom: dx and the three of dv.

Their adjoints are kernels of the same form, and the derivatives of the adjoints are values and adjoints with one operand replaced by its cotangent (xnn.common.models.multilinear), so the fused layers train with a force loss.

Functions

attention_logits(q, k, dk, src, dst, heads)

The fused logits sum_(f in h) q[dst] k[src] dk of every pair and head, (P, H).

attention_messages(a, w, dw, cw, v, u, src, ...)

The fused messages of every center: dx and the three rows of dv, (N, 4, F).