MolecularDiffusion.modules.models.painn_backbone¶
PaiNN-style scalar+vector equivariant backbone, ported from OM-Diff.
Source: om-diff @ 976084eaf407cc84a5f169f4204f72d4a1fbdbbc
(https://github.com/Aalto-QuML/om-diff — MIT), files
src/models/backbones/equivnet.py, src/models/layers/{rbf,norm,
readout,mlp,features}.py and src/models/ops.py.
Only the network is ported. OM-Diff’s diffusion objective, metal-centre
masking, conditional size prior and sampler are deliberately not part of
this file — the platform’s EnVariationalDiffusion supplies all of
that (see docs/model_integrations/omdiff/INTEGRATION_PLAN.md).
Two deliberate deviations from upstream:
EquivNet.forwardtakes plain tensors instead of OM-Diff’sBatchdataclass, so no part of their data model has to come along.EdgeLayer/with_edge_interactionsis not ported — it is off in every shipped OM-Diff config and nothing else here would use it.
Classes¶
Bessel radial basis (upstream alternative to the Gaussian one). |
|
Polynomial cutoff envelope, smoothly zero beyond |
|
OM-Diff's scalar+vector message-passing network. |
|
Hyperparameters of |
|
Evenly spaced Gaussians — OM-Diff's configured default. |
|
Layer norm whose statistics are pooled per graph, not per node. |
Functions¶
|
Edge distances |
Module Contents¶
- class MolecularDiffusion.modules.models.painn_backbone.BesselRBFLayer(n_features: int = 20, max_distance: float = 5.0, trainable: bool = True)¶
Bases:
RBFLayerBessel radial basis (upstream alternative to the Gaussian one).
- forward(distances: torch.Tensor) torch.Tensor¶
- prefactor¶
- r_max¶
- class MolecularDiffusion.modules.models.painn_backbone.EnvelopLayer(p: int = 6, xc: float = 5.0)¶
Bases:
torch.nn.ModulePolynomial cutoff envelope, smoothly zero beyond
xc.- forward(distances: torch.Tensor) torch.Tensor¶
- class MolecularDiffusion.modules.models.painn_backbone.EquivNet(hparams: EquivNetHParams, rbf_layer: RBFLayer | None = None, envelop_layer: EnvelopLayer | None = None)¶
Bases:
torch.nn.ModuleOM-Diff’s scalar+vector message-passing network.
Unlike upstream this consumes/returns tensors rather than their
Batchdataclass, so it can be driven straight from the dense diffusion batch byPaiNNDynamics.- forward(node_positions: torch.Tensor, node_states: torch.Tensor, edge_index: torch.Tensor, num_nodes: torch.Tensor) tuple[torch.Tensor, torch.Tensor]¶
Run the network over one flat (concatenated) batch of graphs.
- Parameters:
node_positions –
(n, 3)coordinates.node_states –
(n, input_size)embedded node features.edge_index –
(E, 2)directed edges,[:, 0] -> [:, 1].num_nodes –
(B,)nodes per graph; must sum ton.
- Returns:
(delta_node_positions (n, 3), node_states (n, node_size)).
- edge_featurizers¶
- envelop_layer = None¶
- hp¶
- interactions¶
- project_layer¶
- rbf_layer = None¶
- updates¶
- class MolecularDiffusion.modules.models.painn_backbone.EquivNetHParams¶
Hyperparameters of
EquivNet.
- class MolecularDiffusion.modules.models.painn_backbone.GaussianLinearRBFLayer(n_features: int = 64, max_distance: float = 5.0, min_distance: float = 0.0)¶
Bases:
RBFLayerEvenly spaced Gaussians — OM-Diff’s configured default.
- forward(distances: torch.Tensor) torch.Tensor¶
- class MolecularDiffusion.modules.models.painn_backbone.GraphLayerNorm(in_channels: int, eps: float = 1e-06, affine: bool = True)¶
Bases:
torch.nn.ModuleLayer norm whose statistics are pooled per graph, not per node.
- forward(x: torch.Tensor, splits: torch.Tensor) torch.Tensor¶
- eps = 1e-06¶
- MolecularDiffusion.modules.models.painn_backbone.pairwise_distances(positions: torch.Tensor, edges: torch.Tensor) tuple[torch.Tensor, torch.Tensor]¶
Edge distances
(E, 1)and unit vectors(E, 3), i -> j.edgesis(E, 2)(OM-Diff’s layout, not PyG’s(2, E)).