generated from ashleve/lightning-hydra-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_basic_commands.py
64 lines (51 loc) · 1.6 KB
/
test_basic_commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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():
"""Test running for 1 train, val and test batch."""
command = ["run.py", "++trainer.fast_dev_run=true"]
run_command(command)
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_gpu():
"""Test running 1 epoch on GPU."""
command = [
"run.py",
"++trainer.max_epochs=1",
"++trainer.gpus=1",
]
run_command(command)
@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():
"""Test running 1 epoch on 25% of data."""
command = [
"run.py",
"++trainer.max_epochs=1",
"++trainer.limit_train_batches=0.25",
"++trainer.limit_val_batches=0.25",
"++trainer.limit_test_batches=0.25",
]
run_command(command)
def test_double_validation_loop():
"""Test running 1 epoch with validation loop twice per epoch."""
command = [
"run.py",
"++trainer.max_epochs=1",
"++trainer.val_check_interval=0.5",
]
run_command(command)