Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement saving and loading of models #19

Merged
merged 8 commits into from
Dec 11, 2023
Merged

Implement saving and loading of models #19

merged 8 commits into from
Dec 11, 2023

Conversation

frostedoyster
Copy link
Collaborator

@frostedoyster frostedoyster commented Dec 8, 2023

@frostedoyster frostedoyster marked this pull request as ready for review December 8, 2023 11:40
@frostedoyster frostedoyster changed the title First attempt Implement saving and loading of models Dec 8, 2023
Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

Very nice export. I am not sure where we want the export to be called. Should this be controlled by the train script or the trainer?

src/metatensor/models/soap_bpnn/train.py Outdated Show resolved Hide resolved
src/metatensor/models/soap_bpnn/train.py Outdated Show resolved Hide resolved
src/metatensor/models/utils/model_io.py Outdated Show resolved Hide resolved
src/metatensor/models/utils/model_io.py Outdated Show resolved Hide resolved
Comment on lines 14 to 18
ARCHITECTURE_NAME = "soap_bpnn"

DEFAULT_MODEL_HYPERS = OmegaConf.to_container(
OmegaConf.load(ARCHITECTURE_CONFIG_PATH / "soap_bpnn.yaml")
)["model"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't have to set hypers to a default value or is there a specific reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this way, it's much easier to use the model from Python. For example, the test I've written for the model_io module would have been much more difficult. In general, I feel like, if we want to support model use from Python as well, we need to make the hypers available from Python as well

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay I get your point but then maybe it makes sense to provide a general parser and store the hypers as dictionary in the init of each architecture.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like this is short enough for the moment... Perhaps we can change it once we have more models?

@frostedoyster
Copy link
Collaborator Author

frostedoyster commented Dec 8, 2023

EDIT: I now understand the question

I would say at least in part the trainer (because we need to checkpoint). The last model save (at the end of training) can be done either by the trainer or by train.py. I would say by train.py, so that we can have that line in one file instead of in all the trainers. Moreover, some trainers might not support checkpointing (thinking of linear algebra)

@PicoCentauri
Copy link
Contributor

I would say at least in part the trainer (because we need to checkpoint). The last model save (at the end of training) can be done either by the trainer or by train.py. I would say by train.py, so that we can have that line in one file instead of in all the trainers. Moreover, some trainers might not support checkpointing (thinking of linear algebra)

I am more and more thinking that we should create a class for training with a train method and save method. With this we can do checkpoints within and in the end train.py just calls save again. What do you say?

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

I have a minor idea that we should integrate the save_model maybe as a class method. Othwerwise it is very nice!

@frostedoyster frostedoyster merged commit 44e4f11 into main Dec 11, 2023
8 checks passed
@frostedoyster frostedoyster deleted the model-io branch December 11, 2023 08:58
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.

3 participants