Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Now multiple checkpoints will be saved after using -stopk option in train_model.py#4978

Open
hamjam wants to merge 13 commits into
facebookresearch:mainfrom
hamjam:multiple_checkpoint
Open

Now multiple checkpoints will be saved after using -stopk option in train_model.py#4978
hamjam wants to merge 13 commits into
facebookresearch:mainfrom
hamjam:multiple_checkpoint

Conversation

@hamjam

@hamjam hamjam commented Mar 10, 2023

Copy link
Copy Markdown

Patch description

In this PR, the train_model.py script has the option to keep and store multiple checkpoints based on validation metrics. Some checkpoints that have best validation metrics during training will be kept in the directory specified by --model-file. Resolves #4970

Testing steps

To test this PR, you can run something like parlai train_model --task babi:task10k:1 --model seq2seq --model-file seq2seq/babi_task10k --batchsize 32 --validation-every-n-secs 30 -stopk 5 -vstep 50
Note that -vstep option must be exist to save and store 5 top checkpoints in this example. For me, the list of files in the -model-file directory after 1350 steps of training is like this:
2023-03-10_16h39_48

@facebook-github-bot

Copy link
Copy Markdown

Hi @hamjam!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@klshuster klshuster left a comment

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.

thanks for adding this! Could you please include a test?

Comment on lines +639 to +647
if (
opt['validation_metric_mode'] == 'max'
and self.best_k_models[-1][1] >= opt['validation_cutoff']
) or (
opt['validation_metric_mode'] == 'min'
and self.best_k_models[-1][1] <= opt['validation_cutoff']
):
logging.info('task solved! stopping.')
return True

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.

i think this check requires that we look at self.best_k_models[0], right? since we're looking at the best metric

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My idea here was that we want the last saved model's metric to be better than validation_cutoff so I checked the last one with self.best_k_models[-1]

@github-actions

Copy link
Copy Markdown

This PR has not had activity in 30 days. Closing due to staleness.

@github-actions github-actions Bot added the stale label May 19, 2023
@klshuster klshuster added donotreap Avoid automatically marking as stale. and removed stale labels May 22, 2023
@klshuster

Copy link
Copy Markdown
Contributor

@jxmsML any interest in taking over this PR?

@hamjam

hamjam commented Jun 5, 2023 via email

Copy link
Copy Markdown
Author

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

Labels

CLA Signed donotreap Avoid automatically marking as stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep multiple checkpoints during training

3 participants