xnn.gnn.fast.gemnet_kernels#

Triton kernels and autograd functions of the GemNet fast path (see xnn.gnn.fast.gemnet).

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

The neighbor sums of the efficient bilinear layer, S[e, a, f] = sum_{t: out_t = e} s[t, a] x[in_t, f], split the items of every output edge (triplets or quadruplets, in output order) into chunks of at most CHUNK: one program per chunk forms the chunk’s product s^T x (a matrix-unit tile in IEEE float32, multiply-adds in float64) and one program per output adds its chunks’ partial sums in order, so long rows (quadruplets) occupy the whole GPU. The gradients take one program per chunk as well (the output’s gradient row read once): per item gs[t, a] = sum_f w[out_t, a, f] x[in_t, f] and the share u[t, f] = sum_a w[out_t, a, f] s[t, a], then one program per input row sums the shares of its items, gx[r] = sum_{t: in_t = r} u[t] (compressed rows, xnn.common.models.csr). No atomic adds: the sums come out the same in every run.

Module Attributes

CHUNK

one program each, the partial sums of an output's chunks added in order.

DOT_FLOAT64

Triton has no float64 tile product (it rejects the operands), so float64 accumulates by multiply-adds.

Functions

item_rows(in_idx, out_idx, num_in, num_out)

The items by output and by input and the output chunks: (order_out, ptr_out, order_in, ptr_in, chunk_out, chunk_start, chunk_end, chunk_ptr), cached for the same index tensors (the interaction blocks of one evaluation pass the same ones).

neighbor_sums(x, s, in_idx, out_idx, num_out)

The neighbor sums of the efficient bilinear layer (see xnn.gnn.fast.gemnet).

Classes

NeighborGradsFunction(*args, **kwargs)

(sum_a w[out] s, sum_f w[out] x[in]) onto the input rows and the items: the gradients of NeighborSumsFunction for the incoming w.

NeighborSumsFunction(*args, **kwargs)

S[e] = sum_{t: out_t = e} s_t (x) x[in_t], differentiable at any order.