run_sanity_check.py 1.3 KB

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