e3j.core.Convolution¶
- class e3j.core.Convolution(source: tuple[O3Space, O3Space], target: O3Space | None = None, *, graph_ordering: str | GraphOrdering, layout: str | Layout = Layout.TRAILING_CHANNELS, avg_num_neighbors: float | None = None, normalization: str | TensorProductNormalization = 'SQRT_DIM_OUT', config: Config | None = None)¶
Equivariant message-passing convolution.
Computes the aggregated message on receiver nodes given by:
\[m_b = \frac 1 N \sum_a (x_a \otimes y_{ab}) \odot s_{ab}\]where the sum runs over neighbors \(a\) of the receiver node \(b\), \(\otimes\) denotes a tensor product operation, \(\odot\) denotes a scalar mixing, and \(N\) the average number of neighbors.
The plain JAX implementation consists of the following operations:
Gather node features by senders,
Compute the tensor product of sender features with edge features (typically harmonic embeddings),
Mix tensor product outputs with edge scalars (typically MLP of RBF encodings),
Scatter-add messages on receiver nodes.
Optionally, the sum of messages is rescaled by
avg_num_neighbors.Note
When using CUDA or Mosaic TPU kernels with
SENDERgraph ordering, the following additional assumptions should hold:Symmetric graph: each edge
(a, b)has its reverse(b, a),Graded-symmetric edge features: \(y_{ba} = p . y_{ab}\) per slice, where the parity is \(p = (-1)^l\) for harmonic polynomials.
Symmetric scalars: \(s_{ba} = s_{ab}\) (true for distance-based radial functions).
Note
RECEIVERordering is not yet implemented for the Mosaic TPU kernel.Initialize a Convolution block from parameters.
- Parameters:
source – Representations of the two tensor-product inputs (node and edge features). The third source space (mixing scalars) is inferred from the former two in the
.sourceattribute.target – Output representation, inferred by default. Passing a target argument enforces a filter on the output irreducible blocks.
graph_ordering – Edge ordering for the graph, can be
RECEIVER,SENDERorNONE. When edges are sorted by senders, symmetry assumptions on the graph and edge features should hold. Only the unfused path supportsNONEfor now.layout – Specifies the channel axis,
TRAILING_CHANNELSis faster.avg_num_neighbors – If given, messages are divided by this factor.
normalization – Normalization of the tensor product’s Clebsch-Gordan coefficients, see
e3j.utils.options.TensorProductNormalization.config – Global
e3j.utils.config.Config(optional) pointing to the implementation path. The best available option should be automatically selected based on the environment.
Note
Operations inherit the dtype of their operands. On
FUSED_CUDA, the value dtype may befloat16,float32orfloat64: the fused convolution is trailing channels only, so it never hits theatomicAddfloat16 restriction.Methods
__call__(node_features, edge_features, ...)Return sum of messages on receiver nodes.
Attributes
Return packed Coef4D coefficients for the forward pass.
- __call__(node_features: Array, edge_features: Array, edge_scalars: Array, senders: Array, receivers: Array, node_mask: Array | None = None) Array¶
Return sum of messages on receiver nodes.
Leading axes should match the number of nodes
n0or number of edgesn1respectively. Feature dimensionsnum_x,num_y,num_scalarsmust match the dimensions of thesourceattribute.Node features and edge scalars may carry a trailing channel axis of size
num_channels, however edge features are expected to not carry one and are broadcast with node features along the channel axis.- Parameters:
node_features – array of shape
(num_nodes, num_x, num_channels)edge_features – array of shape
(num_edges, num_y)edge_scalars – array of shape
(num_edges, num_scalars, num_channels)senders – index vector of length num_edges, in bounds [0, num_nodes)
receivers – index vector of length num_edges, in bounds [0, num_nodes).
node_mask – optional boolean vector of length num_nodes,
Truefor real nodes andFalsefor padding nodes, which must lie at the tail of the graph. Padding edges are also assumed to only connect padding nodes.
Note
On the CUDA convolution kernel the edges must be sorted by the endpoint selected via
graph_ordering. TheSENDERordering additionally requires the symmetry assumptions documented on the class.
- coef¶
Return packed Coef4D coefficients for the forward pass.