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

Code cleaning in preparation for #7258 [3/n] #7262

Merged
merged 2 commits into from
Apr 29, 2021
Merged

Conversation

carmocca
Copy link
Contributor

@carmocca carmocca commented Apr 28, 2021

What does this PR do?

Some changes related to #7258 but not critical which I have split into this PR

  • Non-exhaustive typing
  • Moved _validate_data_hooks into ConfigValidator
  • Fixed bug where scale_batch_size would fail if the number of trials was 0
  • Moved scale_batch_size tests from tests/trainer/test_trainer_tricks.py to tests/tuner/test_scale_batch_size.py

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?
  • [n/a] Did you make sure to update the documentation with your changes? (if necessary)
  • 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 bug Something isn't working refactor labels Apr 28, 2021
@carmocca carmocca added this to the v1.3 milestone Apr 28, 2021
@carmocca carmocca self-assigned this Apr 28, 2021
@codecov
Copy link

codecov bot commented Apr 28, 2021

Codecov Report

Merging #7262 (1eeedac) into master (7a48db5) will decrease coverage by 0%.
The diff coverage is 76%.

@@          Coverage Diff           @@
##           master   #7262   +/-   ##
======================================
- Coverage      91%     91%   -0%     
======================================
  Files         199     199           
  Lines       12799   12793    -6     
======================================
- Hits        11701   11675   -26     
- Misses       1098    1118   +20     

@carmocca carmocca changed the title Code cleaning in preparation for #7258 Code cleaning in preparation for #7258 [3/n] Apr 28, 2021
Comment on lines 30 to +39
def scale_batch_size(
trainer,
model: LightningModule,
trainer: 'pl.Trainer',
model: 'pl.LightningModule',
mode: str = 'power',
steps_per_trial: int = 3,
init_val: int = 2,
max_trials: int = 25,
batch_arg_name: str = 'batch_size',
**fit_kwargs
):
) -> Optional[int]:
Copy link
Contributor

Choose a reason for hiding this comment

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

this should have some caveats that the tuner doesn't work with things like deepspeed or sharded ddp which have different behavior on multiple gpus right?

Copy link
Member

Choose a reason for hiding this comment

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

Agree with this. In general scale_batch_size is not really that well tested in multi-gpu settings. Even the most simple case where you are using multiple gpus of different types (so maybe one with 8 gb of vram and one with 16 gb of vram) it will not assign higher batch size to the second device.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SkafteNicki since you are the most familiar with the tuner limitations, can you open a PR showing warnings or raising an error for these cases?

Copy link
Member

Choose a reason for hiding this comment

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

@carmocca will do. I basically think that anything else than single cpu/gpu batch scaling is not supported

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.

LGTM !

@tchaton tchaton self-requested a review April 29, 2021 12:12
Copy link
Member

@SkafteNicki SkafteNicki 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 carmocca merged commit a5ac3f8 into master Apr 29, 2021
@carmocca carmocca deleted the changes-for-7258 branch April 29, 2021 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants