mlipcpp 0.1.1__cp312-abi3-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mlipcpp/__init__.py ADDED
@@ -0,0 +1,94 @@
1
+ """
2
+ mlipcpp - Fast C++ Machine Learning Interatomic Potentials
3
+
4
+ A high-performance implementation of MLIPs using GGML for inference.
5
+
6
+ Example usage:
7
+ import mlipcpp
8
+
9
+ # Direct C++ API
10
+ predictor = mlipcpp.Predictor("pet-mad.gguf")
11
+ result = predictor.predict(positions, atomic_numbers)
12
+ print(f"Energy: {result.energy} eV")
13
+
14
+ # ASE Calculator (if ASE is installed)
15
+ from mlipcpp.ase import MLIPCalculator
16
+ calc = MLIPCalculator("pet-mad.gguf")
17
+ atoms.calc = calc
18
+ energy = atoms.get_potential_energy()
19
+ """
20
+
21
+ from ._mlipcpp import (
22
+ Backend,
23
+ LogLevel,
24
+ ModelOptions,
25
+ Predictor,
26
+ Result,
27
+ backend_is_gpu,
28
+ enable_logging,
29
+ get_backend_name,
30
+ is_backend_available,
31
+ set_backend,
32
+ set_log_level,
33
+ version,
34
+ __version__,
35
+ )
36
+
37
+ __all__ = [
38
+ "Backend",
39
+ "LogLevel",
40
+ "ModelOptions",
41
+ "Predictor",
42
+ "Result",
43
+ "backend_is_gpu",
44
+ "enable_logging",
45
+ "get_backend_name",
46
+ "is_backend_available",
47
+ "set_backend",
48
+ "set_log_level",
49
+ "version",
50
+ "__version__",
51
+ ]
52
+
53
+
54
+ def load_model(path: str, **kwargs) -> Predictor:
55
+ """
56
+ Load an MLIP model from a GGUF file.
57
+
58
+ Parameters
59
+ ----------
60
+ path : str
61
+ Path to the GGUF model file
62
+ **kwargs
63
+ Additional options:
64
+ - backend: "auto", "cpu", "cuda", "hip", "metal", "vulkan", "sycl", "cann"
65
+ (default: "auto")
66
+ - cutoff_override: float (default: use model's cutoff)
67
+
68
+ Returns
69
+ -------
70
+ Predictor
71
+ Model predictor instance
72
+ """
73
+ options = ModelOptions()
74
+
75
+ if "backend" in kwargs:
76
+ backend_str = kwargs["backend"].lower()
77
+ backend_map = {
78
+ "auto": Backend.Auto,
79
+ "cpu": Backend.CPU,
80
+ "cuda": Backend.CUDA,
81
+ "hip": Backend.HIP,
82
+ "metal": Backend.Metal,
83
+ "vulkan": Backend.Vulkan,
84
+ "webgpu": Backend.WebGPU,
85
+ "sycl": Backend.SYCL,
86
+ "cann": Backend.CANN,
87
+ }
88
+ if backend_str in backend_map:
89
+ options.backend = backend_map[backend_str]
90
+
91
+ if "cutoff_override" in kwargs:
92
+ options.cutoff_override = float(kwargs["cutoff_override"])
93
+
94
+ return Predictor(path, options)
Binary file
mlipcpp/_mlipcpp.pyi ADDED
@@ -0,0 +1,247 @@
1
+ """mlipcpp - Fast C++ Machine Learning Interatomic Potentials"""
2
+
3
+ from collections.abc import Sequence
4
+ import enum
5
+ from typing import Annotated
6
+
7
+ import numpy
8
+ from numpy.typing import NDArray
9
+
10
+
11
+ class LogLevel(enum.Enum):
12
+ """Logging verbosity level"""
13
+
14
+ Trace = 0
15
+ """Most verbose"""
16
+
17
+ Debug = 1
18
+ """Debug messages"""
19
+
20
+ Info = 2
21
+ """Informational messages"""
22
+
23
+ Warn = 3
24
+ """Warnings only"""
25
+
26
+ Error = 4
27
+ """Errors only"""
28
+
29
+ Off = 5
30
+ """No logging (default)"""
31
+
32
+ def set_log_level(level: LogLevel) -> None:
33
+ """Set the logging verbosity level"""
34
+
35
+ def enable_logging() -> None:
36
+ """Enable informational logging"""
37
+
38
+ class Backend(enum.Enum):
39
+ """Compute backend selection"""
40
+
41
+ Auto = 0
42
+ """Automatically select best available GPU, fallback to CPU"""
43
+
44
+ CPU = 1
45
+ """CPU only"""
46
+
47
+ CUDA = 2
48
+ """NVIDIA CUDA GPU"""
49
+
50
+ HIP = 3
51
+ """AMD HIP/ROCm GPU"""
52
+
53
+ Metal = 4
54
+ """Apple Metal GPU (macOS/iOS)"""
55
+
56
+ Vulkan = 5
57
+ """Vulkan GPU (cross-platform)"""
58
+
59
+ WebGPU = 6
60
+ """WebGPU (Dawn native or browser)"""
61
+
62
+ SYCL = 7
63
+ """Intel SYCL (oneAPI)"""
64
+
65
+ CANN = 8
66
+ """Huawei Ascend NPU"""
67
+
68
+ class ModelOptions:
69
+ """Model configuration options"""
70
+
71
+ def __init__(self) -> None: ...
72
+
73
+ @property
74
+ def backend(self) -> Backend:
75
+ """Compute backend"""
76
+
77
+ @backend.setter
78
+ def backend(self, arg: Backend, /) -> None: ...
79
+
80
+ @property
81
+ def cutoff_override(self) -> float:
82
+ """Override model cutoff (0 = use default)"""
83
+
84
+ @cutoff_override.setter
85
+ def cutoff_override(self, arg: float, /) -> None: ...
86
+
87
+ class PredictOptions:
88
+ """Prediction options"""
89
+
90
+ def __init__(self) -> None: ...
91
+
92
+ @property
93
+ def compute_forces(self) -> bool:
94
+ """Whether to compute forces (default: True)"""
95
+
96
+ @compute_forces.setter
97
+ def compute_forces(self, arg: bool, /) -> None: ...
98
+
99
+ @property
100
+ def compute_stress(self) -> bool:
101
+ """Whether to compute stress tensor (default: False)"""
102
+
103
+ @compute_stress.setter
104
+ def compute_stress(self, arg: bool, /) -> None: ...
105
+
106
+ @property
107
+ def use_nc_forces(self) -> bool:
108
+ """
109
+ Use non-conservative forces from forward pass heads (faster, not energy-conserving)
110
+ """
111
+
112
+ @use_nc_forces.setter
113
+ def use_nc_forces(self, arg: bool, /) -> None: ...
114
+
115
+ class Result:
116
+ """Prediction results"""
117
+
118
+ @property
119
+ def energy(self) -> float:
120
+ """Total energy in eV"""
121
+
122
+ @property
123
+ def forces(self) -> Annotated[NDArray[numpy.float32], dict(writable=False)]:
124
+ """Forces array [n_atoms, 3] in eV/Angstrom"""
125
+
126
+ @property
127
+ def stress(self) -> Annotated[NDArray[numpy.float32], dict(writable=False)]:
128
+ """Stress tensor [6] in Voigt notation (eV/Angstrom^3)"""
129
+
130
+ def has_forces(self) -> bool: ...
131
+
132
+ def has_stress(self) -> bool: ...
133
+
134
+ class Predictor:
135
+ """MLIP model for energy/force predictions"""
136
+
137
+ def __init__(self, path: str, options: ModelOptions = ...) -> None:
138
+ """Load a model from a GGUF file"""
139
+
140
+ @property
141
+ def cutoff(self) -> float:
142
+ """Model cutoff radius in Angstroms"""
143
+
144
+ @property
145
+ def model_type(self) -> str:
146
+ """Model type string (e.g., 'PET')"""
147
+
148
+ def predict(self, positions: Annotated[NDArray[numpy.float32], dict(shape=(None, 3), order='C', writable=False)], atomic_numbers: Annotated[NDArray[numpy.int32], dict(shape=(None,), order='C', writable=False)], cell: Annotated[NDArray[numpy.float32], dict(shape=(3, 3), order='C', writable=False)] | None = None, pbc: Sequence[bool] | None = None, compute_forces: bool = True, compute_stress: bool = False) -> Result:
149
+ """
150
+ Predict energy and forces for an atomic system.
151
+
152
+ Parameters
153
+ ----------
154
+ positions : ndarray[float32, (n_atoms, 3)]
155
+ Atomic positions in Angstroms
156
+ atomic_numbers : ndarray[int32, (n_atoms,)]
157
+ Atomic numbers (e.g., 1 for H, 6 for C)
158
+ cell : ndarray[float32, (3, 3)], optional
159
+ Lattice vectors as rows for periodic systems
160
+ pbc : tuple[bool, bool, bool], optional
161
+ Periodic boundary conditions (default: all True if cell provided)
162
+ compute_forces : bool
163
+ Whether to compute forces (default: True)
164
+ compute_stress : bool
165
+ Whether to compute stress tensor (default: False)
166
+
167
+ Returns
168
+ -------
169
+ Result
170
+ Object containing energy, forces, and stress
171
+ """
172
+
173
+ def predict_with_options(self, positions: Annotated[NDArray[numpy.float32], dict(shape=(None, 3), order='C', writable=False)], atomic_numbers: Annotated[NDArray[numpy.int32], dict(shape=(None,), order='C', writable=False)], cell: Annotated[NDArray[numpy.float32], dict(shape=(3, 3), order='C', writable=False)] | None = None, pbc: Sequence[bool] | None = None, options: PredictOptions = ...) -> Result:
174
+ """
175
+ Predict energy and forces with full options control.
176
+
177
+ Parameters
178
+ ----------
179
+ positions : ndarray[float32, (n_atoms, 3)]
180
+ Atomic positions in Angstroms
181
+ atomic_numbers : ndarray[int32, (n_atoms,)]
182
+ Atomic numbers (e.g., 1 for H, 6 for C)
183
+ cell : ndarray[float32, (3, 3)], optional
184
+ Lattice vectors as rows for periodic systems
185
+ pbc : tuple[bool, bool, bool], optional
186
+ Periodic boundary conditions (default: all True if cell provided)
187
+ options : PredictOptions
188
+ Prediction options (compute_forces, compute_stress, use_nc_forces)
189
+
190
+ Returns
191
+ -------
192
+ Result
193
+ Object containing energy, forces, and stress
194
+
195
+ Notes
196
+ -----
197
+ When use_nc_forces is True, forces are computed from the model's forward pass
198
+ force heads instead of as gradients of energy. This is faster but the forces
199
+ are not energy-conserving.
200
+ """
201
+
202
+ def version() -> str:
203
+ """Get library version string"""
204
+
205
+ def set_backend(backend: Backend) -> None:
206
+ """
207
+ Set the global backend for all models.
208
+
209
+ This affects all subsequently loaded models. Call this before loading
210
+ any models to ensure they use the desired backend.
211
+
212
+ Parameters
213
+ ----------
214
+ backend : Backend
215
+ Backend to use (e.g., Backend.Metal, Backend.CPU, Backend.CUDA)
216
+
217
+ Example
218
+ -------
219
+ >>> import mlipcpp
220
+ >>> mlipcpp.set_backend(mlipcpp.Backend.Metal)
221
+ >>> model = mlipcpp.Predictor("model.gguf") # Uses Metal
222
+ """
223
+
224
+ def get_backend_name() -> str:
225
+ """
226
+ Get the name of the current backend (e.g., 'Metal', 'CPU', 'CUDA').
227
+ Check this after constructing a Predictor to confirm that a requested
228
+ GPU backend was actually selected rather than silently falling back to CPU.
229
+ """
230
+
231
+ def backend_is_gpu() -> bool:
232
+ """True if the currently active backend is a GPU device."""
233
+
234
+ def is_backend_available(backend: Backend) -> bool:
235
+ """
236
+ Check whether a specific backend is selectable on this host.
237
+
238
+ Returns True for Backend.CPU (always) and Backend.Auto (always, since Auto
239
+ falls back to CPU). For specific GPU backends returns True only when the
240
+ corresponding ggml backend is compiled in AND at least one matching device
241
+ is detected.
242
+
243
+ Example
244
+ -------
245
+ >>> if mlipcpp.is_backend_available(mlipcpp.Backend.Metal):
246
+ ... mlipcpp.set_backend(mlipcpp.Backend.Metal)
247
+ """
mlipcpp/ase.py ADDED
@@ -0,0 +1,202 @@
1
+ """
2
+ ASE Calculator interface for mlipcpp.
3
+
4
+ Example usage:
5
+ from ase.build import molecule
6
+ from mlipcpp.ase import MLIPCalculator
7
+
8
+ calc = MLIPCalculator("pet-mad.gguf")
9
+ atoms = molecule("H2O")
10
+ atoms.calc = calc
11
+
12
+ energy = atoms.get_potential_energy()
13
+ forces = atoms.get_forces()
14
+ """
15
+
16
+ from typing import Optional
17
+ import numpy as np
18
+
19
+ try:
20
+ from ase.calculators.calculator import Calculator, all_changes
21
+ from ase import Atoms
22
+
23
+ ASE_AVAILABLE = True
24
+ except ImportError:
25
+ ASE_AVAILABLE = False
26
+ Calculator = object
27
+ all_changes = []
28
+
29
+ from ._mlipcpp import Predictor, ModelOptions, Backend
30
+
31
+
32
+ class MLIPCalculator(Calculator):
33
+ """
34
+ ASE Calculator interface for mlipcpp MLIP models.
35
+
36
+ Parameters
37
+ ----------
38
+ model_path : str
39
+ Path to the GGUF model file
40
+ backend : str, optional
41
+ Compute backend (default: "auto"):
42
+ - "auto": Automatically select best available GPU, fallback to CPU
43
+ - "cpu": CPU only
44
+ - "cuda": NVIDIA CUDA GPU
45
+ - "hip": AMD HIP/ROCm GPU
46
+ - "metal": Apple Metal GPU (macOS/iOS)
47
+ - "vulkan": Vulkan GPU (cross-platform)
48
+ - "sycl": Intel SYCL (oneAPI)
49
+ - "cann": Huawei Ascend NPU
50
+ cutoff_override : float, optional
51
+ Override the model's cutoff radius (default: use model's cutoff)
52
+
53
+ Examples
54
+ --------
55
+ >>> from ase.build import molecule
56
+ >>> from mlipcpp.ase import MLIPCalculator
57
+ >>> calc = MLIPCalculator("pet-mad.gguf")
58
+ >>> atoms = molecule("H2O")
59
+ >>> atoms.calc = calc
60
+ >>> atoms.get_potential_energy()
61
+ -14.123...
62
+
63
+ # Use specific backend
64
+ >>> calc = MLIPCalculator("pet-mad.gguf", backend="cuda")
65
+ """
66
+
67
+ implemented_properties = ["energy", "forces", "stress"]
68
+ default_parameters = {
69
+ "backend": "auto",
70
+ "cutoff_override": 0.0,
71
+ }
72
+
73
+ def __init__(
74
+ self,
75
+ model_path: str,
76
+ backend: str = "auto",
77
+ cutoff_override: float = 0.0,
78
+ **kwargs,
79
+ ):
80
+ if not ASE_AVAILABLE:
81
+ raise ImportError(
82
+ "ASE is not installed. Install it with: pip install ase"
83
+ )
84
+
85
+ super().__init__(**kwargs)
86
+
87
+ self.model_path = model_path
88
+
89
+ # Set up model options
90
+ options = ModelOptions()
91
+
92
+ backend_map = {
93
+ "auto": Backend.Auto,
94
+ "cpu": Backend.CPU,
95
+ "cuda": Backend.CUDA,
96
+ "hip": Backend.HIP,
97
+ "metal": Backend.Metal,
98
+ "vulkan": Backend.Vulkan,
99
+ "sycl": Backend.SYCL,
100
+ "cann": Backend.CANN,
101
+ }
102
+ if backend.lower() not in backend_map:
103
+ valid_backends = ", ".join(sorted(backend_map.keys()))
104
+ raise ValueError(
105
+ f"Unknown backend '{backend}'. Valid options: {valid_backends}"
106
+ )
107
+ options.backend = backend_map[backend.lower()]
108
+ options.cutoff_override = cutoff_override
109
+
110
+ # Load the model
111
+ self._predictor = Predictor(model_path, options)
112
+
113
+ @property
114
+ def cutoff(self) -> float:
115
+ """Get the model's cutoff radius in Angstroms."""
116
+ return self._predictor.cutoff
117
+
118
+ @property
119
+ def model_type(self) -> str:
120
+ """Get the model type string (e.g., 'PET')."""
121
+ return self._predictor.model_type
122
+
123
+ def calculate(
124
+ self,
125
+ atoms: Optional["Atoms"] = None,
126
+ properties: list = ["energy"],
127
+ system_changes: list = all_changes,
128
+ ):
129
+ """
130
+ Calculate the requested properties for the given atoms.
131
+
132
+ Parameters
133
+ ----------
134
+ atoms : ase.Atoms
135
+ The atomic system to calculate
136
+ properties : list of str
137
+ Properties to calculate. Can include "energy", "forces", "stress"
138
+ system_changes : list
139
+ List of changes since last calculation (used for caching)
140
+ """
141
+ super().calculate(atoms, properties, system_changes)
142
+
143
+ if atoms is None:
144
+ atoms = self.atoms
145
+
146
+ # Prepare input arrays
147
+ positions = atoms.positions.astype(np.float32)
148
+ atomic_numbers = atoms.numbers.astype(np.int32)
149
+
150
+ # Check for periodic boundary conditions
151
+ pbc = atoms.pbc
152
+ cell = None
153
+ pbc_tuple = None
154
+
155
+ if any(pbc):
156
+ cell = atoms.cell.array.astype(np.float32)
157
+ pbc_tuple = tuple(bool(p) for p in pbc)
158
+
159
+ # Determine what to compute
160
+ compute_forces = "forces" in properties
161
+ compute_stress = "stress" in properties
162
+
163
+ # Run prediction
164
+ result = self._predictor.predict(
165
+ positions,
166
+ atomic_numbers,
167
+ cell=cell,
168
+ pbc=pbc_tuple,
169
+ compute_forces=compute_forces or compute_stress,
170
+ compute_stress=compute_stress,
171
+ )
172
+
173
+ # Store results
174
+ self.results["energy"] = float(result.energy)
175
+
176
+ if compute_forces and result.has_forces():
177
+ self.results["forces"] = np.array(result.forces)
178
+
179
+ if compute_stress and result.has_stress():
180
+ # ASE expects stress in Voigt notation: xx, yy, zz, yz, xz, xy
181
+ # with units of eV/Angstrom^3
182
+ stress = np.array(result.stress)
183
+ self.results["stress"] = stress
184
+
185
+
186
+ def load_model(model_path: str, **kwargs) -> MLIPCalculator:
187
+ """
188
+ Convenience function to load an MLIP model as an ASE calculator.
189
+
190
+ Parameters
191
+ ----------
192
+ model_path : str
193
+ Path to the GGUF model file
194
+ **kwargs
195
+ Additional arguments passed to MLIPCalculator
196
+
197
+ Returns
198
+ -------
199
+ MLIPCalculator
200
+ ASE calculator instance
201
+ """
202
+ return MLIPCalculator(model_path, **kwargs)
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.1
2
+ Name: mlipcpp
3
+ Version: 0.1.1
4
+ Summary: Fast C++ implementation of Machine Learning Interatomic Potentials
5
+ Author-Email: Peter Spackman <peterspackman@fastmail.com>
6
+ License: BSD 3-Clause License
7
+
8
+ Copyright (c) 2025, Peter Spackman
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice, this
14
+ list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ 3. Neither the name of the copyright holder nor the names of its
21
+ contributors may be used to endorse or promote products derived from
22
+ this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ Classifier: License :: OSI Approved :: BSD License
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: C++
38
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
39
+ Classifier: Topic :: Scientific/Engineering :: Physics
40
+ Project-URL: Homepage, https://github.com/peterspackman/mlip.cpp
41
+ Requires-Python: >=3.12
42
+ Requires-Dist: numpy>=1.24.0
43
+ Provides-Extra: ase
44
+ Requires-Dist: ase>=3.22.0; extra == "ase"
45
+ Provides-Extra: test
46
+ Requires-Dist: pytest; extra == "test"
47
+ Requires-Dist: ase>=3.22.0; extra == "test"
48
+ Description-Content-Type: text/markdown
49
+
50
+ # mlipcpp
51
+
52
+ > **WARNING: Pre-alpha software**
53
+ > This project is in early development. APIs may change without notice, and there may be bugs or incomplete features. Not recommended for production use.
54
+
55
+ Standalone C++ implementation of Machine Learning Interatomic Potentials (MLIPs) using [ggml](https://github.com/ggml-org/ggml).
56
+
57
+ Currently supports [PET/uPET](https://github.com/lab-cosmo/pet-mad) models (energy, forces, stresses).
58
+
59
+ ## Quick start (Python)
60
+
61
+ ```bash
62
+ # Install the package
63
+ pip install .
64
+
65
+ # Download and convert a model to GGUF
66
+ uv run scripts/convert_models.py --models pet-mad-s
67
+ ```
68
+
69
+ ```python
70
+ import numpy as np
71
+ import mlipcpp
72
+
73
+ # Load a model
74
+ model = mlipcpp.Predictor("gguf/pet-mad-s.gguf")
75
+ print(f"Model type: {model.model_type}, cutoff: {model.cutoff} A")
76
+
77
+ # Water molecule
78
+ positions = np.array([
79
+ [0.000, 0.000, 0.000], # O
80
+ [0.757, 0.586, 0.000], # H
81
+ [-0.757, 0.586, 0.000], # H
82
+ ], dtype=np.float32)
83
+ atomic_numbers = np.array([8, 1, 1], dtype=np.int32)
84
+
85
+ # Predict energy
86
+ result = model.predict(positions, atomic_numbers, compute_forces=False)
87
+ print(f"Energy: {result.energy:.4f} eV")
88
+ # => Energy: -14.3693 eV
89
+
90
+ # Predict energy + forces
91
+ result = model.predict(positions, atomic_numbers, compute_forces=True)
92
+ print(f"Energy: {result.energy:.4f} eV")
93
+ forces = np.array(result.forces).reshape(-1, 3)
94
+ print(f"Forces (eV/A):\n{forces}")
95
+ ```
96
+
97
+ ### ASE integration
98
+
99
+ ```python
100
+ from ase.io import read
101
+ from mlipcpp.ase import MLIPCalculator
102
+
103
+ atoms = read("structure.xyz")
104
+ atoms.calc = MLIPCalculator("gguf/pet-mad-s.gguf")
105
+ print(f"Energy: {atoms.get_potential_energy():.4f} eV")
106
+ ```
107
+
108
+ ## Converting models
109
+
110
+ Download and convert uPET models from HuggingFace to GGUF format:
111
+
112
+ ```bash
113
+ # Convert all available models
114
+ uv run scripts/convert_models.py
115
+
116
+ # Convert a specific model
117
+ uv run scripts/convert_models.py --models pet-mad-s
118
+
119
+ # List available models
120
+ uv run scripts/convert_models.py --list
121
+ ```
122
+
123
+ Default models: `pet-mad-s`, `pet-oam-l`, `pet-omad-xs`, `pet-omad-s`, `pet-omat-xs`, `pet-omat-s`, `pet-spice-s`
124
+
125
+ 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`
126
+
127
+ ## Building from source
128
+
129
+ ### Dependencies
130
+
131
+ - [ggml](https://github.com/ggml-org/ggml) - Tensor library (fetched automatically via CMake)
132
+ - [fmt](https://github.com/fmtlib/fmt) - Formatting library (fetched automatically)
133
+
134
+ **Note:** This project uses a [modified fork of ggml](https://github.com/peterspackman/ggml) with additional backpropagation support for `CONCAT` and `CLAMP` operations, required for force/stress computation.
135
+
136
+ ### Build
137
+
138
+ ```bash
139
+ mkdir build && cd build
140
+ cmake .. -DCMAKE_BUILD_TYPE=Release
141
+ cmake --build . -j
142
+ ```
143
+
144
+ ### C++ CLI
145
+
146
+ ```bash
147
+ # Energy only
148
+ ./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz
149
+
150
+ # With forces
151
+ ./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz --forces
152
+
153
+ # With forces and stress (periodic systems)
154
+ ./build/bin/graph_inference gguf/pet-mad-s.gguf structure.xyz --forces --stress
155
+ ```
156
+
157
+ ## API
158
+
159
+ C, C++, Fortran, and Python APIs are provided. See `examples/` for usage.
160
+
161
+ ## License
162
+
163
+ BSD 3-Clause
@@ -0,0 +1,9 @@
1
+ py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mlipcpp-0.1.1.dist-info/RECORD,,
3
+ mlipcpp-0.1.1.dist-info/WHEEL,sha256=6aSHgtE1eGTwS98scn-MEfWDB7FkcgyinAWDEj2ZzUA,113
4
+ mlipcpp-0.1.1.dist-info/METADATA,sha256=DnKFbbJhx8bL7JFZc0p7nlQDzXfs5c1B0q9WZ4BYMag,5665
5
+ mlipcpp-0.1.1.dist-info/licenses/LICENSE,sha256=lRiAxMD8BWmdz8M6yQVPa4QZX_UFtQIaKVA2M8OdyX8,1501
6
+ mlipcpp/_mlipcpp.pyi,sha256=OcQrIVJE2P53Qsf0lFlPRQCupRs8NV5eXWXwTxMzv7M,7371
7
+ mlipcpp/ase.py,sha256=JKmOdF4NPI58qXBqNQ6M4TUz5i9Enf_0xBTtGxL3Y-A,5690
8
+ mlipcpp/_mlipcpp.abi3.so,sha256=LWaqYm07i8C1kFZk8lQcSba1IDA9XH-OhAYJJmORZpk,2711888
9
+ mlipcpp/__init__.py,sha256=tAU7hX0ZRl3FW4AAwNn-jQWPVr7LByWQ_spQ0VxaxJw,2230
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.12.2
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-abi3-macosx_11_0_arm64
5
+
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Peter Spackman
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
py.typed ADDED
File without changes