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

Remove all old timing calls #594

Merged
merged 23 commits into from
Mar 1, 2022
Merged

Remove all old timing calls #594

merged 23 commits into from
Mar 1, 2022

Conversation

ravi-mosaicml
Copy link
Contributor

@ravi-mosaicml ravi-mosaicml commented Feb 24, 2022

  1. Remove all uses of state.max_epochs; replaced with state.max_duration -- specifically in stochastic depth (Remove old timing calls from stochastic depth #229) and sequential length warmup (Remove old timing calls from Sequential Length Warmup #226). However, it does not fix the latter, as we still need to update the algorithm to support max_duration in terms of tokens or samples.
  2. Replaced all state.step with int(state.timer.batch)
  3. Replaced all state.epoch with int(state.timer.epoch)
  4. Replaced all state.batch_idx with int(state.timer.batch_in_epoch)
  5. Removed the constraints that max_duration be specified in epochs; it can now be in any unit. Added test cases for specify max duration in batches.
  6. Added a helper method to the Time class to convert it to a timestring (with a test case)

Closes #146
Closes #229
Closes #512

1. Remove all uses of `state.max_epochs`; replaced with `state.max_duration`
2. Replaced all `state.step` with `int(state.timer.batch)`
3. Replaced all `state.epoch` with `int(state.timer.epoch)`
4. Removed the constraints that max_duration be specified in epochs; it can now be in any unit. Added test cases.
5. Added a helper method to the `Time` class to convert it to a timestring (with a test case)

Closes #146
Closes #229
Closes #512
@ravi-mosaicml ravi-mosaicml changed the title Finish removing all old timing calls Remove all old timing calls Feb 24, 2022
@ravi-mosaicml ravi-mosaicml added this to the v0.4.1 milestone Feb 24, 2022
@ravi-mosaicml ravi-mosaicml marked this pull request as ready for review February 24, 2022 07:16
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.

Hmm would it make sense to attach to state the epoch, etc. properties? That would reduce the code verbosity here and also be easier for developers to access directly.

Copy link
Contributor

@ajaysaini725 ajaysaini725 left a comment

Choose a reason for hiding this comment

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

Overall looks great just a few comments

composer/__init__.py Show resolved Hide resolved
composer/algorithms/stochastic_depth/stochastic_depth.py Outdated Show resolved Hide resolved
composer/core/time.py Show resolved Hide resolved
tests/trainer/test_scale_schedule.py Show resolved Hide resolved
@ravi-mosaicml
Copy link
Contributor Author

Hmm would it make sense to attach to state the epoch, etc. properties? That would reduce the code verbosity here and also be easier for developers to access directly.

Unfortunately, this would lead to naming conflicts, since batch is already defined on state. If we bound it directly on the state, then we would need to use a different name on the state object -- e.g. batch_idx, sample_idx. I think this could lead to confusion if it's called state.epoch_idx on the state and timer.epoch on the timer (it also wouldn't be that much less verbose -- saves two characters now!)

I could rename it in both places, but am not a huge fan of having everything in the timer be _idx'ed.

Alternatively, we could rename batch to batch_data? Also not a huge fan of that.

Agree it would be nice if these properties were more visible, but a good solution doesn't come to mind. Thoughts?

@ravi-mosaicml
Copy link
Contributor Author

Random thought - should we have a doctest here to test for from composer import ____ imports that we expect to work (that way if someone changes something within a module like callbacks that somehow breaks importing directly from Composer we catch it here)

Any import from a submodule will attempt to load the parent module's __init__.py, so our tests already check to ensure that the parent's __init__.py is bug-free. As for ensuring that, say, composer.callbacks doesn't have a bug in it, we should use the highest-level import whenever possible (e.g. from composer import Trainer, not from composer.trainer.trainer import Trainer) in the tests. But going to leave that out of this PR as that would be a larger change.

@hanlint
Copy link
Contributor

hanlint commented Feb 28, 2022

Good point on the naming conflicts -- let's keep them in state.timer for now then.

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.

For the method cards, the actual READMEs should sit in the composer/algorithms/ folder, with a symlink in the docs/source.

@ravi-mosaicml
Copy link
Contributor Author

For the method cards, the actual READMEs should sit in the composer/algorithms/ folder, with a symlink in the docs/source.

Whoops, good catch. Just fixed this.

@ravi-mosaicml ravi-mosaicml merged commit 1002758 into dev Mar 1, 2022
@ravi-mosaicml ravi-mosaicml deleted the ravi/remove_max_epochs branch March 1, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants