"sgl-kernel/tests/test_custom_allreduce.py" did not exist on "6cb3974e77524ee2b291919ca6a8b55547bca8e0"
run_test.py 2.58 KB
Newer Older
hubertlu-tw's avatar
hubertlu-tw committed
1
"""
Michael Carilli's avatar
Michael Carilli committed
2
3
import unittest
import sys
4

5
from apex.testing.common_utils import TEST_WITH_ROCM
6
from apex.testing.common_utils import SKIP_FLAKY_TEST
Michael Carilli's avatar
Michael Carilli committed
7

8
test_dirs = ["run_amp", "run_fp16util", "run_optimizers", "run_fused_layer_norm", "run_pyprof_nvtx", "run_pyprof_data", "run_mlp"]
Michael Carilli's avatar
Michael Carilli committed
9

10
11
12
13
14
ROCM_BLACKLIST = [
    'run_pyprof_nvtx',
    'run_pyprof_data',
]

Michael Carilli's avatar
Michael Carilli committed
15
16
17
18
19
runner = unittest.TextTestRunner(verbosity=2)

errcode = 0

for test_dir in test_dirs:
20
    if (test_dir in ROCM_BLACKLIST) and TEST_WITH_ROCM and SKIP_FLAKY_TEST:
21
        continue
Michael Carilli's avatar
Michael Carilli committed
22
23
24
25
26
27
28
29
30
    suite = unittest.TestLoader().discover(test_dir)

    print("\nExecuting tests from " + test_dir)

    result = runner.run(suite)

    if not result.wasSuccessful():
        errcode = 1

31
sys.exit(errcode)
hubertlu-tw's avatar
hubertlu-tw committed
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107


"""
############################################################
"""L0 Tests Runner.

How to run this script?

1. Run all the tests: `python /path/to/apex/tests/L0/run_test.py`
2. Run one of the tests (e.g. fused layer norm):
    `python /path/to/apex/tests/L0/run_test.py --include run_fused_layer_norm`
3. Run two or more of the tests (e.g. optimizers and fused layer norm):
    `python /path/to/apex/tests/L0/run_test.py --include run_optimizers run_fused_layer_norm`
"""
import argparse
import os
import unittest
import sys

from apex.testing.common_utils import TEST_WITH_ROCM
from apex.testing.common_utils import SKIP_FLAKY_TEST

TEST_ROOT = os.path.dirname(os.path.abspath(__file__))
TEST_DIRS = [
    "run_amp",
    "run_fp16util",
    "run_optimizers",
    "run_fused_layer_norm",
    "run_mlp",
    "run_transformer",       # not fully supported on ROCm
]
DEFAULT_TEST_DIRS = [
    "run_amp",
    "run_fp16util",
    "run_optimizers",
    "run_fused_layer_norm",
    "run_mlp",
]


def parse_args():
    parser = argparse.ArgumentParser(
        description="L0 test runner",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument(
        "--include",
        nargs="+",
        choices=TEST_DIRS,
        default=DEFAULT_TEST_DIRS,
        help="select a set of tests to run (defaults to ALL tests).",
    )
    args, _ = parser.parse_known_args()
    return args


def main(args):
    runner = unittest.TextTestRunner(verbosity=2)
    errcode = 0
    for test_dir in args.include:
        test_dir = os.path.join(TEST_ROOT, test_dir)
        print(test_dir)
        suite = unittest.TestLoader().discover(test_dir)

        print("\nExecuting tests from " + test_dir)
        result = runner.run(suite)
        if not result.wasSuccessful():
            errcode = 1

    sys.exit(errcode)


if __name__ == '__main__':
    args = parse_args()
    main(args)