mMACE (magnetism ML)
Two features run on the mMACE backbone, a frozen magnetic MACE model:
| Feature | What it needs mMACE for |
|---|---|
is_magnetic classification |
Reads a frozen mMACE embedding to classify magnetic vs. non-magnetic (human > ml > llm > heuristic, see Scientific controls) |
goldilocks magnetic-orderings --rank-with-mmace |
Relaxes every candidate ordering's magnetic moments on a frozen mMACE potential energy surface and ranks them by energy per atom (see Magnetic orderings) |
Both work once the default assets are installed: the is-magnetic-classifier asset carries
the backbone (~80.5 MB) beside the classifier, and goldilocks-ml installs mace-torch,
e3nn and sphericart with mace-torch[magnetic]. Without the asset, both features
degrade to their next tier (LLM or heuristic for is_magnetic; an unranked candidate list
with a warning for --rank-with-mmace) rather than failing. Once it is installed, an
is_magnetic model that fails to run fails the request instead of answering from the
heuristic.
1. Install the model asset
Part of the default and all asset profiles:
goldilocks assets install default
goldilocks assets status models/is-magnetic-classifier
# models/is-magnetic-classifier@1: installed
The install downloads model.json, is_magnetic.pt, the model card and the backbone
mmace-matpes-pbe-pretrained.model from PSDI record
sgk1t-48m42 and checks each
file's SHA-256.
2. Verify it's actually being used
A structure loading successfully is not proof the ml tier is live — check the source
field explicitly. Fe_bcc.cif (bundled with this repo, and actually magnetic) makes a good
check:
STRUCTURE="$(goldilocks examples path)/Fe_bcc.cif"
goldilocks explain "$STRUCTURE" --json | python3 -c \
"import json,sys; print(json.load(sys.stdin)['records']['is_magnetic']['source'])"
# expect: ml (not: heuristic, or llm)
Importing mace prints a UserWarning and a "cuequivariance ... will be disabled" line. Both
go to stderr, so they never reach the JSON on stdout.
For ordering ranking, a successful --rank-with-mmace run reports a model_id and real
per-candidate energies instead of degrading with a warning:
goldilocks magnetic-orderings "$STRUCTURE" --rank-with-mmace --json
If is_magnetic.source still reads heuristic, check
goldilocks assets status models/is-magnetic-classifier (step 1), then whether
GOLDILOCKS_MACE_BACKBONE is set in this shell (step 3): when it is, it replaces the
installed backbone.
3. Use a different checkpoint
GOLDILOCKS_MACE_BACKBONE overrides the installed backbone for both features:
export GOLDILOCKS_MACE_BACKBONE=/path/to/checkpoint.model
goldilocks-ml checks the backbone against the SHA-256 that the classifier's model.json
pins, so is_magnetic accepts only the file from record sgk1t-48m42: a different file
fails with ... has SHA-256 ...; its record pins fb43d7aa.... Leave the variable unset to
use the installed backbone.
4. Use mMACE in the Workbench
Nothing to configure: start the Workbench as usual (see the Workbench guide)
once the default (or all) assets are installed.
Load a magnetic structure (for example the bundled Fe_bcc.cif, in the folder
goldilocks examples path prints) and
check the Analysis column's "is magnetic" field: once the ml tier is live, its caption
reads "Goldilocks-ML prediction". A "Magnetic Orderings" column also appears
automatically once the run is spin-polarized, whether the classifier made it so, a Hubbard U
on an odd d or f count did, or a setting such as spin_polarized or magnetic_ordering did
(it stays hidden for a spin-unpolarized run) — this is where --rank-with-mmace lives in the
UI.
Clicking Run mMACE there ranks the candidates in a separate process, so editing a setting while it runs is unaffected. Rankings run one at a time on the server: a ranking behind others shows "Queued: N rankings ahead of yours", then "Ranking candidate i of n" while it runs. With goldilocks-ml 0.4.0, rock-salt NiO's eight candidates take about 11 s and bcc Fe's eight about 9 s on a laptop CPU (Apple silicon, 2026-11-10). Larger cells take longer.
5. Structure size limit
mMACE's memory grows with the number of atoms. The is_magnetic embedding peaked at 3.5,
6.4 and 11.8 GB for 54, 128 and 250 atoms (core 0.3.0, macOS, 2026-11-09). On Linux with
goldilocks-ml 0.3.3 (aarch64, glibc 2.36, 2026-11-09), its worker peaked at 4.3 GB for 128
atoms and 6.3 GB for 200, from a 0.7 GB baseline. So neither mMACE use runs on a structure
with more atoms than GOLDILOCKS_MMACE_MAX_ATOMS (default 200):
is_magnetictakes its next tier's answer (an LLM value, else the local-moment heuristic), and the record'ssource_notesays the classifier was not run and why. The Workbench shows it under the "is magnetic" field.- A ranking whose largest candidate is above the limit is not started. The candidates come
back unranked, with a
magnetic.ordering_ranking_unavailablewarning naming the candidate, its atom count and the limit.
export GOLDILOCKS_MMACE_MAX_ATOMS=400 # a positive whole number; anything else fails the request
The is_magnetic worker keeps much of a prediction's memory afterwards: 0.45 GB after a
16-atom structure, 0.9–2.3 GB after a 128-atom one. Only the process exiting releases it.
So after a structure of more than 16 atoms, once the worker has been idle for 30 s, a fresh
one is started and warmed up in the background and takes over, and the old one exits. On
Linux that brought the worker back to 0.67 GB. Predictions keep going to the old worker
meanwhile, so none waits for the model to load.
6. Run mMACE on a GPU
mMACE runs on the CPU unless GOLDILOCKS_MMACE_DEVICE says otherwise:
export GOLDILOCKS_MMACE_DEVICE=cuda # or cpu, the default; anything else stops the server at startup
On cuda, the is_magnetic classifier embeds structures on the GPU, and each ordering
ranking relaxes its candidates there. A ranking's process exits when the ranking ends, so
its GPU memory is freed with it. The is_magnetic worker lives as long as the server, so
it holds its CUDA context, and whatever its predictions leave cached, until it is replaced
(section 5).
A ranking job of the HTTP server runs on a worker warmed ahead of it, so the job does not pay CUDA initialisation, which took about 19 s on an A100. The warm worker waiting for the next job holds a CUDA context and the model on the GPU the whole time, and while a job runs there are two such processes.
The CUDA build of torch comes from a uv dependency group. A uv-managed install takes CPU
torch by default (the cpu group, so CI and the image stay small). Swap that group for
cu130 (Linux, with an NVIDIA driver for CUDA 13.0):
uv sync --no-group cpu --group cu130 --extra http
# or, at each start:
uv run --no-group cpu --group cu130 --extra http goldilocks serve http
Asking for both groups is an error.
The groups exist only in a source checkout: the published package carries neither, so
--group cu130 does nothing for an install from PyPI. Such an install, whether by pip,
uv pip or uvx, takes torch from PyPI, and PyPI's Linux wheel is already a CUDA build. So
GOLDILOCKS_MMACE_DEVICE=cuda works there as long as the install was not pointed at the CPU
index.
If torch cannot use a GPU, mMACE runs on the CPU. That happens when torch is a CPU build or sees no CUDA device. The server logs a warning at startup saying which:
GOLDILOCKS_MMACE_DEVICE=cuda, but torch sees no CUDA device, so mMACE runs on the CPU
On cuda, Triton writes ~/.triton the first time it runs, so the server's HOME must be
writable. With a read-only HOME, rankings come back unranked as "ranking unavailable".
Measured on an A100 80 GB, with core 0.3.1 and torch 2.13.0+cu130 (2026-11-10):
- bcc Fe ranking: 8 candidates in 67 s, against 107 s on 24 CPU cores. The first candidate takes about 19 s, since it starts the process, loads the checkpoint and initialises CUDA. Each later one takes about 5.5 s, against 13 s on the CPU.
- Results: the same recommended ordering as on the CPU, with energies within about 1e-10 eV/atom.
- GPU memory: grows by about 41 MB per atom, so about 8 GB at the 200-atom limit.
- Sharing the GPU: a ranking running beside a chat model on the same GPU slowed the chat model's decoding from 52 to 43 tokens/s.
These numbers predate goldilocks-ml 0.4.0, whose relaxation is 5–15× faster on either device.
The fixed cost of each ranking (starting its process, loading the checkpoint, initialising
CUDA) now weighs more, so measure both devices before choosing cuda.