Skip to content

Update to metatrain v2026.4 and fix uncertainty under rotational averaging - #161

Open
ppegolo wants to merge 13 commits into
mainfrom
update-metatrain-2026.4
Open

Update to metatrain v2026.4 and fix uncertainty under rotational averaging#161
ppegolo wants to merge 13 commits into
mainfrom
update-metatrain-2026.4

Conversation

@ppegolo

@ppegolo ppegolo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

The metatrain pin no longer resolved against a released version. Bumping it to
v2026.4 pulls in metatomic-torch 0.1.17, which deprecates two ModelOutput
arguments we passed: quantity is dropped, and per_atom becomes sample_kind.
Our own per_atom arguments stay as they are.

It also fixes the uncertainty methods when rotational averaging is on. They were
called on the SymmetrizedCalculator, which does not have the attributes they
need, so they raised an AttributeError as soon as rotational_average_order
was set. They now go to the calculator it wraps, since uncertainties are not
rotationally averaged. Nothing tested the two together, hence the silence.

metatrain v2026.4 requires metatomic-torch >=0.1.17, which deprecates two
ModelOutput arguments this package still passed:

- `quantity` is deprecated outright, so it is dropped;
- `per_atom` is replaced by `sample_kind`, which takes "atom"/"system"
  rather than a boolean.

The `per_atom` flag stays in this package's own public signatures
(`get_energy_uncertainty`, `get_energy_ensemble`, `_calculate_dos`); only the
translation into a `ModelOutput` changes. `metatomic-ase` is pinned to the
>=0.1.3 release that goes with metatomic-torch 0.1.17.
`rotational_average_order` replaces `self.calculator` with a
`SymmetrizedCalculator`, which has neither `_calculate_uncertainty` nor
`_energy_uq_key` nor `run_model`: every uncertainty method raised an
`AttributeError` as soon as rotational averaging was enabled. No test
combined the two, so this went unnoticed.

Uncertainty outputs are not rotationally averaged, so they are requested from
the wrapped calculator, reached through a `_base_calculator` property that
unwraps `SymmetrizedCalculator` when there is one.
Register pet-omol-{s,m,l} as available models, and give them their own
metadata: the authors and references of the model paper
(doi:10.1088/2632-2153/ae6417), plus the OMol25 dataset paper. The
dataset reference is listed under `model` because `references` only
accepts the `implementation`, `architecture` and `model` keys.
Register pet-mols-s as an available model, and as a UQ-capable one since
the released checkpoints are wrapped in an LLPR uncertainty model. It is
not a universal potential, so it gets its own description on top of its
own authors and reference (arXiv:2603.06236).
@ppegolo
ppegolo marked this pull request as ready for review August 13, 2026 12:56
The test suite is parametrized over UPET_AVAILABLE_MODELS, so registering
PET-OMOL and PET-MOLS enrolled them in tests written around materials
models, and 11 of them failed.

The non-conservative regime used to require both non-conservative forces
and stresses. Models trained on non-periodic data (PET-OMOL) only predict
the forces, so they are now run with the forces alone, leaving the stress
to backpropagation. PET-MOLS has no non-conservative outputs at all and
is listed as such.

The remaining failures came from the tests themselves: they assumed every
non-MAD model shares one set of authors and a universal-potential
description, they hardcoded PET-SPICE as the only model without
non-conservative outputs, and they evaluated every model on stretched
diamond, which is far enough out of PET-MOLS' domain that its uncertainty
exceeds the threshold above which the calculator warns.
Delete UPET_NO_NC_STRESS_MODELS: it was never used, and the calculator
already reads the same fact from the model capabilities.

Inline the PET-OMOL and PET-MOLS metadata in their branches, like the
other models, instead of hoisting them to module constants and looking the
dataset name up in a one-entry dict.

The metadata test used to reproduce the branches of get_upet_metadata, so
it could only fail if one of the two copies was edited on its own. Test
one model per family against literal values instead.

Also document the new models, and report the missing non-conservative
forces rather than "forces and stresses", since the stress alone is now
tolerated.
It followed the list of conservative-only checkpoints, and so read as an
explanation of the PET-MOLS entries in it.
Comment thread src/upet/calculator.py Outdated
Comment on lines +126 to +127
PET-OMol models only predict non-conservative forces, so their stress
is computed by backpropagation even when this is set.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks a bit confusing, how can a model for molecules have no conservative forces, but at the same time have conservative stresses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You can still use it in the bulk if you want, and in that case it's fine to compute (conservative) stress. But this comment is confusing, so I'll get rid of it.

Comment thread src/upet/calculator.py Outdated
Comment on lines +179 to +181
if nc_stress_key not in model_outputs:
# the stress is left to backpropagation
nc_regime = "forces"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need to fall back to this option? Our models typically either have or don't have the nc forces and stresses. Besides, I'm not a particular fan of having such implicit silent swaps of a model behavior

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's not silent because we just checked nc forces are available in the line above. It isn't a fallback, it is just a flag saying such a model only supports nc forces (like OMol models). Happy to discuss a better design if you dislike this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants