Skip to content

Commit 9793d99

Browse files
authored
Add docs as ipynb, and reduce time for adsorption example (#1304)
* small changes * update github codespaces install * clean up install content for consistency across tutorials * make sure ipynb works for uma tutorial * long timeout
1 parent 2f34701 commit 9793d99

19 files changed

Lines changed: 196 additions & 51 deletions

File tree

.devcontainer/postCreateCommand.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#!/bin/bash
2-
if [ -f packages/requirements.txt ]; then pip install -r packages/requirements.txt; fi
3-
if [ -f packages/requirements-optional.txt ]; then pip install -r packages/requirements-optional.txt; fi
4-
pip install -e packages/fairchem-core[dev,docs,adsorbml]
5-
pip install -e packages/fairchem-data-oc[dev]
6-
pip install -e packages/fairchem-demo-ocpapi[dev]
7-
pip install -e packages/fairchem-applications-cattsunami
8-
pip install jupytext
2+
pip install -e packages/fairchem-core[docs,adsorbml,quacc] -e packages/fairchem-data-oc[dev] -e packages/fairchem-applications-cattsunami jupytext
93

104
# Convert all .md docs to ipynb for easy viewing in vscode later!
115
find ./docs -name '*.md' -exec jupytext --to ipynb {} \;

.github/workflows/build_docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
# Set FAST_DOCS only if not a push to main
4242
FAST_DOCS: ${{ (github.event_name != 'push' || github.ref != 'refs/heads/main') && 'true' || '' }}
4343
run: |
44+
# Convert MyST markdown files to Jupyter notebooks if needed to get download as ipynb buttons
45+
jupytext --to ipynb ./docs/uma_tutorials/uma_tutorial.md
46+
# find ./docs/ -name "*.md" -exec grep -q "format_name: myst" {} \; -print0 | xargs -0 jupytext --to ipynb
4447
jupyter-book build docs
4548
4649
- name: Upload documentation artifact

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ copyright : "2024" # Copyright year to be placed in the foote
1414
# See https://jupyterbook.org/content/execute.html
1515
execute:
1616
execute_notebooks: cache
17-
timeout: 7200
17+
timeout: 14400
1818
allow_errors: false
1919

2020
# Define the name of the latex output file for PDF builds

docs/catalysts/examples_tutorials/OCP-introduction.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,41 @@ Based on https://atct.anl.gov/Thermochemical%20Data/version%201.118/species/?spe
5656

5757
The first step is getting a checkpoint for the model we want to use. UMA is currently the state-of-the-art model and will provide total energy estimates at the RPBE level of theory if you use the "OC20" task.
5858

59-
This next cell will automatically download the checkpoint from huggingface and load it.
60-
1. You need to first request access to the UMA model here: https://huggingface.co/facebook/UMA
61-
2. You also need to run `huggingface-cli login` and follow the instructions to get a token from huggingface to authenticate to the servers.
59+
60+
````{admonition} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
61+
:class: dropdown
62+
63+
64+
1. Install the necessary packages using pip, uv etc
65+
```{code}
66+
:tags: [skip-execution]
67+
68+
! pip install fairchem-core fairchem-data-oc fairchem-applications-cattsunami
69+
```
70+
71+
2. Get access to any necessary huggingface gated models
72+
* Get and login to your Huggingface account
73+
* Request access to https://huggingface.co/facebook/UMA
74+
* Create a Huggingface token at https://huggingface.co/settings/tokens/ with the permission "Permissions: Read access to contents of all public gated repos you can access"
75+
* Add the token as an environment variable using `huggingface-cli login` or by setting the HF_TOKEN environment variable.
76+
77+
```{code}
78+
:tags: [skip-execution]
79+
80+
# Login using the huggingface-cli utility
81+
# ! huggingface-cli login
82+
83+
# alternatively,
84+
import os
85+
os.environ['HF_TOKEN'] = 'MY_TOKEN'
86+
```
87+
88+
````
6289

6390
If you find your kernel is crashing, it probably means you have exceeded the allowed amount of memory. This checkpoint works fine in this example, but it may crash your kernel if you use it in the NRR example.
6491

92+
This next cell will automatically download the checkpoint from huggingface and load it.
93+
6594
```{code-cell}
6695
from __future__ import annotations
6796

docs/catalysts/examples_tutorials/adsorbml_walkthrough.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ The [AdsorbML](https://arxiv.org/abs/2211.16486) paper showed that pre-trained m
1717

1818
The latest UMA models are now total-energy models, and the results for the adsorption energy are even more impressive ([see the paper for details and benchmarks](https://ai.meta.com/research/publications/uma-a-family-of-universal-models-for-atoms/)). The AdsorbML package helps you with automated multi-adsorbate placement, and will automatically run calculations using the ML models to find the best sites to sample.
1919

20+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
21+
:class: dropdown
22+
23+
```{include} ../../core/simplified_install.md
24+
```
25+
26+
:::
27+
2028
## Define desired adsorbate+slab system
2129

2230
```{code-cell} ipython3

docs/catalysts/examples_tutorials/adsorption_energies/adsorption_energies.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ Expert adsorption energies
1717

1818
One of the most common tasks in computational catalysis is calculating the binding energies or adsorption energies of small molecules on catalyst surfaces.
1919

20+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
21+
:class: dropdown
22+
23+
```{include} ../../core/simplified_install.md
24+
```
25+
26+
:::
27+
2028
```{code-cell} ipython3
2129
from __future__ import annotations
2230
@@ -189,7 +197,7 @@ if fast_docs:
189197
relaxation_steps = 20
190198
else:
191199
num_bulks = -1
192-
num_sites = 100
200+
num_sites = 20
193201
relaxation_steps = 300
194202
```
195203

docs/catalysts/examples_tutorials/cattsunami_tutorial.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ else:
3030
optimization_steps = 300
3131
```
3232

33+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
34+
:class: dropdown
35+
36+
```{include} ../../core/simplified_install.md
37+
```
38+
39+
:::
40+
3341
## Do enumerations in an AdsorbML style
3442

3543
```{code-cell} ipython3

docs/catalysts/examples_tutorials/ocpapi.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ Python library for programmatic use of the [Open Catalyst Demo](https://open-cat
1616

1717
## Installation
1818

19-
Ensure you have Python 3.9.1 or newer, and install `ocpapi` using:
19+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
20+
:class: dropdown
2021

21-
```{code-cell} ipython3
22-
---
23-
tags: ["skip-execution"]
24-
---
25-
! pip install -q ocpapi
22+
```{include} ../../core/simplified_install.md
2623
```
2724

25+
:::
26+
2827
## Quickstart
2928

3029
The following examples are used to search for *OH binding sites on Pt surfaces. They use the `find_adsorbate_binding_sites` function, which is a high-level workflow on top of other methods included in this library. Once familiar with this routine, users are encouraged to learn about lower-level methods and features that support more advanced use cases.

docs/core/common_tasks/ase_calculator.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ predictor = pretrained_mlip.get_predict_unit("uma-s-1", device="cuda")
2727
calc = FAIRChemCalculator(predictor, task_name="oc20")
2828
```
2929

30+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
31+
:class: dropdown
32+
33+
```{include} ../../core/simplified_install.md
34+
```
35+
:::
36+
3037
## Default mode
3138

3239
UMA is designed for both general-purpose usage (single or batched systems) and single-system long rollout (MD simulations, relaxations, etc.). For general-purpose use, we suggest using the [default settings](https://github.com/facebookresearch/fairchem/blob/main/src/fairchem/core/units/mlip_unit/api/inference.py#L92). This is a good trade-off between accuracy, speed, and memory consumption and should suffice for most applications. In this setting, on a single 80GB H100 GPU, we expect a user should be able to compute on systems as large as 50k-100k neighbors (depending on their atomic density). Batching is also supported in this mode.

docs/core/common_tasks/batch_inference.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Batch inference with UMA models
22

3+
:::{note} Need to install fairchem-core or get UMA access or getting permissions/401 errors?
4+
:class: dropdown
5+
6+
```{include} ../../core/simplified_install.md
7+
```
8+
:::
9+
310
If your application requires predictions over many systems you can run batch inference using
411
UMA models to use compute more efficiently and improve GPU utilization. Below we show some easy ways to run batch
512
inference over batches created at runtime or loading from a dataset. If you want to learn more about the different
@@ -39,8 +46,7 @@ preds["energy"][0]
3946
preds["forces"][batch.batch == 0]
4047
```
4148

42-
Batch inference using a dataset and a dataloader
43-
------------------------------------------------
49+
## Batch inference using a dataset and a dataloader
4450

4551
If you are running predictions over more structures than you can fit in memory, you can run inference using
4652
a torch Dataloader,
@@ -60,8 +66,8 @@ for batch in loader:
6066
preds = predictor.predict(batch)
6167
```
6268

63-
Inference over heterogenous batches
64-
-----------------------------------
69+
## Inference over heterogenous batches
70+
6571
For the odd cases where you want to batch systems to be computed with different task predictions
6672
(ie molecules and materials), you can take advantage of UMA models and do it in a single batch
6773
as follows,

0 commit comments

Comments
 (0)