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

Metrics refactor pt1 #1411

Merged
merged 14 commits into from
Aug 17, 2022
Merged

Conversation

ishanashastri
Copy link
Contributor

@ishanashastri ishanashastri commented Aug 13, 2022

This PR implements part 1 of the Metrics Refactor, which entails removing metrics from the Evaluator class and storing raw deep-copied metrics in the State class. The Evaluator class now stores evaluation metric names instead of metric instances, which are matched against the model-defined model.val_metrics to indicate which metrics will be computed at eval time. Additionally, instead of storing all computed metrics as part of state.current_metrics, both the raw non-computed training and validation metrics are now stored separately as part of state.train_metrics and state.eval_metrics.

All tests updated and passing, regression tests will be conducted once PR 2 is ready.

Note: PR for part 2 will also touch a lot of the same code, so expect some refactors and clean up (mostly in the Trainer class) after this PR is merged in.

Closes CO-679

@ishanashastri ishanashastri marked this pull request as ready for review August 16, 2022 00:36
@ishanashastri ishanashastri requested review from knighton and a team as code owners August 16, 2022 00:36
Copy link
Contributor

@hanlint hanlint left a comment

Choose a reason for hiding this comment

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

Overall LGTM, a few questions and suggested code changes for style nits.

composer/core/evaluator.py Outdated Show resolved Hide resolved
composer/core/evaluator.py Outdated Show resolved Hide resolved
composer/core/state.py Show resolved Hide resolved
composer/core/state.py Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@bandish-shah bandish-shah left a comment

Choose a reason for hiding this comment

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

LGTM, please see my nit about the TODO

composer/trainer/trainer_hparams.py Outdated Show resolved Hide resolved
Copy link
Contributor

@hanlint hanlint left a comment

Choose a reason for hiding this comment

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

One more quick change, and I think this is ready to merge!

composer/core/state.py Outdated Show resolved Hide resolved
@ishanashastri ishanashastri merged commit b47ecd9 into mosaicml:dev Aug 17, 2022
This was referenced Aug 17, 2022
hanlint pushed a commit that referenced this pull request Aug 26, 2022
This PR implements the second half of the metrics refactor (#1411) that updates the training loop and all the Composer models.

The training loop now uses the previously added state.train_metrics and state.eval_metrics from #1411 to perform all training and evaluation on the correct set of metrics.

The main changes with respect to models is that the models now have split up validate() into eval_forward() and update_metrics() methods, which run an evaluation forward pass and update the metrics with the outputs of the evaluation forward pass respectively. This is mainly to get rid of the double forward pass (#467).
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