xnn.gnn.models.mace_foundation.from_mace_torch#
- xnn.gnn.models.mace_foundation.from_mace_torch(upstream, head=None, dtype=None)[source]#
Convert a
mace-torchmodel (plain or ScaleShift) to an xnn MACE.Reads every architecture hyper-parameter off the upstream module, builds the equivalent
MACE, and copies the weights; multi-head checkpoints are sliced to the requestedhead. The converted model reproduces the upstream energies, forces and stress to numerical precision (seetests/test_mace.pyand the foundation fidelity notebook).- Parameters:
upstream (torch.nn.Module) – A
mace.modules.models.MACEorScaleShiftMACEinstance.head (str, optional) – Head to keep for multi-head checkpoints (see
_resolve_head()).dtype (torch.dtype or str, optional) – Final dtype;
Nonekeeps the upstream parameters’ dtype.
- Returns:
The converted model.
- Return type:
- Raises:
NotImplementedError – For upstream features outside the xnn MACE (un-enveloped radial embeddings, unknown interaction blocks / radial bases / transforms, readout layouts other than one readout per interaction).