Skip to main content

Fast C++ implementation of Machine Learning Interatomic Potentials

Project description

mlipcpp

WARNING: Pre-alpha software This project is in early development. APIs may change without notice, and there may be bugs or incomplete features. Not recommended for production use.

Standalone C++ implementation of Machine Learning Interatomic Potentials (MLIPs) using ggml.

Currently supports PET/uPET models (energy, forces, stresses).

Quick start (Python)

# Install the package
pip install .

# Download and convert a model to GGUF
uv run scripts/convert_models.py --models pet-mad-s
import numpy as np
import mlipcpp

# Load a model
model = mlipcpp.Predictor("gguf/pet-mad-s.gguf")
print(f"Model type: {model.model_type}, cutoff: {model.cutoff} A")

# Water molecule
positions = np.array([
    [0.000,  0.000, 0.000],  # O
    [0.757,  0.586, 0.000],  # H
    [-0.757, 0.586, 0.000],  # H
], dtype=np.float32)
atomic_numbers = np.array([8, 1, 1], dtype=np.int32)

# Predict energy
result = model.predict(positions, atomic_numbers, compute_forces=False)
print(f"Energy: {result.energy:.4f} eV")
# => Energy: -14.3693 eV

# Predict energy + forces
result = model.predict(positions, atomic_numbers, compute_forces=True)
print(f"Energy: {result.energy:.4f} eV")
forces = np.array(result.forces).reshape(-1, 3)
print(f"Forces (eV/A):\n{forces}")

ASE integration

from ase.io import read
from mlipcpp.ase import MLIPCalculator

atoms = read("structure.xyz")
atoms.calc = MLIPCalculator("gguf/pet-mad-s.gguf")
print(f"Energy: {atoms.get_potential_energy():.4f} eV")

Converting models

Download and convert uPET models from HuggingFace to GGUF format:

# Convert all available models
uv run scripts/convert_models.py

# Convert a specific model
uv run scripts/convert_models.py --models pet-mad-s

# List available models
uv run scripts/convert_models.py --list

Default models: pet-mad-s, pet-oam-l, pet-omad-xs, pet-omad-s, pet-omat-xs, pet-omat-s, pet-spice-s

Use --all to also convert larger variants: pet-oam-xl, pet-omad-l, pet-omat-m, pet-omat-l, pet-omat-xl, pet-omatpes-l, pet-spice-l

Building from source

Dependencies

  • ggml - Tensor library (fetched automatically via CMake)
  • fmt - Formatting library (fetched automatically)

Note: This project uses a modified fork of ggml with additional backpropagation support for CONCAT and CLAMP operations, required for force/stress computation.

Build

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j

C++ CLI

# Energy only
./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz

# With forces
./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz --forces

# With forces and stress (periodic systems)
./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz --forces --stress

API

C, C++, Fortran, and Python APIs are provided. See examples/ for usage.

License

BSD 3-Clause

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlipcpp-0.1.1.tar.gz (336.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mlipcpp-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

mlipcpp-0.1.1-cp312-abi3-macosx_11_0_arm64.whl (984.0 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

Details for the file mlipcpp-0.1.1.tar.gz.

File metadata

  • Download URL: mlipcpp-0.1.1.tar.gz
  • Upload date:
  • Size: 336.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mlipcpp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c762bb5f09d2f0839717c5432838a2239efec44a4182a28278a6a4fa78c34f5e
MD5 a7c708257c792403d6f894cc710aed74
BLAKE2b-256 e1276342246fa60a7bc311a8e0e41e95e9c2dac6f2a82c42789df02a356fc56c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.1.tar.gz:

Publisher: wheels.yml on peterspackman/mlip.cpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mlipcpp-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlipcpp-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b2144e658fdc752fed8c6e6367ecf6091b521fa9d7b75cde625cbfc3ec60c8dd
MD5 db26455e7eac2c5eb70ea5e2f75c3574
BLAKE2b-256 d7eefca4cc68e66553d457c43cc7131e5cde13615823714aff8f86c396d1fb56

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on peterspackman/mlip.cpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mlipcpp-0.1.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mlipcpp-0.1.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5db2c1cc9c5857ddc21fcd9262970d9b30178757405cb09839d56cec827d05d2
MD5 ee6500820baaccdd91ae69ddb00f7e33
BLAKE2b-256 fc77f595fae49fb31f5d98f4cf41584c8cad240b46e8595cee9a40a6f0d9a89b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.1-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on peterspackman/mlip.cpp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page