Skip to content

Commit 8de9a81

Browse files
benrhodes26ben rhodes
andauthored
Omol models (#120)
* Add dispersion models and update internal check script * Update model with charge+spin conditioning. Add model stubs. Still need to add weights * Add paths. Handle charge and spin in atoms.info * Final working implementation * Update readmes * Address comments * Address comments --------- Co-authored-by: ben rhodes <benrhodes@bens-MacBook-Pro.local>
1 parent 25185e8 commit 8de9a81

File tree

14 files changed

+900
-294
lines changed

14 files changed

+900
-294
lines changed

MODELS.md

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
1-
## Released Models
2-
3-
4-
| Model Name | Link | MD5 Hash | Matbench Discovery | D3 Corrections | Notes |
5-
|------------|------|----------|---------------------|-----------------|-------|
6-
| **orb-v1** | [link](https://orbitalmaterials-public-models.s3.us-west-1.amazonaws.com/forcefields/orbff-v1-20240827.ckpt) | 92897eda08609425ee001955c7885139 | Yes | No | Full dataset pretraining, MPTraj + Alexandria finetuning |
7-
| **orb-mptraj-only-v1** | [link](https://orbitalmaterials-public-models.s3.us-west-1.amazonaws.com/forcefields/orbff-mptraj-only-v1-20240827.ckpt) | ff42a2bc1e1f50b5f3ee2a20b83cf3a2 | Yes | No | MPTraj pretraining and finetuning only |
8-
| **orb-d3-v1** | [link](https://orbitalmaterials-public-models.s3.us-west-1.amazonaws.com/forcefields/orb-d3-v1-20240902.ckpt) | 470c7d3482ead3bc97cd4b46382d5e47 | No | Yes | Full dataset pretraining, MPTraj + Alexandria finetuning, integrated D3 corrections |
9-
| **orb-d3-sm-v1** | [link](https://orbitalmaterials-public-models.s3.us-west-1.amazonaws.com/forcefields/orb-d3-sm-v1-20240902.ckpt) | 64fe91603e46ad5fa695525e3f1e9397 | No | Yes | First 10 layers of a pretrained model finetuned on mptrj + alexandria with D3 corrections |
10-
| **orb-d3-xs-v1** | [link](https://orbitalmaterials-public-models.s3.us-west-1.amazonaws.com/forcefields/orb-d3-xs-v1-20240902.ckpt) | 79d042f9f16c4407795426a75498fbb7 | No | Yes | First 5 layers of a pretrained model finetuned on mptrj + alexandria with D3 corrections |
11-
12-
13-
14-
### Matbench Discovery Results
15-
16-
17-
### orb-v1: Full dataset pretraining, MPtraj + Alexandria finetuning
18-
19-
```
20-
orb 10k unique
21-
F1 0.846577 0.988213 0.867282
22-
DAF 5.394101 6.389021 6.015771
23-
Precision 0.898971 0.976700 0.919641
24-
Recall 0.799953 1.000000 0.820563
25-
Accuracy 0.951678 0.976700 0.961608
26-
TPR 0.799953 1.000000 0.820563
27-
FPR 0.017979 1.000000 0.012939
28-
TNR 0.982021 0.000000 0.987061
29-
FNR 0.200047 0.000000 0.179437
30-
TP 34258.000000 9767.000000 27031.000000
31-
FP 3850.000000 233.000000 2362.000000
32-
TN 210288.000000 0.000000 180184.000000
33-
FN 8567.000000 0.000000 5911.000000
34-
MAE 0.030884 0.019012 0.030589
35-
RMSE 0.080986 0.064470 0.079003
36-
R2 0.798803 0.907903 0.815941
37-
```
38-
### orb-mptraj-only-v1: MPTraj pretraining, MPTraj finetuning
39-
40-
```
41-
orb 10k unique
42-
F1 0.752143 0.963193 0.761336
43-
DAF 4.267540 6.076994 4.667345
44-
Precision 0.711221 0.929000 0.713505
45-
Recall 0.798062 1.000000 0.816040
46-
Accuracy 0.912341 0.929000 0.921787
47-
TPR 0.798062 1.000000 0.816040
48-
FPR 0.064804 1.000000 0.059130
49-
TNR 0.935196 0.000000 0.940870
50-
FNR 0.201938 0.000000 0.183960
51-
TP 34177.000000 9290.000000 26882.000000
52-
FP 13877.000000 710.000000 10794.000000
53-
TN 200261.000000 0.000000 171752.000000
54-
FN 8648.000000 0.000000 6060.000000
55-
MAE 0.044745 0.040998 0.046230
56-
RMSE 0.093426 0.102950 0.093919
57-
R2 0.732243 0.780546 0.739879
58-
```
1+
## Pretrained models
592

3+
We provide several pretrained models that can be used to calculate energies, forces & stresses of atomic systems. All models are provided in the `orb_models.forcefield.pretrained` module.
4+
5+
### OrbMol Models
6+
7+
These models are a continuation of the `orb-v3` series, but are trained on the [Open Molecules 2025 (OMol25)](https://arxiv.org/pdf/2505.08762) dataset—over 100M high-accuracy DFT calculations (ωB97M-V/def2-TZVPD) on diverse molecular systems including metal complexes, biomolecules, and electrolytes.
8+
9+
There are two options:
10+
* `orb-v3-conserative-omol`
11+
* `orb-v3-direct-omol`
12+
13+
See below for more explanation of this naming convention. Both models have `inf` neighbors, ensuring a continuous PES.
14+
15+
### [V3 Models](https://arxiv.org/abs/2504.06231)
16+
V3 models use the following naming convention: ```orb-v3-X-Y-Z``` where:
17+
- `X`: Model type - `direct` or `conservative`. Conservative models compute forces and stress via backpropagation, which is a physically motivated choice that appears necessary for certain types of simulation such as NVE Molecular dynamics. Conservative models are signficantly slower and use more memory than their direct counterparts.
18+
19+
- `Y`: Maximum neighbors per atom: `20` or `inf`. A finite cutoff of `20` induces discontinuties in the PES, which can lead to significant inaccuracies for certain types of highly sensitive calculations (e.g. calculations involving Hessians). However, finite cutoffs reduce the amount of edge processing in the network, reducing latency and memory use.
20+
21+
- `Z`: Training dataset - `omat` or `mpa`. Both of these dataset consist of small bulk crystal structures. We find that models trained on such data can generalise reasonably well to non-periodic systems (organic molecules) or partially periodic systems (slabs), but caution is advised in these scenarios.
22+
23+
#### Features:
24+
- Model compilation using PyTorch 2.6.0+, enabling faster inference while maintaining support for dynamic graph sizes
25+
- Wider architecture (1024 vs 512) with fewer layers (5 vs 15) compared to v2, resulting in 2-3x faster performance with similar parameter count
26+
- Two variants available: direct models and conservative models (forces/stress computed via backpropagation)
27+
- Trained on the larger, more diverse OMat24 dataset
28+
- Improved edge embeddings using Bessel-Spherical Harmonic outer products (8 Bessel bases, Lmax=3)
29+
- Enhanced stability through Huber loss and a ZBL pair repulsion term added to forces
30+
- Models available with both unlimited neighbors and 20-neighbor maximum configurations
31+
- New confidence head providing intrinsic uncertainty estimates for predictions
32+
33+
#### Advice / Caveats
34+
- Consider using `orb-v3-conservative-120-omat` for initial testing, specifying `precision='float32-highest'` when loading the model. This is the most computational expensive but accurate configuration. If this level of accuracy meets your needs, then other models and precisions can be investigated to improve speed and system-size scalability.
35+
- We do not advise using the `-mpa` models unless they are required for compatability with benchmarks (for example, Matbench Discovery). They are generally less performant.
36+
- Orb-v3 models are **compiled** by default and use Pytorch's dynamic batching, which means that they do not need to recompile as graph sizes change. However, the first call to the model will be slower, as the graph is compiled by torch.
37+
38+
### [V2 Models](https://arxiv.org/abs/2410.22570)
39+
40+
- `orb-v2` - trained on [MPTraj](https://figshare.com/articles/dataset/Materials_Project_Trjectory_MPtrj_Dataset/23713842?file=41619375) + [Alexandria](https://alexandria.icams.rub.de/).
41+
- `orb-mptraj-only-v2` - trained on the MPTraj dataset only to reproduce our second Matbench Discovery result. We do not recommend using this model for general use.
42+
- `orb-d3-v2` - trained on MPTraj + Alexandria with integrated D3 corrections. In general, we recommend using this model, particularly for systems where dispersion interactions are important. This model was trained to predict D3-corrected targets and hence is the same speed as `orb-v2`. Incorporating D3 into the model like this is substantially faster than using analytical D3 corrections.
43+
- `orb-d3-{sm,xs}-v2` - Smaller versions of `orb-d3-v2`. The `sm` model has 10 layers, whilst the `xs` model has 5 layers.
44+
45+
#### Features
46+
- v2 models use a smoothed cosine distance cutoff for the attention mechanism, ensuring a continuous PES.
47+
- The force predictions now have net zero forces, meaning they are much more stable for MD simulations.
48+
- The models are generally more accurate (Increase in 2-3% on the matbench discovery dataset).
49+
50+
### [V1 Models](https://arxiv.org/abs/2410.22570)
51+
52+
Our initial release. These models were state of the art performance on the matbench discovery dataset at time of release, but have since been superceeded and removed.

README.md

Lines changed: 35 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,61 +27,21 @@ Alternatively, you can use Docker to run orb-models; [see instructions below](#d
2727

2828
### Updates
2929

30-
**April 2025**: We have released the [Orb-v3 set of potentials](https://arxiv.org/abs/2504.06231). These models improve substantially over Orb-v2, in particular:
30+
**August 2025**: Release of the OrbMol potentials (blog post forthcoming).
3131

32-
- Model compilation using PyTorch 2.6.0+, enabling faster inference while maintaining support for dynamic graph sizes
33-
- Wider architecture (1024 vs 512) with fewer layers (5 vs 15) compared to v2, resulting in 2-3x faster performance with similar parameter count
34-
- Two variants available: direct models and conservative models (forces/stress computed via backpropagation)
35-
- Trained on the larger, more diverse OMat24 dataset
36-
- Improved edge embeddings using Bessel-Spherical Harmonic outer products (8 Bessel bases, Lmax=3)
37-
- Enhanced stability through Huber loss and a ZBL pair repulsion term added to forces
38-
- Models available with both unlimited neighbors and 20-neighbor maximum configurations
39-
- New confidence head providing intrinsic uncertainty estimates for predictions
32+
* Trained on the [Open Molecules 2025 (OMol25)](https://arxiv.org/pdf/2505.08762) dataset—over 100M high-accuracy DFT calculations (ωB97M-V/def2-TZVPD) on diverse molecular systems including metal complexes, biomolecules, and electrolytes.
33+
* Architecturally similar to the highly-performant Orb-v3 models, but now explicit total charges and spins can be passed as input.
34+
* To get started with these models, see: [How to specify total charge and spin for OrbMol](#how-to-specify-total-charge-and-spin-for-orbmol).
4035

36+
**April 2025**: Release of the [Orb-v3 set of potentials](https://arxiv.org/abs/2504.06231).
4137

42-
**Oct 2024**: We have released the [Orb-v2 set of potentials](https://arxiv.org/abs/2410.22570). These models have two major changes:
43-
- v2 models use a smoothed cosine distance cutoff for the attention mechanism. This is a more physically motivated cutoff that is better suited for MPNNs.
44-
- The force predictions now have net zero forces, meaning they are much more stable for MD simulations.
45-
- The models are generally more accurate (Increase in 2-3% on the matbench discovery dataset).
38+
**Oct 2024**: Release of the [Orb-v2 set of potentials](https://arxiv.org/abs/2410.22570).
4639

47-
These models are substantially better for all use cases, so we have removed the v1 models from the new orb-models package. To load the v1 models, please install the v0.3.2 version of orb-models.
40+
**Sept 2024**: Release of v1 models - state of the art performance on the matbench discovery dataset.
4841

49-
**Sept 2024**: v1 models released - state of the art performance on the matbench discovery dataset.
5042

51-
52-
### Pretrained models
53-
54-
We provide several pretrained models that can be used to calculate energies, forces & stresses of atomic systems. All models are provided in the `orb_models.forcefield.pretrained` module.
55-
56-
#### V3 Models
57-
V3 models use the following naming convention:
58-
59-
```orb-v3-X-Y-Z```
60-
61-
where:
62-
- `X`: Model type (`direct` or `conservative`) - determines how forces/stress are computed
63-
- `Y`: Maximum neighbors per atom (`20` or `inf`)
64-
- `Z`: Training dataset (`omat` or `mpa`)
65-
66-
For example, `orb-v3-conservative-inf-omat` is a model that:
67-
- Computes forces/stress as gradients of energy
68-
- Has effectively infinite neighbors (120 in practice)
69-
- Was trained on the OMat24 dataset
70-
71-
72-
Orb-v3 models are **compiled** by default and use Pytorch's dynamic batching, which means that they do not need to recompile as graph sizes change. However, the first call to the model will be slower, as the graph is compiled by torch.
73-
74-
75-
**We suggest using models trained on OMAT24**, as these models are more performant and the data they are trained on uses newer pseudopotentials in VASP (PBE54 vs PBE52)*. `-mpa` models should be used if compatability with benchmarks (for example, Matbench Discovery) is required.
76-
77-
#### V2 Models
78-
79-
- `orb-v2` - trained on [MPTraj](https://figshare.com/articles/dataset/Materials_Project_Trjectory_MPtrj_Dataset/23713842?file=41619375) + [Alexandria](https://alexandria.icams.rub.de/).
80-
- `orb-mptraj-only-v2` - trained on the MPTraj dataset only to reproduce our second Matbench Discovery result. We do not recommend using this model for general use.
81-
- `orb-d3-v2` - trained on MPTraj + Alexandria with integrated D3 corrections. In general, we recommend using this model, particularly for systems where dispersion interactions are important. This model was trained to predict D3-corrected targets and hence is the same speed as `orb-v2`. Incorporating D3 into the model like this is substantially faster than using analytical D3 corrections.
82-
- `orb-d3-{sm,xs}-v2` - Smaller versions of `orb-d3-v2`. The `sm` model has 10 layers, whilst the `xs` model has 5 layers.
83-
84-
For more information on the models, please see the [MODELS.md](MODELS.md) file.
43+
### Available models
44+
See [MODELS.md](MODELS.md) for a full list of available models along with guidance.
8545

8646

8747
### Usage
@@ -104,11 +64,9 @@ orbff = pretrained.orb_v3_conservative_inf_omat(
10464
)
10565
atoms = bulk('Cu', 'fcc', a=3.58, cubic=True)
10666
graph = atomic_system.ase_atoms_to_atom_graphs(atoms, orbff.system_config, device=device)
107-
atoms = bulk('Cu', 'fcc', a=3.58, cubic=True)
108-
graph = atomic_system.ase_atoms_to_atom_graphs(atoms, orbff.system_config, device=device)
10967

110-
# Optionally, batch graphs for faster inference
111-
# graph = batch_graphs([graph, graph, ...])
68+
# If you have several graphs, batch them like so:
69+
# graph = batch_graphs([graph1, graph2, ...])
11270

11371
result = orbff.predict(graph, split=False)
11472

@@ -160,6 +118,28 @@ print("Optimized Energy:", atoms.get_potential_energy())
160118

161119
Or you can use it to run MD simulations. The script, an example input xyz file and a Colab notebook demonstration are available in the [examples directory.](./examples) This should work with any input, simply modify the input_file and cell_size parameters. We recommend using constant volume simulations.
162120

121+
#### How to specify total charge and spin for OrbMol
122+
123+
The OrbMol models *require* total charge and spin to be specified. This can be done by setting them in `atoms.info` dictionary.
124+
125+
```python
126+
import ase
127+
from ase.build import molecule
128+
from orb_models.forcefield import atomic_system, pretrained
129+
from orb_models.forcefield.base import batch_graphs
130+
131+
device = "cpu" # or device="cuda"
132+
orbff = pretrained.orb_v3_conservative_omol(
133+
device=device,
134+
precision="float32-high", # or "float32-highest" / "float64
135+
)
136+
atoms = molecule("C6H6")
137+
atoms.info["charge"] = 1.0 # total charge
138+
atoms.info["spin"] = 0.0 # total spin
139+
graph = atomic_system.ase_atoms_to_atom_graphs(atoms, orbff.system_config, device=device)
140+
141+
result = orbff.predict(graph, split=False)
142+
```
163143

164144
#### Confidence head (Orb-v3 Models Only)
165145

@@ -216,16 +196,9 @@ The dataset should be an [ASE sqlite database](https://wiki.fysik.dtu.dk/ase/ase
216196
```python
217197
python finetune.py --dataset=<dataset_name> --data_path=<your_data_path> --base_model=<base_model>
218198
```
219-
Where base_model is one of:
220-
- "orb_v3_conservative_inf_omat"
221-
- "orb_v3_conservative_20_omat"
222-
- "orb_v3_direct_inf_omat"
223-
- "orb_v3_direct_20_omat"
224-
- "orb_v2"
225-
226-
After the model is finetuned, checkpoints will, by default, be saved to the ckpts folder in the directory you ran the finetuning script from.
199+
Where base_model is an element of `orb_models.forcefield.pretrained.ORB_PRETRAINED_MODELS.keys()`.
227200

228-
You can use the new model and load the checkpoint by:
201+
After the model is finetuned, checkpoints will, by default, be saved to the ckpts folder in the directory you ran the finetuning script from. You can use the new model and load the checkpoint by:
229202
```python
230203
from orb_models.forcefield import pretrained
231204

finetune.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,13 @@ def run(args):
259259
wandb.define_metric("step")
260260
wandb.define_metric("finetune_step/*", step_metric="step")
261261

262+
graph_targets = ["energy", "stress"] if model.has_stress else ["energy"]
262263
loader_args = dict(
263264
dataset_name=args.dataset,
264265
dataset_path=args.data_path,
265266
num_workers=args.num_workers,
266267
batch_size=args.batch_size,
267-
target_config={"graph": ["energy", "stress"], "node": ["forces"]},
268+
target_config={"graph": graph_targets, "node": ["forces"]},
268269
)
269270
train_loader = build_train_loader(
270271
**loader_args,
@@ -379,7 +380,7 @@ def main():
379380
)
380381
parser.add_argument(
381382
"--lr",
382-
default=3e-04,
383+
default=3e-4,
383384
type=float,
384385
help="Learning rate. 3e-4 is purely a sensible default; you may want to tune this for your problem.",
385386
)

internal/check.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)