create_mace

jaxrens.backends.mace.create_mace(model_path=None, supercell_trafo=(2, 2, 2), **kwargs)[source]

Create a MACE-JAX energy backend from any supported model file.

Single front door for every on-disk shape a converted MACE model can take. Dispatches by path so callers (and the YAML checkpoint_path) never have to know which container they hold:

  • .pkl — a {graphdef, state, ...} pickle (see create_mace_from_pickle()); the only shape that stores the split module directly rather than config + msgpack params.

  • everything else — handed to mace-jax’s load_model_bundle, which already accepts a bundle directory (config.json + params.msgpack), a loose config.json / params.msgpack pair (pass either file), a .ckpt orbax checkpoint, and the mace-jax-from-torch output (a msgpack blob named <name>-jax.npz with a sibling <name>-jax.json; pass the .npz). Note the converter’s .npz is msgpack, not a numpy archive, and only resolves when its same-stem .json sits next to it.

The backend always runs in float32. mace-jax’s bundle loader toggles jax_enable_x64 based on the dtype passed to load_model_bundle; we pin it to float32 so the rest of jaxrens (cells / positions / energies are all float32 by construction) doesn’t get silently promoted.

Parameters:
  • model_path (str | None) – Path to a model bundle directory, config.json / params.msgpack / .npz params file, .ckpt checkpoint, or .pkl graphdef+state pickle.

  • supercell_trafo (tuple[int, int, int]) – (sc_a, sc_b, sc_c) supercell expansion for neighbor finding. Must satisfy min(cell_diag * sc) >= 2 * r_cutoff.

  • kwargs (Any)

Returns:

MACEBackend instance.

Return type:

MACEBackend