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-onnxadapter are implemented. A real checkpoint is user-supplied; no weights are bundled. See the v2.x roadmap.Feature.
alpha-mlip(included inalpha-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
(elements, positions, cell?) -> (energy, forces, stress?)with:
| Quantity | Unit |
|---|---|
| positions | Å |
| energy | kcal/mol |
| forces | kcal/mol/Å |
| stress | kcal/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:
{
"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
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:
[dependencies]
sci-form = { version = "2.2", features = ["mlip-onnx"] }Load a user-supplied checkpoint:
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 input | Shape | Meaning |
|---|---|---|
positions | [N, 3] | Cartesian coordinates in Å |
atomic_numbers | [N] | Atomic numbers |
cell | [3, 3] optional | Lattice vectors for periodic models |
periodic | [1] optional | PBC flag |
| ONNX output | Shape | Meaning |
|---|---|---|
energy | [1] | Energy in the model's native unit |
forces | [N, 3] | Forces in the model's native unit per Å |
stress | [3, 3] optional | Stress 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
| Gate | Observable | Result |
|---|---|---|
| Callback contract | Energy and force shape | finite, one force per atom |
| Units (F113) | eV callback → kcal/mol; F = −∇E by finite differences | exact; 6.9e-10 kcal/mol/Å |
| Element coverage | Missing element | Unsupported |
| Registry | Duplicate name | rejected |
| Manifest | Empty elements / licence | rejected |
| Stress | Model declares stress but returns none | rejected |
| Cell | Non-finite component or zero-volume cell | rejected |
| Units | eV callback (energy + force) | converted by 23.060548867 at the boundary |
| ONNX adapter | Missing checkpoint | explicit load error |
| ONNX adapter | Wrong input count | explicit 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
| Surface | Entry point |
|---|---|
| CLI | no generic command; a model must be supplied by the host |
| WASM | no generic callback bridge |
| Python | no 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
- Add a real exported checkpoint and a conversion test.
- Add the neighbour list and PBC cell handling.
- Add stress and periodic benchmark cases.
- Add a model registry JSON manifest.
- Add Python, WASM and CLI wrappers.
- Benchmark against the model's native runtime on MD17/SPICE.