run_sanity_check.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (c) Microsoft Corporation.
  2. # SPDX-License-Identifier: Apache-2.0
  3. # DeepSpeed Team
  4. """
  5. Note: please copy webtext data to "Megatron-LM" folder, before running this script.
  6. """
  7. import sys
  8. import unittest
  9. sys.path.append('../DeepSpeedExamples/Megatron_GPT2')
  10. sys.path.append('../DeepSpeedExamples/BingBertSquad')
  11. # Import the test cases here.
  12. import Megatron_GPT2
  13. import BingBertSquad
  14. def pytest_hack(runner_result):
  15. '''This is an ugly hack to get the unittest suites to play nicely with
  16. pytest. Otherwise failed tests are not reported by pytest for some reason.
  17. Long-term, these model tests should be adapted to pytest.
  18. '''
  19. if not runner_result.wasSuccessful():
  20. print('SUITE UNSUCCESSFUL:', file=sys.stderr)
  21. for fails in runner_result.failures:
  22. print(fails, file=sys.stderr)
  23. assert runner_result.wasSuccessful() # fail the test
  24. def test_megatron():
  25. runner = unittest.TextTestRunner(failfast=True)
  26. pytest_hack(runner.run(Megatron_GPT2.suite()))
  27. def test_megatron_checkpoint():
  28. runner = unittest.TextTestRunner(failfast=True)
  29. pytest_hack(runner.run(Megatron_GPT2.checkpoint_suite()))
  30. def test_squad():
  31. runner = unittest.TextTestRunner(failfast=True)
  32. pytest_hack(runner.run(BingBertSquad.suite()))