Release/1.2 (#198)
* update template to pytorch 1.10+ and lightning 1.5+ * add experiment mode to all experiment configs and implement special logging paths for experiment mode * add `MaxMetric` to model, for computation of best so far validation accuracy * add RichProgressBar to default callbacks * get rid of trick for preventing auto hparam logging, since lightning now supports it with `self.save_hyperparameters(logger=False)` * add `self.save_hyperparameters()` to datamodule since lightinng now supports it * deprecate Apex support * deprecate bash script for conda setup * change `terminate_on_nan` debug option to `detect_anomaly` for compatibility with lightning v1.5 * specify model and datamodule during `trainer.test()`, for compatibility with lightning v1.5 * remove `configs/trainer/all_params.yaml` * make hyperparameter optimization compatible with lightning v1.5 * general documentation improvements
This commit is contained in:
1 parent
6159c413f2
commit
9468ef91c5
29 files changed
+278
-330
No files matched your search
@@ -24,7 +24,6 @@ def _module_available(module_path: str) -> bool:
|
||||
|
||||
|
||||
_IS_WINDOWS = platform.system() == "Windows"
|
||||
_APEX_AVAILABLE = _module_available("apex.amp")
|
||||
_DEEPSPEED_AVAILABLE = not _IS_WINDOWS and _module_available("deepspeed")
|
||||
_FAIRSCALE_AVAILABLE = not _IS_WINDOWS and _module_available("fairscale.nn")
|
||||
_RPC_AVAILABLE = not _IS_WINDOWS and _module_available("torch.distributed.rpc")
|
||||
@@ -12,7 +12,6 @@ Adapted from:
|
||||
"""
|
||||
|
||||
from tests.helpers.module_available import (
|
||||
_APEX_AVAILABLE,
|
||||
_DEEPSPEED_AVAILABLE,
|
||||
_FAIRSCALE_AVAILABLE,
|
||||
_IS_WINDOWS,
|
||||
@@ -40,7 +39,6 @@ class RunIf:
|
||||
min_torch: Optional[str] = None,
|
||||
max_torch: Optional[str] = None,
|
||||
min_python: Optional[str] = None,
|
||||
amp_apex: bool = False,
|
||||
skip_windows: bool = False,
|
||||
rpc: bool = False,
|
||||
fairscale: bool = False,
|
||||
@@ -53,7 +51,6 @@ class RunIf:
|
||||
min_torch: minimum pytorch version to run test
|
||||
max_torch: maximum pytorch version to run test
|
||||
min_python: minimum python version required to run test
|
||||
amp_apex: NVIDIA Apex is installed
|
||||
skip_windows: skip test for Windows platform
|
||||
rpc: requires Remote Procedure Call (RPC)
|
||||
fairscale: if `fairscale` module is required to run the test
|
||||
@@ -84,10 +81,6 @@ class RunIf:
|
||||
conditions.append(Version(py_version) < Version(min_python))
|
||||
reasons.append(f"python>={min_python}")
|
||||
|
||||
if amp_apex:
|
||||
conditions.append(not _APEX_AVAILABLE)
|
||||
reasons.append("NVIDIA Apex")
|
||||
|
||||
if skip_windows:
|
||||
conditions.append(_IS_WINDOWS)
|
||||
reasons.append("does not run on Windows")
|
||||
|
||||
@@ -1,43 +1,49 @@
|
||||
import pytest
|
||||
|
||||
from tests.helpers.run_command import run_command
|
||||
from tests.helpers.runif import RunIf
|
||||
|
||||
"""
|
||||
A couple of sanity checks to make sure the model doesn't crash with different running options.
|
||||
"""
|
||||
|
||||
|
||||
def test_fast_dev_run():
|
||||
"""Run 1 train, val, test batch."""
|
||||
"""Test running for 1 train, val and test batch."""
|
||||
command = ["run.py", "++trainer.fast_dev_run=true"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_default_cpu():
|
||||
"""Test default config on CPU."""
|
||||
def test_cpu():
|
||||
"""Test running 1 epoch on CPU."""
|
||||
command = ["run.py", "++trainer.max_epochs=1", "++trainer.gpus=0"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
# use RunIf to skip execution of some tests, e.g. when no gpus are available
|
||||
@RunIf(min_gpus=1)
|
||||
def test_default_gpu():
|
||||
"""Test default config on GPU."""
|
||||
def test_gpu():
|
||||
"""Test running 1 epoch on GPU."""
|
||||
command = [
|
||||
"run.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++datamodule.pin_memory=True",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_experiments():
|
||||
"""Train 1 epoch with all experiment configs."""
|
||||
command = ["run.py", "-m", "experiment=glob(*)", "++trainer.max_epochs=1"]
|
||||
@RunIf(min_gpus=1)
|
||||
def test_mixed_precision():
|
||||
"""Test running 1 epoch with pytorch native automatic mixed precision (AMP)."""
|
||||
command = [
|
||||
"run.py",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
def test_limit_batches():
|
||||
"""Train 1 epoch on 25% of data."""
|
||||
"""Test running 1 epoch on 25% of data."""
|
||||
command = [
|
||||
"run.py",
|
||||
"++trainer.max_epochs=1",
|
||||
@@ -49,7 +55,7 @@ def test_limit_batches():
|
||||
|
||||
|
||||
def test_double_validation_loop():
|
||||
"""Train 1 epoch with validation loop twice per epoch."""
|
||||
"""Test running 1 epoch with validation loop twice per epoch."""
|
||||
command = [
|
||||
"run.py",
|
||||
"++trainer.max_epochs=1",
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
from tests.helpers.run_command import run_command
|
||||
from tests.helpers.runif import RunIf
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_O1():
|
||||
"""Test mixed-precision level O1."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++trainer.amp_backend=apex",
|
||||
"++trainer.amp_level=O1",
|
||||
"++trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_O2():
|
||||
"""Test mixed-precision level O2."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++trainer.amp_backend=apex",
|
||||
"++trainer.amp_level=O2",
|
||||
"++trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@RunIf(amp_apex=True)
|
||||
def test_apex_O3():
|
||||
"""Test mixed-precision level O3."""
|
||||
command = [
|
||||
"run.py",
|
||||
"trainer=default",
|
||||
"++trainer.max_epochs=1",
|
||||
"++trainer.gpus=1",
|
||||
"++trainer.amp_backend=apex",
|
||||
"++trainer.amp_level=O3",
|
||||
"++trainer.precision=16",
|
||||
]
|
||||
run_command(command)
|
||||
@@ -3,11 +3,20 @@ import pytest
|
||||
from tests.helpers.run_command import run_command
|
||||
|
||||
"""
|
||||
A couple of tests executing hydra sweeps.
|
||||
|
||||
Use the following command to skip slow tests:
|
||||
pytest -k "not slow"
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_experiments():
|
||||
"""Test running all available experiment configs for 1 epoch."""
|
||||
command = ["run.py", "-m", "experiment=glob(*)", "++trainer.max_epochs=1"]
|
||||
run_command(command)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_default_sweep():
|
||||
"""Test default Hydra sweeper."""
|
||||
|
||||
Reference in new issue
Block a user