-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip tuner algorithms on fast dev (#3903)
* skip on fast dev * fix error * changelog * fix recursive issue * combine tests * pep8 * move logic to base funcs * fix mistake * Update pytorch_lightning/tuner/lr_finder.py Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com> * pep Co-authored-by: William Falcon <waf2107@columbia.edu> Co-authored-by: Nicki Skafte <nugginea@gmail.com> Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com> Co-authored-by: chaton <thomas@grid.ai>
- Loading branch information
1 parent
41c9bee
commit 4f3160b
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
from pytorch_lightning import Trainer | ||
from tests.base import EvalModelTemplate | ||
|
||
|
||
@pytest.mark.parametrize('tuner_alg', ['batch size scaler', 'learning rate finder']) | ||
def test_skip_on_fast_dev_run_batch_scaler(tmpdir, tuner_alg): | ||
""" Test that tuner algorithms are skipped if fast dev run is enabled """ | ||
|
||
hparams = EvalModelTemplate.get_default_hparams() | ||
model = EvalModelTemplate(**hparams) | ||
trainer = Trainer( | ||
default_root_dir=tmpdir, | ||
max_epochs=2, | ||
auto_scale_batch_size=True if tuner_alg == 'batch size scaler' else False, | ||
auto_lr_find=True if tuner_alg == 'learning rate finder' else False, | ||
fast_dev_run=True | ||
) | ||
expected_message = f'Skipping {tuner_alg} since `fast_dev_run=True`' | ||
with pytest.warns(UserWarning, match=expected_message): | ||
trainer.tune(model) |