Skip to content

Check input model hypers when restarting trainings - #1232

Open
pfebrer wants to merge 6 commits into
metatensor:mainfrom
pfebrer:restart_model_hypers
Open

Check input model hypers when restarting trainings#1232
pfebrer wants to merge 6 commits into
metatensor:mainfrom
pfebrer:restart_model_hypers

Conversation

@pfebrer

@pfebrer pfebrer commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This is a first design of something that was discussed today in the devel meeting.

When restarting, it should be checked that if the user has provided model hypers in the input yaml, those match the hypers present in the checkpoint.

This enables the possibility that in the future, architectures will allow not only perfect matches, but also updating the model to some compatible hypers. This is for example the case in #1209 , which is what spawned the discussion leading to this PR.

@Luthaf @PicoCentauri could you check if something like this would work?


📚 Documentation preview 📚: https://metatrain--1232.org.readthedocs.build/en/1232/

return self.outputs

def restart(self, dataset_info: DatasetInfo) -> "PET":
def restart(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I think this this is the canoncial place! Very good.

Comment thread src/metatrain/utils/hypers.py
return diff


def raise_hypers_mismatch(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here. I would think there is already something. But maybe I am wrong.

Comment thread src/metatrain/utils/hypers.py
@Luthaf

Luthaf commented Jul 31, 2026

Copy link
Copy Markdown
Member

the overall design looks good to me!

@pfebrer

pfebrer commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Ok this is ready for a final review

@pfebrer
pfebrer force-pushed the restart_model_hypers branch from 6f2c41b to be37440 Compare July 31, 2026 15:31

@jwa7 jwa7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this looks good and I like what it enables, but I want to question how restrictive this is. For instance one of the current CI failure looks like:

[Mismatch 1] soap
 Previous: {'max_angular': 2, 'max_radial': 4, 'cutoff': {'radius': 5.0, 'width': 0.5}}
 New: {'max_radial': 4, 'max_angular': 2}

and I'm wondering if this is what we want - are implied default hypers no longer acceptable?

# This should work, as we are not changing the hypers
model.restart(dataset_info=dataset_info)
model.restart(dataset_info=dataset_info, model_hypers={})
model.restart(dataset_info=dataset_info, model_hypers=minimal_model_hypers)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about same hypers but in a different order?

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.

We can add the check just in case

Comment thread src/metatrain/utils/hypers.py
@pfebrer

pfebrer commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Yes that one should work, but that's good this is why we have tests 😄

@pfebrer

pfebrer commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

However it's not obvious what should be the behavior there. People would expect that whatever is not specified in the yaml is the defaults or the current hypers of the model?

@pfebrer

pfebrer commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Maybe we can start by covering only the unambiguous case:

  • For the missing keys, if defaults match the current model's hypers, all good (covers the case of restarting training with the same file).
  • If not, ask user to specify what they want to use.

In principle this would be for nested keys, since for top-level ones we are assuming the missing keys are the current model hypers. But we could also be more strict there if you think it's not fine?

@pfebrer

pfebrer commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

I was planning to do something different @HaoZeke , so I will revert. In any case, I think pushing into branches of other people without asking first or having been asked for a review is not the way to go 😅

@pfebrer

pfebrer commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Ah well you were asked for a review, but that is just the automatic one for being the maintainer of dpa3 haha

@HaoZeke

HaoZeke commented Aug 16, 2026

Copy link
Copy Markdown
Member

oops, my bad

@pfebrer
pfebrer force-pushed the restart_model_hypers branch 2 times, most recently from 0078884 to 7b537ae Compare August 25, 2026 09:27
@pfebrer

pfebrer commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@PicoCentauri I implemented dealing with nested keys as I proposed here: #1232 (comment)

Could you check if that is ok? Then I will add this to the changelog and possibly to the docs and we could merge 👍

Comment on lines +121 to +127
if default_hypers is not None:
hypers_keys = list(new_hypers.keys())
merged = OmegaConf.merge(
OmegaConf.create(default_hypers), OmegaConf.create(new_hypers)
)
merged = OmegaConf.to_container(merged)
new_hypers = {k: merged[k] for k in hypers_keys}

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.

@PicoCentauri this is mainly the new change in the logic

@pfebrer
pfebrer force-pushed the restart_model_hypers branch from 2b5ef8b to 896c9bc Compare August 31, 2026 14:16
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.

5 participants