run_sanity_check.py 1.27 KB
Newer Older
aiss's avatar
aiss committed
1
2
3
4
5
6
7
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0

# DeepSpeed Team
"""
Note: please copy webtext data to "Megatron-LM" folder, before running this script.
"""
Elton Zheng's avatar
Elton Zheng committed
8
9
10
11

import sys
import unittest

Shaden Smith's avatar
Shaden Smith committed
12
sys.path.append('../DeepSpeedExamples/Megatron_GPT2')
13
sys.path.append('../DeepSpeedExamples/BingBertSquad')
Elton Zheng's avatar
Elton Zheng committed
14
15
16

# Import the test cases here.
import Megatron_GPT2
17
import BingBertSquad
Elton Zheng's avatar
Elton Zheng committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


def pytest_hack(runner_result):
    '''This is an ugly hack to get the unittest suites to play nicely with
    pytest. Otherwise failed tests are not reported by pytest for some reason.

    Long-term, these model tests should be adapted to pytest.
    '''
    if not runner_result.wasSuccessful():
        print('SUITE UNSUCCESSFUL:', file=sys.stderr)
        for fails in runner_result.failures:
            print(fails, file=sys.stderr)
        assert runner_result.wasSuccessful()  # fail the test


33
34
35
36
37
38
39
40
def test_megatron():
    runner = unittest.TextTestRunner(failfast=True)
    pytest_hack(runner.run(Megatron_GPT2.suite()))


def test_megatron_checkpoint():
    runner = unittest.TextTestRunner(failfast=True)
    pytest_hack(runner.run(Megatron_GPT2.checkpoint_suite()))
Elton Zheng's avatar
Elton Zheng committed
41
42


Jeff Rasley's avatar
Jeff Rasley committed
43
44
45
def test_squad():
    runner = unittest.TextTestRunner(failfast=True)
    pytest_hack(runner.run(BingBertSquad.suite()))