Skip to content

Universal MLIP model contract ​

The v2.2 MLIP prototype defines the contract for a user-supplied universal potential. The library does not bundle MACE, CHGNet, Orb or a private checkpoint: model weights have their own licences and training provenance. The registry and callback backend make the contract executable and testable without pretending that a random or test-weight model is a production potential.

Status. Contract, callback backend and the optional mlip-onnx adapter are implemented. A real checkpoint is user-supplied; no weights are bundled. See the v2.x roadmap.

Feature. alpha-mlip (included in alpha-v2).

flowchart LR
    A[Manifest: elements, cutoff, license, unit] --> B[Validate manifest]
    B --> C[Register model]
    C --> D[Evaluate elements + positions + optional cell]
    D --> E[Check coverage, cell, stress flag]
    E --> F[Convert eV to kcal/mol at boundary]
    F --> G[Validate energy/force/stress shapes and finiteness]
    G --> H[MlipResult]

Root entry point ​

evaluate_mlip(model, elements, positions, cell) validates the model manifest, the non-empty finite 3N geometry, atomic numbers (1..=118) and element coverage before delegation. It then rejects a non-finite energy, a force array whose length is not N or contains a non-finite component, a non-finite stress tensor, and a manifest that declares stress when the model returns none. MlipOnnx::evaluate applies the same finite checks to its tensor outputs.

Contract ​

A model evaluates

text
(elements, positions, cell?) -> (energy, forces, stress?)

with:

QuantityUnit
positionsÅ
energykcal/mol
forceskcal/mol/Å
stresskcal/mol/ų
cutoffÅ

The contract uses kcal/mol because that is the native unit of the existing force fields and MD integrators. A model trained in eV must convert at the adapter boundary; the registry does not hide the conversion.

Manifest ​

Every model carries a manifest:

json
{
  "schema_version": 1,
  "name": "mace-off23-small",
  "elements": [1, 6, 7, 8, 9, 15, 16, 17],
  "cutoff_angstrom": 5.0,
  "license": "MIT",
  "energy_unit": "ev",
  "supports_stress": false,
  "source": "sha256:..."
}

Validation rejects an unknown schema version, an empty element list, an invalid cutoff, an empty licence and an out-of-range atomic number.

API ​

rust
use sci_form::mlip::{CallbackMlip, MlipEnergyUnit, MlipManifest, MlipRegistry};

let manifest = MlipManifest {
    schema_version: 1,
    name: "my-model".into(),
    elements: vec![1, 6, 8],
    cutoff_angstrom: 5.0,
    license: "user-supplied".into(),
    // The closure answers in this unit; `evaluate` converts to kcal/mol.
    energy_unit: MlipEnergyUnit::Ev,
    supports_stress: false,
    source: None,
};

let model = CallbackMlip::new(manifest, |elements, positions, cell| {
    // Call a user-supplied ONNX runtime or a native backend here.
    Ok((0.0, vec![[0.0, 0.0, 0.0]; elements.len()], None))
})?;

let result = model.evaluate(&[8, 1, 1], &water, None)?;

MlipRegistry stores named models and rejects duplicate names. The registry is deliberately small; it is a contract boundary, not a model zoo.

ONNX adapter ​

Enable the optional dependency:

toml
[dependencies]
sci-form = { version = "2.2", features = ["mlip-onnx"] }

Load a user-supplied checkpoint:

rust
use std::path::Path;
use sci_form::mlip_onnx::MlipOnnx;

let model = MlipOnnx::from_path(Path::new("model.onnx"), manifest)?;
let result = sci_form::evaluate_mlip(&model, &elements, &positions, None)?;

The adapter is native-first and currently non-periodic. It requires exactly two inputs (positions, atomic_numbers) and two outputs (energy, forces). A checkpoint that returns stress or needs a cell is rejected explicitly rather than silently ignored.

ONNX adapter contract ​

An ONNX checkpoint adapter must document:

ONNX inputShapeMeaning
positions[N, 3]Cartesian coordinates in Å
atomic_numbers[N]Atomic numbers
cell[3, 3] optionalLattice vectors for periodic models
periodic[1] optionalPBC flag
ONNX outputShapeMeaning
energy[1]Energy in the model's native unit
forces[N, 3]Forces in the model's native unit per Å
stress[3, 3] optionalStress in the model's native unit per ų

The adapter must convert eV → kcal/mol at the boundary and reject a model whose element list does not cover the requested system. It must not silently fall back to a different model.

Validation ​

GateObservableResult
Callback contractEnergy and force shapefinite, one force per atom
Units (F113)eV callback → kcal/mol; F = −∇E by finite differencesexact; 6.9e-10 kcal/mol/Å
Element coverageMissing elementUnsupported
RegistryDuplicate namerejected
ManifestEmpty elements / licencerejected
StressModel declares stress but returns nonerejected
CellNon-finite component or zero-volume cellrejected
UnitseV callback (energy + force)converted by 23.060548867 at the boundary
ONNX adapterMissing checkpointexplicit load error
ONNX adapterWrong input countexplicit contract error

A production gate needs a real checkpoint and a reference trajectory (MD17/SPICE or a materials benchmark). That is why the adapter is not marked promoted.

Bindings ​

SurfaceEntry point
CLIno generic command; a model must be supplied by the host
WASMno generic callback bridge
Pythonno generic callback bridge

The contract is evaluated through a host-provided callback. The optional mlip-onnx adapter is the native load path; a Python/WASM bridge requires a host model loader and is not bundled.

Limitations ​

  • No model weights are included; the caller supplies the checkpoint.
  • The ONNX adapter is behind mlip-onnx, native-first and non-periodic.
  • It supports exactly two inputs and two outputs; stress/PBC are follow-ups.
  • No neighbour list, PBC wrapping or stress validation beyond finiteness.
  • No training, fine-tuning or uncertainty calibration.
  • The registry is in-memory and not serializable.
  • No Python, WASM or CLI wrapper for the registry.
  • Model licence and checkpoint provenance are the caller's responsibility.

Next steps ​

  1. Add a real exported checkpoint and a conversion test.
  2. Add the neighbour list and PBC cell handling.
  3. Add stress and periodic benchmark cases.
  4. Add a model registry JSON manifest.
  5. Add Python, WASM and CLI wrappers.
  6. Benchmark against the model's native runtime on MD17/SPICE.

Released under the MIT License.