Skip to content

Add NequIP & Allegro to matbench leaderboard - #282

Merged
janosh merged 31 commits into
janosh:mainfrom
kavanase:main
Sep 8, 2025
Merged

Add NequIP & Allegro to matbench leaderboard#282
janosh merged 31 commits into
janosh:mainfrom
kavanase:main

Conversation

@kavanase

@kavanase kavanase commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

Description

This PR adds initial foundation potentials from the NequIP GNN and Allegro architectures, including both compliant and non-compliant (OMat) models.

Checklist

Please check the following items before submitting your PR:

  • I created a new folder and YAML metadata file models/<arch_name>/<model_variant>.yml for my submission. arch_name is the name of the architecture and model_variant.yml includes things like author details, training set names and important hyperparameters.
  • I added the new model as a new attribute Model.<arch_name> enum on the Model enum in enums.py.
  • I uploaded the energy/force/stress model prediction file for the WBM test set to Figshare or another cloud storage service (<yyyy-mm-dd>-<model_variant>-preds.csv.gz).
  • I uploaded the model-relaxed structures file to Figshare or another cloud storage service in JSON lines format (<yyyy-mm-dd>-wbm-IS2RE-FIRE.jsonl.gz). JSON Lines allows fast loading of small numbers of structures with pandas.read_json(lines=True, nrows=100) for inspection.
  • I uploaded the phonon predictions to Figshare or another cloud storage service (<yyyy-mm-dd>-kappa-103-FIRE-<values-of-dist|fmax|symprec>.gz).
  • I included the urls to the Figshare files in the YAML metadata file (models/<arch_name>/<model_variant>.yml). If not using Figshare I have included the urls to the cloud storage service in the description of the PR.
  • I included the test script (test_<arch_name>_<task>.py for task in discovery, kappa, diatomics) that generated the prediction files.

Additional Information (Optional)

  • I included a training script (train_<arch_name>.py) if I trained a model specifically for this benchmark.
  • I included a readme.md with additional details about my model.

@coderabbitai ignore

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@kavanase

Copy link
Copy Markdown
Contributor Author

@janosh I think this is nearly ready to go. The remaining issues that seem to be causing the pre-commit test failures are the k_SRME values in the configs. When I try running scripts/evals/kappa_srme.py, I get this same error for all models, so not sure what's causing this? I'm using the main branch, with it's requirements (i.e. pymatviz 0.16.0)

❯ python scripts/evals/kappa_srme.py
Evaluating kappa metrics for 38 models...
Skipping AlchemBERT: no kappa_103_path found

Processing AlphaNet-v1-OMA...
	✗ Error processing AlphaNet-v1-OMA: "None of [<Key.mat_id: 'material_id'>] are in the columns"
Skipping ALIGNN: no kappa_103_path found

Processing Allegro-OAM-L...
	✗ Error processing Allegro-OAM-L: "None of [<Key.mat_id: 'material_id'>] are in the columns"

Processing Allegro-MP-L...
	✗ Error processing Allegro-MP-L: "None of [<Key.mat_id: 'material_id'>] are in the columns"
Skipping BOWSR: no kappa_103_path found

Processing CHGNet...
	✗ Error processing CHGNet: "None of [<Key.mat_id: 'material_id'>] are in the columns"
Skipping CGCNN: no kappa_103_path found
Skipping CGCNN+P: no kappa_103_path found

Then also for the geo-opt analysis script:

