Skip to content

Commit fded566

Browse files
committed
Merge branch 'main' into cu-h2o-rdf
# Conflicts: # uv.lock
2 parents 82a91db + 1f34ec2 commit fded566

333 files changed

Lines changed: 41773 additions & 7982 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pip-wheel-metadata/
4040
__pycache__/
4141
ml_peg/app/data/*
4242
!ml_peg/app/data/onboarding/
43+
!ml_peg/app/data/table_download/
4344
certs/
4445
ml_peg/calcs/surfaces/copper_water_interface/data/
4546
ml_peg/calcs/aqueous_solutions/bulk_water/data/

.jules/bolt.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 2024-05-19 - Caching YAML Load for Model Parsing
2+
**Learning:** `yaml.safe_load` on large configuration files like `models.yml` is significantly slower than parsing JSON or doing other basic IO. It can become a bottleneck when called repeatedly throughout an application's lifecycle (e.g., getting subsets of models, instantiating apps).
3+
**Action:** Always memoize or `@lru_cache` functions that load static, read-only configuration files (like `models.yml`) to prevent repeated disk I/O and parsing overhead.
4+
5+
## 2024-05-19 - Caching YAML Load for Framework Registry
6+
**Learning:** `yaml.safe_load` on `frameworks.yml` within `load_framework_registry()` was taking ~2-3 ms per call and it was repeatedly called for every framework entry via `get_framework_config()`. This was a micro-bottleneck, especially when dealing with lists or multiple frameworks.
7+
**Action:** Applied the `@lru_cache` and `deepcopy` pattern successfully again to `load_framework_registry()` and `get_framework_config()` to avoid caching a mutable dictionary directly and avoid repeated YAML I/O parsing.

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pre-commit install
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: v6.0.0
66
hooks:
77
- id: end-of-file-fixer
88
- id: mixed-line-ending
@@ -11,7 +11,7 @@ repos:
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
1313
# Ruff version.
14-
rev: v0.11.13
14+
rev: v0.15.5
1515
hooks:
1616
# Run the linter.
1717
- id: ruff-check
@@ -20,7 +20,7 @@ repos:
2020
- id: ruff-format
2121

2222
- repo: https://github.com/numpy/numpydoc
23-
rev: v1.8.0
23+
rev: v1.10.0
2424
hooks:
2525
- id: numpydoc-validation
2626
files: ^ml_peg/

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ python3 -m pip install git+https://github.com/ddmms/ml-peg.git
4040

4141
## Features
4242

43-
Coming soon!
43+
More details coming soon!
4444

4545

4646
## Development
@@ -66,6 +66,53 @@ Please refer to the [online documentation](https://ddmms.github.io/ml-peg/develo
6666
for information about contributing new benchmarks and models.
6767

6868

69+
### Command-line interface
70+
71+
To help run calculations, analysis, and the application, we provide the `ml_peg`
72+
command line tool, which is installed with the package. This provides the following
73+
commands:
74+
75+
```shell
76+
ml_peg app
77+
ml_peg calc
78+
ml_peg analyse
79+
ml_peg download
80+
ml_peg list
81+
```
82+
83+
For example, to run the X23 test with mace-mp-0a and orb-v3-consv-inf-omat, you can run:
84+
85+
```shell
86+
ml_peg calc --test X23 --models mace-mp-0a,orb-v3-consv-inf-omat
87+
```
88+
89+
A description of each subcommand, as well as valid options, can be listed using the
90+
`--help` option. For example:
91+
92+
```shell
93+
ml_peg calc --help
94+
```
95+
96+
The `ml_peg list` command provides a further set of subcommands:
97+
98+
```shell
99+
ml_peg list calcs
100+
ml_peg list analysis
101+
ml_peg list app
102+
ml_peg list models
103+
```
104+
105+
which list the available tests and categories that may be run for `ml_peg calc`,
106+
`ml_peg analyse` and `ml_peg app`, and the MLIPs that these can be run for.
107+
108+
109+
### Tutorials
110+
111+
We encourage developers new to the ML-PEG framework to work through the detailed
112+
step-by-step guides provided by our Jupyter Notebook tutorials:
113+
- [Adding a New Benchmark](docs/source/tutorials/python/adding_benchmark.ipynb) [![badge](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ddmms/ml-peg/blob/main/docs/source/tutorials/python/adding_benchmark.ipynb)
114+
115+
69116
## Docker/Podman images
70117

71118
You can use [Docker](https://www.docker.com) or [Podman](https://podman.io/) to build

conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import pytest
1010

11-
from ml_peg.models import models
11+
from ml_peg import models
1212

1313

1414
def pytest_addoption(parser):
@@ -31,6 +31,12 @@ def pytest_addoption(parser):
3131
default=None,
3232
help="MLIPs, in comma-separated list. Default is all models",
3333
)
34+
parser.addoption(
35+
"--models-file",
36+
action="store",
37+
default=None,
38+
help="Filepath to model definitions. Default models.yml in models directory.",
39+
)
3440

3541

3642
def pytest_configure(config):
@@ -41,6 +47,9 @@ def pytest_configure(config):
4147

4248
# Set current models from CLI input
4349
models.current_models = config.getoption("--models")
50+
model_file = config.getoption("--models-file")
51+
if model_file:
52+
models.models_file = model_file
4453

4554

4655
def pytest_collection_modifyitems(config, items):

docs/source/developer_guide/add_benchmarks.rst

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ the error with respect to DFT predictions of energies.
3434
Reference data may also include experimental data, or higher-accuracy theoretical predictions,
3535
e.g. CCSD(T).
3636

37+
Each metric in ``metrics.yml`` should have a ``level_of_theory`` field identifying its reference
38+
method. The app compares this string against the ``level_of_theory`` set in ``models.yml`` for each
39+
MLIP, flagging mismatches using the traffic light system. An exact string match is required.
40+
41+
.. warning::
42+
43+
Use the standard strings defined in :doc:`Levels of theory </developer_guide/levels_of_theory>`.
44+
A typo or inconsistent capitalisation (e.g. ``experiment`` instead of ``Experimental``) will
45+
cause incorrect warnings.
46+
3747
In some cases, metrics may also encode correct behaviour without a specific reference,
3848
such as by quantifying features of a known distribution (curvature, minima, etc.),
3949
or quantifying the stability of a simulation.
@@ -99,7 +109,7 @@ the same calculation is run for each model name-model pair:
99109
.. code-block:: python3
100110
101111
from ml_peg.models.get_models import load_models
102-
from ml_peg.models.models import current_models
112+
from ml_peg.models import current_models
103113
104114
MODELS = load_models(current_models)
105115
DATA_PATH = Path(__file__).parent / "data"
@@ -340,7 +350,7 @@ CLI (``ml_peg analyse``), a subset can be used using the ``--models`` option.
340350
from ml_peg.app import APP_ROOT
341351
from ml_peg.calcs import CALCS_ROOT
342352
from ml_peg.models.get_models import get_model_names
343-
from ml_peg.models.models import current_models
353+
from ml_peg.models import current_models
344354
345355
MODELS = get_model_names(current_models)
346356
CALC_PATH = CALCS_ROOT / [category] / [benchmark_name] / "outputs"
@@ -501,3 +511,72 @@ Building those components and their interactivity should become increasingly aut
501511
but less standard plots/interactions will need setting up.
502512

503513
For now, please contact us to help with this process.
514+
515+
Framework credit and custom group tags
516+
++++++++++++++++++++++++++++++++++++++
517+
518+
If a benchmark comes from an external benchmarking framework (for example, MLIP Audit),
519+
or you want to group benchmarks by a custom category (such as those involved in a
520+
paper), you can add a framework credit tag as follows:
521+
522+
1. Add/update the framework entry in ``ml_peg/app/utils/frameworks.yml``.
523+
524+
.. code-block:: yaml
525+
526+
mlip_audit:
527+
label: MLIP Audit
528+
color: "#1d4ed8"
529+
text_color: "#ffffff"
530+
url: "https://huggingface.co/spaces/InstaDeepAI/mlipaudit-leaderboard"
531+
logo: "https://raw.githubusercontent.com/instadeepai/mlipaudit/mlpeg-migration/InstaDeep_Logo.png"
532+
533+
2. Set ``framework_ids`` in the benchmark app constructor. This accepts either a
534+
single framework identifier or a sequence of them, so a benchmark can belong to
535+
multiple frameworks at once.
536+
537+
The app constructor also provides a ``include_ml_peg`` parameter. This is ``True``
538+
by default, which automatically adds the built-in ``ml_peg`` tag to benchmarks, so
539+
``framework_ids`` only needs to list *additional* or *alternative* frameworks. If
540+
you want to omit this tag, set ``include_ml_peg=False``.
541+
542+
For example:
543+
544+
.. code-block:: python3
545+
546+
# MLIP Audit only
547+
return SomeBenchmarkApp(
548+
name="SomeBenchmark",
549+
...,
550+
framework_ids="mlip_audit",
551+
include_ml_peg=False,
552+
)
553+
554+
555+
# MLIP Audit and the MACE Multihead paper
556+
return SomeBenchmarkApp(
557+
name="SomeBenchmark",
558+
...,
559+
framework_ids=["mlip_audit", "mace-multihead"],
560+
include_ml_peg=False,
561+
)
562+
563+
# ML-PEG (added by default) and the MACE Multihead paper
564+
return SomeBenchmarkApp(
565+
name="SomeBenchmark",
566+
...,
567+
framework_ids="mace-multihead",
568+
)
569+
570+
That is all that is required. The benchmark header shows one badge per framework,
571+
and the additional framework pages for non-default frameworks are populated
572+
automatically from this metadata.
573+
574+
Framework sections group matching benchmarks by category, omit the category
575+
summary table, and reuse the same benchmark tables and controls. Updating
576+
weights or thresholds there therefore updates the same benchmark views shown in
577+
the category pages.
578+
579+
The ``logo`` field is optional. It can point to a remote image URL or a local
580+
Dash asset path such as ``/assets/frameworks/my_framework_logo.png``. Use a
581+
browser-supported image format such as ``.svg``, ``.png``, or ``.jpg``/``.jpeg``;
582+
``.pdf`` is not supported. For best results, use a square logo image.

0 commit comments

Comments
 (0)