-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel Weinbach
committed
Apr 30, 2021
1 parent
9fdca6f
commit cfcfd1c
Showing
9 changed files
with
112 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,5 +140,6 @@ checkpoints/ | |
|
||
#test logs | ||
test_checkpoint/ | ||
test_logs/ | ||
logs/ | ||
tensorboard/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
import sys | ||
import unittest | ||
import shutil | ||
import logging | ||
|
||
if __name__ == "__main__": | ||
sys.path.append(os.path.abspath('')) | ||
|
||
from deepspeed.runtime.pipe.engine import PipelineEngine, DeepSpeedEngine | ||
|
||
from megatron.neox_arguments import NeoXArgs | ||
from megatron.model import GPT2ModelPipe | ||
from megatron import initialize_megatron | ||
from megatron.training import setup_model_and_optimizer | ||
from megatron.mpu import destroy_model_parallel | ||
|
||
from tests.common import get_root_directory, get_configs_with_path, get_test_configs_with_path, clear_test_dirs, TEST_CHECKPOINT_DIR, TEST_LOG_DIR | ||
|
||
class TestModelInstantiation(unittest.TestCase): | ||
|
||
def setUp(self): | ||
clear_test_dirs() | ||
|
||
def tearDown(self): | ||
clear_test_dirs() | ||
|
||
def run_instantiation_test(self, yaml_list, model_class_expected): | ||
destroy_model_parallel() # mpu model parallel contains remaining global vars | ||
|
||
# intitially load config from files as would be the case in deepy.py | ||
|
||
logging.info(self.__class__.__name__ + ".run_instantiation_test() " + f"Running on: {yaml_list}") | ||
|
||
args_loaded = NeoXArgs.from_ymls(yaml_list) | ||
args_loaded.build_tokenizer() | ||
args_loaded.update_value("user_script", str(get_root_directory() / "pretrain_gpt2.py")) | ||
args_loaded.update_value("use_cpu_initialization", True) | ||
args_loaded.update_value("save", TEST_CHECKPOINT_DIR) | ||
args_loaded.update_value("load", TEST_CHECKPOINT_DIR) | ||
args_loaded.update_value("log_dir", TEST_LOG_DIR) | ||
|
||
logging.debug(self.__class__.__name__ + ".run_instantiation_test() initializing megatron") | ||
initialize_megatron(neox_args=args_loaded) | ||
|
||
logging.debug(self.__class__.__name__ + ".run_instantiation_test() initializing model") | ||
model, optimizer, lr_scheduler = setup_model_and_optimizer(neox_args=args_loaded, inference=False, get_key_value=True) | ||
|
||
self.assertTrue(isinstance(model, model_class_expected)) | ||
|
||
def test_model_instantiation_small(self): | ||
self.run_instantiation_test(get_configs_with_path(["local_setup.yml", "small.yml"]), PipelineEngine) | ||
|
||
def test_model_instantiation_medium(self): | ||
self.run_instantiation_test(get_configs_with_path(["local_setup.yml", "medium.yml"]), PipelineEngine) | ||
|
||
def test_model_instantiation_small_test(self): | ||
self.run_instantiation_test(get_test_configs_with_path(["test_local_setup.yml", "test_small.yml"]), DeepSpeedEngine) | ||
|
||
def test_model_instantiation_medium_test(self): | ||
self.run_instantiation_test(get_test_configs_with_path(["test_local_setup.yml", "test_medium.yml"]), DeepSpeedEngine) | ||
|
||
if __name__ == "__main__": | ||
suite = unittest.TestSuite() | ||
suite.addTest(TestModelInstantiation("test_model_instantiation_small_test")) | ||
suite.addTest(TestModelInstantiation("test_model_instantiation_medium_test")) | ||
unittest.TextTestRunner(failfast=True).run(suite) |