❯ python scripts/evals/geo_opt.py
Traceback (most recent call last):
  File "/Users/kavanase/Packages/matbench-discovery/scripts/evals/geo_opt.py", line 40, in <module>
    df_dft_analysis = pd.read_csv(dft_analysis_file, index_col=0)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 1026, in read_csv
    return _read(filepath_or_buffer, kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 620, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 1620, in __init__
    self._engine = self._make_engine(f, self.engine)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 1880, in _make_engine
    self.handles = get_handle(
                   ^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pandas/io/common.py", line 765, in get_handle
    handle = gzip.GzipFile(  # type: ignore[assignment]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kavanase/miniconda3/envs/py312/lib/python3.12/gzip.py", line 192, in __init__
    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/kavanase/Packages/matbench-discovery/data/wbm/dft-geo-opt-symprec=1e-5-moyo=0.4.4.csv.gz'

The discovery analysis script works fine though.

@kavanase

Copy link
Copy Markdown
Contributor Author

Trying to use the compile-WBM script, I get:

❯ python data/wbm/compile_wbm_test_set.py
/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pymatgen/core/composition.py:1365: UserWarning: No Pauling electronegativity for Ne. Setting to NaN. This has no physical meaning, and is mainly done to avoid errors caused by the code expecting a float.
  syms: list[str] = sorted(sym_amt, key=lambda x: [get_el_sp(x).X, x])
/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pymatgen/core/composition.py:1365: UserWarning: No Pauling electronegativity for He. Setting to NaN. This has no physical meaning, and is mainly done to avoid errors caused by the code expecting a float.
  syms: list[str] = sorted(sym_amt, key=lambda x: [get_el_sp(x).X, x])
/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pymatgen/core/composition.py:1365: UserWarning: No Pauling electronegativity for Ar. Setting to NaN. This has no physical meaning, and is mainly done to avoid errors caused by the code expecting a float.
  syms: list[str] = sorted(sym_amt, key=lambda x: [get_el_sp(x).X, x])
Traceback (most recent call last):
  File "/Users/kavanase/Packages/matbench-discovery/data/wbm/compile_wbm_test_set.py", line 33, in <module>
    from matbench_discovery.structure import prototype
  File "/Users/kavanase/Packages/matbench-discovery/matbench_discovery/structure/prototype.py", line 16, in <module>
    from pymatviz.typing import AnyStructure
ImportError: cannot import name 'AnyStructure' from 'pymatviz.typing' (/Users/kavanase/miniconda3/envs/py312/lib/python3.12/site-packages/pymatviz/typing.py)

(with pymatviz==0.16.0)

@janosh

janosh commented Aug 29, 2025

Copy link
Copy Markdown
Owner

very nice work! 👍 thanks a lot for this submission @kavanase! 🙏 i'm very excited to add NequiP and Allegro to the benchmark!

thanks for reporting the data/wbm/compile_wbm_test_set.py import error. should be fixed in f3419a2

re the failing scripts/evals/kappa_srme.py, I haven't taken a closer look yet but at first glance seems like the column names are unexpected (e.g. mp_id instead of material_id). i'll take a closer look. no need for you to debug

@janosh

janosh commented Aug 29, 2025

Copy link
Copy Markdown
Owner

also, apologies about all the coderabbit spam. looks like it went absolutely crazy on this PR. i wonder if there's a gh CLI command to delete all bot comments on a PR

coderabbitai[bot]

This comment was marked as outdated.

@janosh

janosh commented Aug 29, 2025

Copy link
Copy Markdown
Owner

this script seems to mostly bring the kappa pred files into the expected format (except there's still an extra nesting level that doesn't play well with pd.read_json). need to change trains now but will have another go later.

standardize_kappa_preds.py
"""Convert kappa predictions to Matbench format."""

import json
import os
import shutil

import pandas as pd
from pymatviz.enums import Key

from matbench_discovery import today
from matbench_discovery.enums import MbdKey, Model

DRY_RUN = False
col_map = {
    "mp_id": Key.mat_id,
    "name": Key.formula,
    "max_stress": Key.max_stress,
    "reached_max_steps": "reached_max_steps",
    "imaginary_freqs": Key.has_imag_ph_modes,
    "frequencies": Key.ph_freqs,
    "kappa_TOT_RTA": MbdKey.kappa_tot_rta,
    "kappa_P_RTA": MbdKey.kappa_p_rta,
    "kappa_C": MbdKey.kappa_c,
    "weights": Key.mode_weights,
    "qpoints": Key.q_points,
    "mode_kappa_TOT": MbdKey.mode_kappa_tot_rta,
    "kappa_TOT_ave": MbdKey.kappa_tot_avg,
    "initial_space_group_number": Key.spg_num,
    "mode_kappa_TOT_ave": MbdKey.mode_kappa_tot_avg,
}
cols_to_drop = [
    "DFT_kappa_TOT_ave",
    "SRD",
    "SRE",
    "SRME",
    "errors",
    "error_traceback",
    "symprec_tests",
    "redirected_to_symm",
]

models_updated: dict[str, dict[str, str | list[str]]] = {}


for model in Model:
    if model.kappa_103_path is None or not os.path.isfile(model.kappa_103_path):
        print(f"{model.label=} kappa_103_path={model.kappa_103_path!r} does not exist")
        continue

    df_ml = pd.read_json(model.kappa_103_path)
    if MbdKey.mode_kappa_tot_avg in df_ml:
        print(f"{model.label=} already processed")
        continue  # skip if already processed

    old_cols = df_ml.columns.copy()
    df_ml = df_ml.rename(columns=col_map)

    renamed_cols = {
        str(old_col): str(new_col)
        for old_col, new_col in zip(old_cols, df_ml)
        if old_col != new_col
    }
    old_cols = df_ml.columns.copy()
    df_ml = df_ml.drop(columns=cols_to_drop, errors="ignore")
    dropped_cols = [col for col in old_cols if col not in df_ml]

    # if dataframe was modified, backup the original file
    if renamed_cols or dropped_cols:
        models_updated[model.key] = {
            "renamed_cols": renamed_cols,
            "dropped_cols": dropped_cols,
        }
        if not DRY_RUN:
            shutil.copy(model.kappa_103_path, f"{model.kappa_103_path}.bak")
            df_ml.to_json(model.kappa_103_path)
            print(f"{model.label=} new column names: {df_ml.columns}")
    else:
        print(f"{model.label=} no changes")


print(f"\n\n{len(models_updated)=}")

for model_key, actions in models_updated.items():
    print(f"{model_key=} {actions=}")

# write updated models to file
with open(f"{today}-kappa-model-files-updated.json", mode="w") as file:
    json.dump(models_updated, file, indent=2)

@kavanase

Copy link
Copy Markdown
Contributor Author

Thanks for this @janosh! 🙏

Repository owner deleted a comment from coderabbitai Bot Aug 29, 2025
…+phonon pred files + geo opt analysis files to MBD figshare

- Introduced a `--timeout` argument in the CLI for HTTP request timeouts, defaulting to 30 seconds.
- Added a `set_timeout` function in `figshare.py` to manage the timeout configuration for API calls.
- Updated the `make_request` function to utilize the configured timeout.
- Adjusted the upload process to reflect the new timeout settings.
- Modified model YAML files to include new metrics and updated URLs for predictions.
- Added nested progress bar to show individual file upload states
@samblau

samblau commented Sep 2, 2025

Copy link
Copy Markdown

Excited to see this merged soon!

@janosh janosh added the new model Model submission label Sep 8, 2025
@janosh

This comment was marked as outdated.

@kavanase

kavanase commented Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

@kavanase very nearly ready to merge. there are some TODOs left

checkpoint_url: https://url.of/model-checkpoint-license # TODO: Zenodo? / Nequip.net

can we address those now that the checkpoints are up https://www.nequip.net/models/mir-group/Allegro-MP-L:0.1?

Fixed now! I missed this entry for the Allegro models on the first draft 🤦

@kavanase

kavanase commented Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

@janosh thanks very much for pushing through with this!
I see the Tests / scripts (scripts/evals/discovery.py) (pull_request) appears as passing, but looking at the outputs it's showing download errors for the updated NequIP/Allegro figshare files?

image

@janosh janosh left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks again for this submission @kavanase! outstanding work 👍 🚀

been hoping for the day when Allegro and Nequip are added to the leaderboard for almost 2 years now! so many people kept asking me why those we're missing and all I could say is lack of time...
very glad that's now over 🙏

but looking at the outputs it's showing download errors for the updated NequIP/Allegro figshare files?

i think i just forgot to re-publish the Figshare article after uploading these files. should be good now

build of local:ty,ase,pymatgen,pymatviz@1 for python@python3.12 exceeds tier max size 250MiB: 697.5MiB
standardize YAML notes title casing
@janosh
janosh merged commit e885b8f into janosh:main Sep 8, 2025
9 of 11 checks passed
@kavanase

kavanase commented Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

Great to see this merged, thanks very much @janosh !!

janosh added a commit that referenced this pull request Jul 31, 2026
* Initial commit of NequIP/Allegro models

* Add NequIP MP model

* Add Allegro models

* Clean up

* Add config files

* Add MIR logo

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename test script files

* Add lean READMEs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Formatting

* Remove ipy delimiters

* Update yamls for pre-commit

* Update configs to new format

* geo-opt metrics for nequip & allegro MPtrj and Omat models

* bump pymatviz from 0.16.0 to 0.17.1 to fix #282 (comment)

auto-format nequip + allegro hyperparam YAMLs

* add --timeout arg to figshare CLI and upload nequip+allegro discovery+phonon pred files + geo opt analysis files to MBD figshare

- Introduced a `--timeout` argument in the CLI for HTTP request timeouts, defaulting to 30 seconds.
- Added a `set_timeout` function in `figshare.py` to manage the timeout configuration for API calls.
- Updated the `make_request` function to utilize the configured timeout.
- Adjusted the upload process to reflect the new timeout settings.
- Modified model YAML files to include new metrics and updated URLs for predictions.
- Added nested progress bar to show individual file upload states

* add/update figshare download ULRs for allegro + nequip geo opt pred + analysis files

* fix tests

* update legacy metrics.geo_opt.pred_file_url in all model YAMLs following removal of legacy geo_opt figshare article

https://figshare.com/articles/dataset/28187999 was superseded by https://figshare.com/articles/dataset/28642406

* fix copy-paste error: Nequip -> Allegro

* add e_form and e_hull parity plots and per-element hull distance errors for Allegro and NequIP

* fill placeholder model checkpoint license URLs with https://creativecommons.org/licenses/by/4.0/legalcode

* fix link check

/home/runner/work/_actions/lycheeverse/lychee-action/v2/entrypoint.sh: eval: line 58: syntax error near unexpected token `('

--exclude https://figshare.com/articles/(dataset|files) \

* update date_added to today

* Update checkpoint URL in allegro-MP-L-0.1.yml

* Update checkpoint URL in allegro-OAM-L-0.1.yml

* fix ASE optim_cls and filter_cls type hints across model test scripts

* try ty with just just ase + pymatgen

build of local:ty,ase,pymatgen,pymatviz@1 for python@python3.12 exceeds tier max size 250MiB: 697.5MiB

* just ase as ty additional dep

standardize YAML notes title casing

* fix dead links

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new model Model submission

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants