speed-up testing (#504)

* extend CI timeout

* add short MNIST

* lower dataset and stop thr

* refactor imports

* formatting

* early stop

* play params

* play params

* minor refactoring

# Conflicts:
#	pytorch_lightning/testing/__init__.py
#	pytorch_lightning/testing/lm_test_module.py
#	pytorch_lightning/testing/lm_test_module_base.py
#	pytorch_lightning/testing/lm_test_module_mixins.py
#	pytorch_lightning/testing/model.py
#	pytorch_lightning/testing/model_base.py
#	pytorch_lightning/testing/model_mixins.py
#	pytorch_lightning/testing/test_module.py
#	pytorch_lightning/testing/test_module_base.py
#	pytorch_lightning/testing/test_module_mixins.py

* typo

Co-Authored-By: Ir1dXD <sirius.caffrey@gmail.com>

* Revert "refactor imports"

This reverts commit b86aee92

* update imports
This commit is contained in:
Jirka Borovec
2019-11-28 12:06:05 -05:00
committed by William Falcon
co-authored by Ir1dXD
parent 9785a3e78e
commit 47659daa5f
12 changed files with 257 additions and 253 deletions
+33 -33
View File
@@ -15,7 +15,7 @@ from pytorch_lightning.trainer.dp_mixin import (
determine_root_gpu_device,
)
from pytorch_lightning.utilities.debugging import MisconfigurationException
from . import testing_utils
import tests.utils as tutils
PRETEND_N_OF_GPUS = 16
@@ -25,13 +25,13 @@ def test_multi_gpu_model_ddp2():
Make sure DDP2 works
:return:
"""
if not testing_utils.can_run_gpu_test():
if not tutils.can_run_gpu_test():
return
testing_utils.reset_seed()
testing_utils.set_random_master_port()
tutils.reset_seed()
tutils.set_random_master_port()
model, hparams = testing_utils.get_model()
model, hparams = tutils.get_model()
trainer_options = dict(
show_progress_bar=True,
max_nb_epochs=1,
@@ -42,7 +42,7 @@ def test_multi_gpu_model_ddp2():
distributed_backend='ddp2'
)
testing_utils.run_gpu_model_test(trainer_options, model, hparams)
tutils.run_model_test(trainer_options, model, hparams)
def test_multi_gpu_model_ddp():
@@ -50,13 +50,13 @@ def test_multi_gpu_model_ddp():
Make sure DDP works
:return:
"""
if not testing_utils.can_run_gpu_test():
if not tutils.can_run_gpu_test():
return
testing_utils.reset_seed()
testing_utils.set_random_master_port()
tutils.reset_seed()
tutils.set_random_master_port()
model, hparams = testing_utils.get_model()
model, hparams = tutils.get_model()
trainer_options = dict(
show_progress_bar=False,
max_nb_epochs=1,
@@ -66,14 +66,14 @@ def test_multi_gpu_model_ddp():
distributed_backend='ddp'
)
testing_utils.run_gpu_model_test(trainer_options, model, hparams)
tutils.run_model_test(trainer_options, model, hparams)
def test_optimizer_return_options():
testing_utils.reset_seed()
tutils.reset_seed()
trainer = Trainer()
model, hparams = testing_utils.get_model()
model, hparams = tutils.get_model()
# single optimizer
opt_a = torch.optim.Adam(model.parameters(), lr=0.002)
@@ -105,15 +105,15 @@ def test_cpu_slurm_save_load():
Verify model save/load/checkpoint on CPU
:return:
"""
testing_utils.reset_seed()
tutils.reset_seed()
hparams = testing_utils.get_hparams()
hparams = tutils.get_hparams()
model = LightningTestModel(hparams)
save_dir = testing_utils.init_save_dir()
save_dir = tutils.init_save_dir()
# logger file to get meta
logger = testing_utils.get_test_tube_logger(False)
logger = tutils.get_test_tube_logger(False)
version = logger.version
@@ -149,7 +149,7 @@ def test_cpu_slurm_save_load():
assert os.path.exists(saved_filepath)
# new logger file to get meta
logger = testing_utils.get_test_tube_logger(False, version=version)
logger = tutils.get_test_tube_logger(False, version=version)
trainer_options = dict(
max_nb_epochs=1,
@@ -174,7 +174,7 @@ def test_cpu_slurm_save_load():
# and our hook to predict using current model before any more weight updates
trainer.fit(model)
testing_utils.clear_save_dir()
tutils.clear_save_dir()
def test_multi_gpu_none_backend():
@@ -183,12 +183,12 @@ def test_multi_gpu_none_backend():
distributed_backend = None
:return:
"""
testing_utils.reset_seed()
tutils.reset_seed()
if not testing_utils.can_run_gpu_test():
if not tutils.can_run_gpu_test():
return
model, hparams = testing_utils.get_model()
model, hparams = tutils.get_model()
trainer_options = dict(
show_progress_bar=False,
max_nb_epochs=1,
@@ -198,7 +198,7 @@ def test_multi_gpu_none_backend():
)
with pytest.raises(MisconfigurationException):
testing_utils.run_gpu_model_test(trainer_options, model, hparams)
tutils.run_model_test(trainer_options, model, hparams)
def test_multi_gpu_model_dp():
@@ -206,12 +206,12 @@ def test_multi_gpu_model_dp():
Make sure DP works
:return:
"""
testing_utils.reset_seed()
tutils.reset_seed()
if not testing_utils.can_run_gpu_test():
if not tutils.can_run_gpu_test():
return
model, hparams = testing_utils.get_model()
model, hparams = tutils.get_model()
trainer_options = dict(
show_progress_bar=False,
distributed_backend='dp',
@@ -221,7 +221,7 @@ def test_multi_gpu_model_dp():
gpus='-1'
)
testing_utils.run_gpu_model_test(trainer_options, model, hparams)
tutils.run_model_test(trainer_options, model, hparams)
# test memory helper functions
memory.get_memory_profile('min_max')
@@ -232,16 +232,16 @@ def test_ddp_sampler_error():
Make sure DDP + AMP work
:return:
"""
if not testing_utils.can_run_gpu_test():
if not tutils.can_run_gpu_test():
return
testing_utils.reset_seed()
testing_utils.set_random_master_port()
tutils.reset_seed()
tutils.set_random_master_port()
hparams = testing_utils.get_hparams()
hparams = tutils.get_hparams()
model = LightningTestModel(hparams, force_remove_distributed_sampler=True)
logger = testing_utils.get_test_tube_logger(True)
logger = tutils.get_test_tube_logger(True)
trainer = Trainer(
logger=logger,
@@ -255,7 +255,7 @@ def test_ddp_sampler_error():
with pytest.warns(UserWarning):
trainer.get_dataloaders(model)
testing_utils.clear_save_dir()
tutils.clear_save_dir()
@pytest.fixture