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.2.tar.gz (396.9 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.2-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.2-cp312-abi3-macosx_11_0_arm64.whl (995.2 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: mlipcpp-0.1.2.tar.gz
  • Upload date:
  • Size: 396.9 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.2.tar.gz
Algorithm Hash digest
SHA256 f5c78b764a014589d33bfbe5f310b65bdf63e3ab21056f13b33326adec871de7
MD5 05c18b411673dfee602ae57940c34165
BLAKE2b-256 7ad38321c545d000dba066d888529c347520bdfff1a18d8342ea8283247f2907

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.2.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.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mlipcpp-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa6e08b4b183a6d5f9a62eb174587a8be00ceeec45c81e90c99fb4811574a1e2
MD5 1861389330db372ec95428d264056f91
BLAKE2b-256 5229a7915f28f33b8bff69e320b0542833b8d6e4df50570a5daa50f342af480d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.2-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.2-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mlipcpp-0.1.2-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ddb7b7bdc968e454dc379de5459c843f84b42ae8c81939168fa045b8b4a1508
MD5 acaa5a5ecb6aabea74f2d1c8fba5bb57
BLAKE2b-256 2ac3042ed56f5dc771bc6582fa08e07a7f436483f41643ad95a086398cad6ff0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlipcpp-0.1.2-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