xnn.gnn.models.blocks.RadialNet#

class xnn.gnn.models.blocks.RadialNet(hs, act=None, variance_in=1, variance_out=1, out_act=False)[source]#

Bases: FullyConnectedNet, FastPathModule

Per-edge radial network that can recompute its hidden layers in the backward.

An e3nn.nn.FullyConnectedNet (same parameters and state_dict keys, outputs equal to round-off). When a gradient flows through it (forces, stress), the hidden layers’ activations, E x hidden per layer whatever the tensor product’s size, are kept for the backward pass; with recomputation only the last hidden output is kept and the hidden layers run again in the backward, giving the same values. TorchScript always keeps the activations.

On the fast path (evaluation mode, float32 on CUDA, three hidden SiLU layers of at most 128 features) the hidden layers run as one Triton kernel per tile of edges whose backward recomputes them (xnn.gnn.fast.radial_kernels); training mode takes the layers as written.

With out_index and out_scale it returns the output columns out_index times out_scale, mapping the last layer’s matrix once instead of every output row (the column order and scale of a fused tensor product’s weights; equal to mapping the output, to round-off).

Variables:

recompute (str) – "auto" (default): recompute in evaluation mode from RECOMPUTE_MIN_EDGES edges; "on": whenever a gradient is needed; "off": never. Set with set_recompute_radial().

Parameters:

hs (List[int])

forward(x, out_index=None, out_scale=None)[source]#

Apply the network to x of shape (E, hs[0]); with out_scale (and out_index), its output columns mapped as in the class notes.

Each layer is one matrix product whose scalar factor carries the layer’s normalization and the constant of the previous activation, then the activation: the same values as the layers applied one by one, in fewer kernels. TorchScript applies the layers one by one.

Parameters:
Return type:

Tensor

fast_supported(device, dtype)[source]#

Whether the fused hidden layers can run there (see the class notes).

Parameters:
Return type:

bool