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

Save metadata and integration when save_weights_only is set #2396

Merged
merged 19 commits into from
Aug 1, 2023

Conversation

eracah
Copy link
Contributor

@eracah eracah commented Jul 26, 2023

What does this PR do?

When save_weights_only is specified to the Trainer, only the weights are saved and no metadata or integrations are saved. However, when doing inference it is often necessary to have the metadata along with the weights. The only current way to get metadata and integrations is to save everything in the state_dict (including the very large optimizer state). This PR enables saving the weights and the metadata and integrations, so you can save an inference-friendly checkpoint without the extra heft of the optimizer or other (not necessary for inference) state fields.

What issue(s) does this change relate to?

fix CO-2226

@eracah eracah marked this pull request as draft July 26, 2023 22:45
@eracah eracah marked this pull request as ready for review July 27, 2023 00:54
@eracah eracah requested a review from a team as a code owner July 27, 2023 00:54
@eracah eracah requested review from dskhudia and dakinggg July 27, 2023 00:55
Copy link
Contributor

@mvpatel2000 mvpatel2000 left a comment

Choose a reason for hiding this comment

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

What if we always included these in the weights only option? I'm just a little hesitant to add more trainer args...

@dakinggg
Copy link
Contributor

dakinggg commented Jul 27, 2023

@mvpatel2000 the issue with always including metadata is that its kind of an API change. If there is code out there relying on a weights only checkpoint only having one key. That being said, it may be worth making that change, not sure. But I think this is the right implementation given that. At a later date we will remove this flag and make it the default

Copy link
Contributor

@dakinggg dakinggg left a comment

Choose a reason for hiding this comment

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

LGTM pending the resolution of Mihir's comment

composer/trainer/trainer.py Outdated Show resolved Hide resolved
@eracah eracah changed the title Add a save_weights_and_metadata_only option to the Trainer Save metadata and integration when save_weights_only is set Jul 28, 2023
@eracah
Copy link
Contributor Author

eracah commented Jul 28, 2023

@mvpatel2000, @dakinggg, ok fixed to add metadata saving to the save_weights_only option

Copy link
Contributor

@mvpatel2000 mvpatel2000 left a comment

Choose a reason for hiding this comment

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

Lgtm! Minor comment that we should probably avoid a warnings.warn in this case.

composer/trainer/trainer.py Outdated Show resolved Hide resolved
docs/source/trainer/checkpointing.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@dakinggg dakinggg left a comment

Choose a reason for hiding this comment

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

Lgtm thanks for taking care of this

composer/callbacks/checkpoint_saver.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
tests/trainer/test_checkpoint.py Show resolved Hide resolved
@eracah eracah enabled auto-merge (squash) August 1, 2023 21:48
@eracah eracah merged commit ff11b18 into mosaicml:dev Aug 1, 2023
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.

4 participants