Spaces:
Running
Running
outline tasks and models
Browse files- README.md +7 -0
- atomind_mlip/models/README.md +6 -0
- atomind_mlip/models/__init__.py +39 -0
- atomind_mlip/models/mace-mp.py +43 -0
- atomind_mlip/models/registry.yaml +7 -0
- atomind_mlip/serve/README.md +0 -0
- atomind_mlip/tasks/README.md +0 -0
- atomind_mlip/tasks/__init__.py +3 -0
- atomind_mlip/tasks/alexandria.py +3 -0
- atomind_mlip/tasks/qmof.py +0 -0
- atomind_mlip/tasks/registry.yaml +2 -0
README.md
CHANGED
@@ -16,9 +16,16 @@ If you have pretrained MLIP models that you would like to contribute to the MLIP
|
|
16 |
|
17 |
#### Molecular dynamics calculations
|
18 |
|
|
|
|
|
|
|
19 |
|
20 |
#### Single-point density functional theory calculations
|
21 |
|
|
|
|
|
|
|
|
|
22 |
### Add new training datasets
|
23 |
|
24 |
[Hugging Face Auto-Train](https://huggingface.co/docs/hub/webhooks-guide-auto-retrain)
|
|
|
16 |
|
17 |
#### Molecular dynamics calculations
|
18 |
|
19 |
+
- [ ] [MD17](http://www.sgdml.org/#datasets)
|
20 |
+
- [ ] [MD22](http://www.sgdml.org/#datasets)
|
21 |
+
|
22 |
|
23 |
#### Single-point density functional theory calculations
|
24 |
|
25 |
+
- [ ] MPTrj
|
26 |
+
- [ ] QM9
|
27 |
+
- [ ] [Alexandria](https://alexandria.icams.rub.de/)
|
28 |
+
|
29 |
### Add new training datasets
|
30 |
|
31 |
[Hugging Face Auto-Train](https://huggingface.co/docs/hub/webhooks-guide-auto-retrain)
|
atomind_mlip/models/README.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
## Note on model registration
|
4 |
+
|
5 |
+
1. Use `ast` to parse model classes from the uploaded script.
|
6 |
+
2. Add the classes and their supported tasks to the model registry file `registry.yaml`.
|
atomind_mlip/models/__init__.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from torch import nn
|
3 |
+
from torch_geometric.data import Data
|
4 |
+
|
5 |
+
from ase import Atoms
|
6 |
+
from ase.calculators.calculator import Calculator, all_changes
|
7 |
+
|
8 |
+
|
9 |
+
class MLIP(Calculator):
|
10 |
+
def __init__(self):
|
11 |
+
super().__init__()
|
12 |
+
self.name: str = "MLIP"
|
13 |
+
self.version: str = None
|
14 |
+
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
15 |
+
self.model: nn.Module = None
|
16 |
+
self.implemented_properties = ["energy", "forces"]
|
17 |
+
|
18 |
+
def calculate(self, atoms: Atoms, properties: list[str], system_changes: dict = all_changes):
|
19 |
+
"""Calculate energies and forces for the given Atoms object"""
|
20 |
+
super().calculate(atoms, properties, system_changes)
|
21 |
+
|
22 |
+
output = self.forward(atoms)
|
23 |
+
|
24 |
+
self.results = {}
|
25 |
+
if "energy" in properties:
|
26 |
+
self.results["energy"] = output["energy"].item()
|
27 |
+
if "forces" in properties:
|
28 |
+
self.results["forces"] = output["forces"].cpu().detach().numpy()
|
29 |
+
|
30 |
+
def forward(self, x: Data | Atoms) -> dict[str, torch.Tensor]:
|
31 |
+
"""Implement data conversion, graph creation, and model forward pass
|
32 |
+
|
33 |
+
Example implementation:
|
34 |
+
1. Use `ase.neighborlist.NeighborList` to get neighbor list
|
35 |
+
2. Create `torch_geometric.data.Data` object and copy the data
|
36 |
+
3. Pass the `Data` object to the model and return the output
|
37 |
+
|
38 |
+
"""
|
39 |
+
raise NotImplementedError
|
atomind_mlip/models/mace-mp.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
from torch_geometric.data import Data
|
4 |
+
|
5 |
+
from ase import Atoms
|
6 |
+
from ase.calculators.calculator import all_changes
|
7 |
+
from atomind_mlip.models import MLIP
|
8 |
+
|
9 |
+
|
10 |
+
class MACE_MP_Medium(MLIP):
|
11 |
+
def __init__(self):
|
12 |
+
super().__init__()
|
13 |
+
self.name = "MACE-MP-0 (medium)"
|
14 |
+
self.version = "1.0.0"
|
15 |
+
|
16 |
+
fpath = hf_hub_download(repo_id="cyrusyc/mace-universal", subfolder="pretrained", filename="2023-12-12-mace-128-L1_epoch-199.model")
|
17 |
+
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
18 |
+
self.model = torch.load(fpath, map_location="cpu")
|
19 |
+
self.model.to(self.device)
|
20 |
+
self.implemented_properties = [
|
21 |
+
"energy",
|
22 |
+
"forces",
|
23 |
+
"stress",
|
24 |
+
]
|
25 |
+
|
26 |
+
def calculate(self, atoms: Atoms, properties: list[str], system_changes: dict = all_changes):
|
27 |
+
"""Calculate energies and forces for the given Atoms object"""
|
28 |
+
super().calculate(atoms, properties, system_changes)
|
29 |
+
|
30 |
+
output = self.forward(atoms)
|
31 |
+
|
32 |
+
self.results = {}
|
33 |
+
if "energy" in properties:
|
34 |
+
self.results["energy"] = output["energy"].item()
|
35 |
+
if "forces" in properties:
|
36 |
+
self.results["forces"] = output["forces"].cpu().detach().numpy()
|
37 |
+
if "stress" in properties:
|
38 |
+
self.results["stress"] = output["stress"].cpu().detach().numpy()
|
39 |
+
|
40 |
+
def forward(self, x: Data | Atoms) -> dict[str, torch.Tensor]:
|
41 |
+
"""Implement data conversion, graph creation, and model forward pass"""
|
42 |
+
# TODO
|
43 |
+
raise NotImplementedError
|
atomind_mlip/models/registry.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
MACE_MP_Medium:
|
3 |
+
username: cyrusyc
|
4 |
+
datetime: 2022-03-28T14:30:00 # TODO: Fake datetime
|
5 |
+
tasks:
|
6 |
+
- alexandria
|
7 |
+
- qmof
|
atomind_mlip/serve/README.md
ADDED
File without changes
|
atomind_mlip/tasks/README.md
ADDED
File without changes
|
atomind_mlip/tasks/__init__.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
REGISTRY_FILE = 'registry.yaml'
|
atomind_mlip/tasks/alexandria.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
URL = "https://alexandria.icams.rub.de/"
|
atomind_mlip/tasks/qmof.py
ADDED
File without changes
|
atomind_mlip/tasks/registry.yaml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
- alexandria
|
2 |
+
- qmof
|