Skip to content

Commit aafca88

Browse files
authored
Add Vivace model (#606)
1 parent cad4d8f commit aafca88

5 files changed

Lines changed: 3841 additions & 7559 deletions

File tree

ml_peg/models/get_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def load_models(
143143
OrbCalc,
144144
SevenNetCalc,
145145
UPETCalc,
146+
VivaceCalc,
146147
)
147148

148149
if run_mock is None:
@@ -220,6 +221,13 @@ def load_models(
220221
trained_on_dispersion=cfg.get("trained_on_dispersion", False),
221222
dispersion_kwargs=cfg.get("dispersion_kwargs", {}),
222223
)
224+
case "MLFFCalculator":
225+
loaded_models[name] = VivaceCalc(
226+
device=cfg.get("device", "auto"),
227+
kwargs=cfg.get("kwargs", {}),
228+
trained_on_dispersion=cfg.get("trained_on_dispersion", False),
229+
dispersion_kwargs=cfg.get("dispersion_kwargs", {}),
230+
)
223231
case _:
224232
loaded_models[name] = GenericASECalc(
225233
module=cfg["module"],

ml_peg/models/models.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,44 @@ def get_calculator(self, precision="high", **kwargs) -> Calculator:
169169
return MlipxGenericASECalc.get_calculator(self, **kwargs)
170170

171171

172+
@dataclasses.dataclass(kw_only=True)
173+
class VivaceCalc(SumCalc):
174+
"""Dataclass for Vivace calculator."""
175+
176+
device: Device | None = None
177+
kwargs: dict = dataclasses.field(default_factory=dict)
178+
179+
def get_calculator(self, precision="high", **kwargs) -> Calculator:
180+
"""
181+
Prepare and load the calculator.
182+
183+
Parameters
184+
----------
185+
precision
186+
Unused precision argument, kept for the common model API.
187+
**kwargs
188+
Keyword arguments passed to the Vivace calculator.
189+
190+
Returns
191+
-------
192+
Calculator
193+
Loaded ASE calculator.
194+
"""
195+
from simpoly.vivace.calculator import MLFFCalculator
196+
197+
kwargs.update(self.kwargs)
198+
calc = MLFFCalculator(**kwargs)
199+
200+
# Vivace sets dtype from checkpoint metadata inside MLFFCalculator.
201+
# Leave precision/overwrite_dtype untouched unless SimPoly exposes it.
202+
device = Device.resolve_auto() if self.device == Device.AUTO else self.device
203+
if device is not None:
204+
calc.device = device
205+
calc.model = calc.model.to(device=device)
206+
207+
return calc
208+
209+
172210
# https://github.com/orbital-materials/orb-models
173211
@dataclasses.dataclass(kw_only=True)
174212
class OrbCalc(SumCalc):

ml_peg/models/models.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ sevennet-omni-mpa:
231231
model: "7net-omni"
232232
modal: "mpa"
233233

234+
# Vivace:
235+
# module: simpoly.vivace.calculator
236+
# class_name: MLFFCalculator
237+
# device: "cuda"
238+
# trained_on_dispersion: true
239+
# level_of_theory: r2SCAN+D3
240+
# kwargs:
241+
# model_path: /path/to/model.pt
242+
234243
# mace-polar-1-s:
235244
# module: mace.calculators
236245
# class_name: mace_polar

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ upet = [
8383
sevenn = [
8484
"sevenn==0.12.1",
8585
]
86+
vivace = [
87+
"simpoly[vivace,cuda13] @ git+https://github.com/microsoft/simpoly.git@da100ad32d971214cf9343d9d853e8ce61604dc0; sys_platform == 'linux'",
88+
"simpoly[vivace] @ git+https://github.com/microsoft/simpoly.git@da100ad32d971214cf9343d9d853e8ce61604dc0; sys_platform != 'linux'",
89+
"cuequivariance ==0.8.1; sys_platform != 'linux'",
90+
"cuequivariance-torch ==0.8.1; sys_platform != 'linux'",
91+
]
8692

8793
[project.scripts]
8894
ml_peg = "ml_peg.cli.cli:app"
@@ -225,6 +231,10 @@ conflicts = [
225231
{ extra = "mace" },
226232
{ extra = "sevenn" },
227233
],
234+
[
235+
{ extra = "vivace" },
236+
{ extra = "mace" },
237+
],
228238
]
229239

230240
constraint-dependencies = [

0 commit comments

Comments
 (0)