Skip to main content

lammps-mdi

MDI engine drivers for LAMMPS — run ML forcefields (MACE, and future models) on GPU via the MolSSI Driver Interface, communicating with a standard LAMMPS binary (no Kokkos compilation needed).

Designed for use with SEAMM, but works with any LAMMPS workflow that supports MDI.

How it works

LAMMPS acts as an MDI driver: it handles atom positions, neighbor lists (at the coarse level), and time integration. The lammps-mdi engine process acts as an MDI engine: it receives coordinates from LAMMPS each step, evaluates the ML model on GPU, and returns energies, forces, and (if periodic) the stress tensor.

mpirun -np 1  mace-mdi  -mdi "..."   ← GPU process: MACE on A100
         : -np 1  lmp  -mdi "..." -in input.dat  ← CPU process: time integration

The two processes communicate over MPI via the MDI protocol.

Supported engines

Engine Status Notes
MACE ✅ MACE-torch ≥ 0.3, vesin-torch neighbor lists, cuEquivariance optional
NequIP Planned
SevenNet Planned

Installation

See INSTALL_CONDA.md for full HPC instructions.

Usage

SEAMM_FF=/path/to/model.model \
mpirun --mca mpi_yield_when_idle 1 \
    -np 1 mdi_bind.sh mace-mdi -mdi "-role ENGINE -name MACE -method MPI" \
    : -np 1 mdi_bind.sh lmp -mdi "-role DRIVER -name LAMMPS -method MPI" -in input.dat

The mace-mdi command accepts several options:

mace-mdi --help

  -mdi MDI_STRING      MDI initialization string [required]
  --model PATH         Path to MACE model (overrides SEAMM_FF)
  --device DEVICE      PyTorch device (default: cuda:0)
  --dtype {float32,float64}
  --enable-cueq        Enable cuEquivariance acceleration
  --enable-oeq         Enable openEquivariance acceleration
  --max-pairs-per-point N
                       Neighbour-list capacity per point (default 256).
                       Raise for dense systems or long cutoffs; the periodic
                       timing line reports the largest value actually seen
                       against this limit.
  --profile-steps N    Profile the first N forward passes with torch.profiler
                       and write a Chrome trace (chrome://tracing, or
                       https://ui.perfetto.dev). Default 0 (disabled).
  --log-level LEVEL    DEBUG / INFO / WARNING / ERROR

From lammps.ini (SEAMM)

[local]
installation = conda   # or modules, or local

gpu-code = mpirun --mca mpi_yield_when_idle 1 \
    -np 1 ~/SEAMM/bin/mdi_bind.sh \
    mace-mdi -mdi "-role ENGINE -name MACE -method MPI" \
    : -np 1 ~/SEAMM/bin/mdi_bind.sh \
    lmp -mdi "-role DRIVER -name LAMMPS -method MPI"

As a Python library

from lammps_mdi import MACEEngine

engine = MACEEngine(
    model_path="/path/to/model.model",
    device="cuda:0",
    default_dtype="float32",
    enable_cueq=True,
)
engine.run("-role ENGINE -name MACE -method MPI")

Shell scripts

The package bundles four helper scripts, installed via lammps-mdi install-scripts:

Script Purpose
mdi_bind.sh Binds engine (rank 0) to GPU + NUMA-local CPUs, driver (rank 1) to adjacent CPUs; starts nvidia-smi monitor. For standalone machines.
mdi_monitor.sh Lightweight wrapper for SLURM/PBS: only starts GPU monitoring. Scheduler handles binding.
gpu_bind.sh Per-rank GPU binding for native Kokkos LAMMPS (approach A).
cpu_bind.sh CPU-only binding using L3 cache groups (EPYC 7763).

The CPU/GPU mappings in mdi_bind.sh, gpu_bind.sh, and cpu_bind.sh are currently hard-coded for a dual-GPU EPYC 7763 system. They will be made configurable in a future release.

Requirements

Package Source Notes
Python ≥ 3.10 HPC module
numpy HPC module Do not reinstall
mpi4py HPC module
pymdi ≥ 1.4 pip PyPI package for import mdi
torch (CUDA) pip (special index) Install before lammps-mdi
mace-torch ≥ 0.3 pip
matscipy ≥ 0.8 pip CPU fallback neighbor list
pint ≥ 0.20 pip Unit conversion
vesin-torch ≥ 0.3 pip (optional) GPU neighbor lists, strongly recommended
cuequivariance* pip (optional) NVIDIA cuEquivariance acceleration

Contributing

Issues and pull requests are welcome at https://github.com/molssi-seamm/lammps-mdi.

License

MIT — see LICENSE.

Metadata

Release files for lammps-mdi 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lammps-mdi 0.1.9
File Size Uploaded
lammps_mdi-0.1.9.tar.gz 42.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lammps-mdi 0.1.9
File Interpreter ABI Platform
lammps_mdi-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 71.5 kB

Release files / lammps_mdi-0.1.9.tar.gz

Download URL lammps_mdi-0.1.9.tar.gz
Size 42.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b749b624177d5a7e331d0e25ee5cd542c84530bfa9a86c8092dd7d69b8966876
BLAKE2b-256 checksum
How to use checksums
e52cbd7efdadf3b051b28b0a6aa557cb7e34d8581d324647c3cc6fcca1f2538d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / lammps_mdi-0.1.9-py3-none-any.whl

Download URL lammps_mdi-0.1.9-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1594b4cf1c4bb29e69d3302a93e42635d9cfd7efb3aa83511b03431b6f2aa407
BLAKE2b-256 checksum
How to use checksums
9881250f8996c8f4582222dfce216302d2a79ecdafcbdcc67a41b69f209dfca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page