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

Attach data refactor and tuner bugs [4/n] #7258

Merged
merged 38 commits into from
Apr 30, 2021
Merged

Conversation

carmocca
Copy link
Contributor

@carmocca carmocca commented Apr 28, 2021

What does this PR do?

Attach data refactor:

  • Each of the trainer functions is now responsible for calling attach_data to register their DataLoaders/DataModule.
  • No longer need to pass DataLoaders to trainer._launch()

Tuner bugs:

  • trainer.tuner.lr_find() and trainer.tuner.scale_batch_size() now calls trainer.tune() internally. This solves a bug where the trainer state was not set properly as we set it in trainer.tune()
  • trainer.tune() now has arguments for the different tuning functions.
  • trainer.tune() now returns the tuning result. The result is a {'scale_batch_size': Optional[int], 'lr_find': Optional[_LRFinder]}

The tuning changes are tied to the attach_data changes because the tuner relied on the setup_fit function which has been removed in this PR.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • [n/a] Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@carmocca carmocca added this to the v1.3 milestone Apr 28, 2021
@carmocca carmocca self-assigned this Apr 28, 2021
@pep8speaks
Copy link

pep8speaks commented Apr 28, 2021

Hello @carmocca! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-30 13:34:56 UTC

@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #7258 (70a16ea) into master (ea2287e) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #7258   +/-   ##
======================================
- Coverage      91%     91%   -0%     
======================================
  Files         199     199           
  Lines       12808   12807    -1     
======================================
- Hits        11688   11686    -2     
- Misses       1120    1121    +1     

@carmocca carmocca changed the title [WIP] Attach data refactor and tuner bugs. [WIP] Attach data refactor and tuner bugs [3/n] Apr 28, 2021
@kaushikb11
Copy link
Contributor

@carmocca

Why is this one PR doing so many things?

Non-exhaustive typing
Moved _validate_data_hooks into ConfigValidator
Each of the trainer functions is now responsible of calling attach_data to register their DataLoaders/DataModule.
No longer need to pass DataLoaders to _launch
Deprecate trainer.tuner.lr_find() and trainer.tuner.scale_batch_size() in favor of trainer.tune(). This solves a bug where the trainer state was not set properly as we set it in trainer.tune()
trainer.tune() now has arguments for the different tuning functions.
trainer.tune() now returns the tuning result.
Fixed bug where scale_batch_size would fail if the number of trials was 0

@carmocca
Copy link
Contributor Author

carmocca commented Apr 28, 2021

Why is this one PR doing so many things?

All of those things are tied together. I just wrote the list of changes so it's easier for reviewers to follow.

edit: clarified the change list at the top and opened #7262 with parts of this PR

@carmocca carmocca changed the title [WIP] Attach data refactor and tuner bugs [3/n] [WIP] Attach data refactor and tuner bugs [4/n] Apr 28, 2021
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
@carmocca carmocca added the bug Something isn't working label Apr 29, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
docs/source/api_references.rst Outdated Show resolved Hide resolved
Comment on lines +921 to +922
# links data to the trainer
self.data_connector.attach_data(model, val_dataloaders=val_dataloaders, datamodule=datamodule)
Copy link
Contributor

Choose a reason for hiding this comment

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

Side question: In trainer.fit we allow trainer.fit(datamodule) but not for test and validate. Do you know why? Did we decide explicit naming by keyword is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye. I actually plan to open a PR adding this.

Not doing it yet as it would give myself conflicts

docs/source/advanced/training_tricks.rst Outdated Show resolved Hide resolved
docs/source/advanced/lr_finder.rst Outdated Show resolved Hide resolved
docs/source/advanced/training_tricks.rst Outdated Show resolved Hide resolved
@carmocca carmocca added the ready PRs ready to be merged label Apr 30, 2021

max_lr: maximum learning rate to investigate

num_training: number of learning rates to test
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR. num_training param doesn't seem intuitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc: @SkafteNicki

I'm just moving the docstring around here

Copy link
Contributor

@kaushikb11 kaushikb11 left a comment

Choose a reason for hiding this comment

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

LGTM!

carmocca and others added 2 commits April 30, 2021 14:42
Co-authored-by: Kaushik B <45285388+kaushikb11@users.noreply.github.com>
@mergify mergify bot removed the has conflicts label Apr 30, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGMT !

@carmocca carmocca enabled auto-merge (squash) April 30, 2021 13:35
@carmocca carmocca merged commit 5af086a into master Apr 30, 2021
@carmocca carmocca deleted the attach-data-refactor branch April 30, 2021 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged refactor tuner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants