-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* requirements for test coverage * cleanup tensorboard dir when testing * simplify using subtests * fix clear test dirs in subtests * test update to try and run tests with a worldsize > 1 * fix test model instantiation for world size > 1 * neox args test with import in function * test readme update * test model checkpoint with forward option * test model checkpoint in inference mode * todo for config data_impl * upate test configs * add docstrings to testcases * test models with overwrite in neox_args * update tests readme * test config include sm3 optimizer * test config adjustments * add cpu and gpu testing in checkpoint test * add test for train / backwards step * requirements for test coverage * cleanup tensorboard dir when testing * simplify using subtests * fix clear test dirs in subtests * test update to try and run tests with a worldsize > 1 * fix test model instantiation for world size > 1 * neox args test with import in function * test readme update * test model checkpoint with forward option * test model checkpoint in inference mode * todo for config data_impl * upate test configs * add docstrings to testcases * test models with overwrite in neox_args * update tests readme * test config include sm3 optimizer * test config adjustments * add cpu and gpu testing in checkpoint test * add test for train / backwards step * test model train with right vocab size * modified test configs * test train with nan handling of losses * test model train comment out config 2 (no error, no termination) * text generation utils - create dir fix * test model generation init * changed model tests to allow for init from dict * fix use recompute kwarg in generation instead of neox_args.recompute * adjust tests for generation to new main branch * test text generation with multiple configs * test model generation with input file * adding config comparer and figured out what's causing test error * updated config comparer and config to meet new format * fix / make loss dict naming consistent * disable fp32 in testing * fix error message for unknown activation * add train_batch_size to known parameters in neox_args used testcase * fix comment with new variable name * add train_batch_size] to known properties in neox_args usage testcase * updated config comparer * compare arg value in neox args load test * mark testcases for cpu * readme for tests on cpu Co-authored-by: Samuel Weinbach <[email protected]> Co-authored-by: kip <[email protected]>
- Loading branch information
1 parent
079a307
commit bb8222f
Showing
32 changed files
with
1,343 additions
and
476 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pytest==6.2.3 | ||
pytest-cov==2.11.1 | ||
pytest-forked==1.3.0 | ||
autopep8==1.5.6 |
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,38 @@ | ||
# Dependencies | ||
|
||
Tests use pytests with coverage and forked plugins. Install with: | ||
|
||
```bash | ||
pip install -r requirements/requirements-dev.txt | ||
``` | ||
|
||
# Run | ||
|
||
Tests can be run using pytest. | ||
|
||
* The argument --forked needs to be provided | ||
* A coverage report can be created using the optional arguments --cov-report and --cov (see pytest documentation) | ||
* A subset of tests can be selected by pointing to the module within tests | ||
|
||
```bash | ||
# run all tests, output coverage report of megatron module in terminal | ||
pytest --forked --cov-report term --cov=megatron tests | ||
|
||
# run tests in tests/model, output coverage report of megatron module as html | ||
pytest --forked --cov-report html --cov=megatron tests/model | ||
|
||
# run tests in tests/model/test_model_generation.py, don't output coverage report | ||
pytest --forked tests/model/test_model_generation.py | ||
``` | ||
|
||
Some tests can run on cpu only. These are marked with the decorator @pytest.mark.cpu. | ||
The test cases for cpu can be run with: | ||
```` | ||
pytest tests -m cpu | ||
``` | ||
If a html coverage report has been created a simple http server can be run to serve static files. | ||
```bash | ||
python -m http.server --directory htmlcov 8000 | ||
``` |
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 |
---|---|---|
@@ -1,6 +0,0 @@ | ||
""" | ||
Testcases for GPT NeoX | ||
""" | ||
|
||
from .model import * | ||
from .neox_args import * | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Should just be called using: "python tests/config_comparison.py" | ||
# Testing code to see which changes among configs break tests | ||
|
||
# Hacky can't remember how to move back to root dir | ||
import sys | ||
from pathlib import Path | ||
file = Path(__file__).resolve() | ||
package_root_directory = file.parents[1] | ||
sys.path.append(str(package_root_directory)) | ||
|
||
from itertools import combinations | ||
from tests.model import run_test_model_instantiation, run_train_test, run_checkpoint_test | ||
from tests.common import TEST_CHECKPOINT_DIR, TEST_LOG_DIR, TEST_TENSORBOARD_DIR | ||
from tests.common import distributed_test, get_test_configs_with_path, get_root_directory, clear_test_dirs | ||
|
||
# World size might need to be adjusted depending on test | ||
@distributed_test(world_size=1) | ||
def main(subsequence_length: int = 2): | ||
"""Allows you to easily compare sets of combinations to find which changes are causing issues | ||
Args: | ||
subsequence_length (int, optional): the length of subsequences of elements from the input iterable. Defaults to 2. | ||
""" | ||
|
||
#choose default params and updated ones | ||
base_yaml_list = get_test_configs_with_path(["test_local_setup.yml", "test_small_0.yml"]) | ||
new_yaml_list = get_test_configs_with_path(["test_local_setup.yml", "test_small_3.yml"]) | ||
|
||
# Need to import here as distributed | ||
from megatron.neox_arguments import NeoXArgs | ||
|
||
overwrite_values = { | ||
"user_script": str(get_root_directory() / "pretrain_gpt2.py"), | ||
"save": TEST_CHECKPOINT_DIR, | ||
"load": TEST_CHECKPOINT_DIR, | ||
"log_dir": TEST_LOG_DIR, | ||
"tensorboard_dir": TEST_TENSORBOARD_DIR, | ||
} | ||
base_args_loaded = NeoXArgs.from_ymls(base_yaml_list, overwrite_values=overwrite_values) | ||
new_args_loaded = NeoXArgs.from_ymls(new_yaml_list, overwrite_values=overwrite_values) | ||
|
||
# Find difference between configs | ||
diff = {} | ||
for key, value in base_args_loaded.all_config.items(): | ||
if new_args_loaded.all_config[key] != value: | ||
diff[key] = new_args_loaded.all_config[key] | ||
print(f'key: {key} original: {value}, updated: {new_args_loaded.all_config[key]}') | ||
|
||
|
||
perms = list(combinations(diff.items(), subsequence_length)) | ||
|
||
# Iterate over combinations and run the test function | ||
# and print information so you can debug from console as program is distributed | ||
for items in perms: | ||
param_dict = base_args_loaded.all_config | ||
print('running setup with:') | ||
for item in items: | ||
param_dict[item[0]] = item[1] | ||
print(f'key: {item[0]} original: {base_args_loaded.all_config[item[0]]}, updated: {item[1]}') | ||
|
||
# These are interchangable | ||
|
||
run_train_test(param_dict=param_dict) | ||
#run_test_model_instantiation(param_dict=param_dict) | ||
#run_checkpoint_test(param_dict=param_dict) | ||
|
||
print('finished running setup with:') | ||
for item in items: | ||
print(f'key: {item[0]} original: {base_args_loaded.all_config[item[0]]}, updated: {item[1]}') | ||
|
||
if __name__ == '__main__': | ||
main() |
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
""" | ||
Tests concerning the GPT2Model class | ||
""" | ||
|
||
from .test_model_checkpoint import TestModelCheckpoint | ||
from .test_model_instantiation import TestModelInstantiation | ||
from .test_model_instantiation import run_test_model_instantiation | ||
from .test_model_train import run_train_test | ||
from .test_model_checkpoint import run_checkpoint_test |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.