Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test coverage #289

Merged
merged 67 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
41d3ca0
requirements for test coverage
May 2, 2021
427bebd
cleanup tensorboard dir when testing
May 2, 2021
fe7916c
simplify using subtests
May 3, 2021
119c6c1
fix clear test dirs in subtests
May 3, 2021
9ac6e03
test update to try and run tests with a worldsize > 1
May 3, 2021
65b497f
fix test model instantiation for world size > 1
May 3, 2021
ca05fd9
neox args test with import in function
May 3, 2021
69ae18c
test readme update
May 3, 2021
fb60a97
test model checkpoint with forward option
May 3, 2021
616ba01
test model checkpoint in inference mode
May 3, 2021
d343dbd
todo for config data_impl
May 3, 2021
2472bd2
upate test configs
May 3, 2021
92251df
add docstrings to testcases
May 3, 2021
532c982
test models with overwrite in neox_args
May 3, 2021
81086aa
update tests readme
May 3, 2021
528686f
test config include sm3 optimizer
May 3, 2021
48c7a3e
test config adjustments
May 3, 2021
b460776
add cpu and gpu testing in checkpoint test
May 3, 2021
023579b
add test for train / backwards step
May 3, 2021
aa0dc64
requirements for test coverage
May 2, 2021
c517c69
cleanup tensorboard dir when testing
May 2, 2021
132abfc
simplify using subtests
May 3, 2021
8b7a9a7
fix clear test dirs in subtests
May 3, 2021
93c986a
test update to try and run tests with a worldsize > 1
May 3, 2021
49ef6d0
fix test model instantiation for world size > 1
May 3, 2021
ce66309
neox args test with import in function
May 3, 2021
3673d1b
test readme update
May 3, 2021
e849d40
test model checkpoint with forward option
May 3, 2021
a83198f
test model checkpoint in inference mode
May 3, 2021
baeb88e
todo for config data_impl
May 3, 2021
ec81841
upate test configs
May 3, 2021
5ac730a
add docstrings to testcases
May 3, 2021
3cd056b
test models with overwrite in neox_args
May 3, 2021
c0469f0
update tests readme
May 3, 2021
44431d5
test config include sm3 optimizer
May 3, 2021
51c9bc1
test config adjustments
May 3, 2021
05fbd5d
add cpu and gpu testing in checkpoint test
May 3, 2021
2f827a3
add test for train / backwards step
May 3, 2021
eefff73
Merge branch 'increase_test_coverage' of github.com:EleutherAI/gpt-ne…
May 4, 2021
f1f40cf
test model train with right vocab size
May 4, 2021
7b0ccf2
modified test configs
May 4, 2021
dc53a5c
test train with nan handling of losses
May 4, 2021
9e4c31a
test model train comment out config 2 (no error, no termination)
May 4, 2021
c8c6e97
text generation utils - create dir fix
May 4, 2021
1cdea36
test model generation init
May 4, 2021
a391ae1
changed model tests to allow for init from dict
kipgparker May 4, 2021
dc88b12
Merge branch 'increase_test_coverage' of https://github.com/EleutherA…
kipgparker May 4, 2021
c756696
Merge branch 'main' into increase_test_coverage
May 7, 2021
48171c7
fix use recompute kwarg in generation instead of neox_args.recompute
May 7, 2021
7239d3a
adjust tests for generation to new main branch
May 7, 2021
83978f2
test text generation with multiple configs
May 10, 2021
f915114
test model generation with input file
May 10, 2021
0fce24f
adding config comparer and figured out what's causing test error
May 10, 2021
9042dab
Merge branch 'main' into increase_test_coverage
May 11, 2021
88d4a35
updated config comparer and config to meet new format
kipgparker May 11, 2021
14a84c9
fix / make loss dict naming consistent
May 11, 2021
b3b3d5c
disable fp32 in testing
May 11, 2021
97c0c62
fix error message for unknown activation
May 11, 2021
6f76823
add train_batch_size to known parameters in neox_args used testcase
May 11, 2021
89863b3
fix comment with new variable name
May 11, 2021
053e70c
add train_batch_size] to known properties in neox_args usage testcase
May 11, 2021
774bc2c
updated config comparer
kipgparker May 11, 2021
dc2806a
Merge branch 'main' into increase_test_coverage
May 12, 2021
02ccedc
Merge branch 'main' into increase_test_coverage
May 12, 2021
d405354
compare arg value in neox args load test
May 12, 2021
af0b1f1
mark testcases for cpu
May 12, 2021
a2d2e2b
readme for tests on cpu
May 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
neox args test with import in function
  • Loading branch information
Samuel Weinbach committed May 3, 2021
commit ca05fd959f25be2879698f896fcac4f0ca7393f5
29 changes: 29 additions & 0 deletions tests/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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)

```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
```

If a html coverage report has been created a simple http server can be run to serve static files.

```bash
cd htmlcov
python -m http.server 8000
```
12 changes: 8 additions & 4 deletions tests/neox_args/test_neoxargs_commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
import sys
from unittest.mock import patch


from megatron.neox_arguments import NeoXArgs
from ..common import get_root_directory, get_config_directory, get_configs_with_path


def test_neoxargs_consume_deepy_args_with_config_dir():
"""
verify consume_deepy_args processes command line arguments without config dir
"""

from megatron.neox_arguments import NeoXArgs

# load neox args with command line
with patch('sys.argv', [str(get_root_directory() / "deepy.py"), "pretrain_gpt2.py"] + get_configs_with_path(["small.yml", "local_setup.yml"])):
args_loaded_consume = NeoXArgs.consume_deepy_args()
Expand All @@ -31,6 +30,8 @@ def test_neoxargs_consume_deepy_args_without_yml_suffix():
verify consume_deepy_args processes command line arguments without yaml suffix
"""

from megatron.neox_arguments import NeoXArgs

# load neox args with command line
with patch('sys.argv', [str(get_root_directory() / "deepy.py"), "pretrain_gpt2.py"] + get_configs_with_path(["small", "local_setup"])):
args_loaded_consume = NeoXArgs.consume_deepy_args()
Expand All @@ -50,6 +51,8 @@ def test_neoxargs_consume_deepy_args_with_config_dir():
verify consume_deepy_args processes command line arguments including config dir
"""

from megatron.neox_arguments import NeoXArgs

# load neox args with command line
with patch('sys.argv', [str(get_root_directory() / "deepy.py"), "pretrain_gpt2.py", '-d', str(get_config_directory())] + ["small.yml", "local_setup.yml"]):
args_loaded_consume = NeoXArgs.consume_deepy_args()
Expand All @@ -68,7 +71,8 @@ def test_neoxargs_consume_neox_args():
"""
verify megatron args are correctly consumed after sending via deepspeed
"""

from megatron.neox_arguments import NeoXArgs

# intitially load config from files as would be the case in deepy.py
yaml_list = get_configs_with_path(["small.yml", "local_setup.yml"])
args_baseline = NeoXArgs.from_ymls(yaml_list)
Expand Down
3 changes: 1 addition & 2 deletions tests/neox_args/test_neoxargs_implementation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from megatron import NeoXArgs

def test_neoxargs_duplicates():
"""
tests that there are no duplicates among parent classes of NeoXArgs
"""
from megatron import NeoXArgs
assert NeoXArgs.validate_keys(), "test_neoxargs_duplicates"
24 changes: 22 additions & 2 deletions tests/neox_args/test_neoxargs_load.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from megatron.neox_arguments import NeoXArgs

from ..common import get_configs_with_path

def test_neoxargs_load_arguments_small_local_setup():
"""
verify small.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["small.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -14,6 +14,8 @@ def test_neoxargs_load_arguments_small_local_setup_text_generation():
"""
verify small.yml can be loaded together with text generation without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["small.yml", "local_setup.yml", "text_generation.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -22,6 +24,8 @@ def test_neoxargs_load_arguments_medium_local_setup():
"""
verify medium.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["medium.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -30,6 +34,8 @@ def test_neoxargs_load_arguments_large_local_setup():
"""
verify large.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["large.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -38,6 +44,8 @@ def test_neoxargs_load_arguments_2_7B_local_setup():
"""
verify 2-7B.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["2-7B.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -46,6 +54,8 @@ def test_neoxargs_load_arguments_6_7B_local_setup():
"""
verify 6-7B.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["6-7B.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -54,6 +64,8 @@ def test_neoxargs_load_arguments_13B_local_setup():
"""
verify 13B.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["13B.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -62,6 +74,8 @@ def test_neoxargs_load_arguments_XL_local_setup():
"""
verify XL.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["XL.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -70,6 +84,8 @@ def test_neoxargs_load_arguments_175B_local_setup():
"""
verify 13B.yml can be loaded without raising validation errors
"""
from megatron.neox_arguments import NeoXArgs

yaml_list = get_configs_with_path(["175B.yml", "local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
assert isinstance(args_loaded, NeoXArgs)
Expand All @@ -78,6 +94,8 @@ def test_neoxargs_fail_instantiate_without_required_params():
"""
verify assertion error if required arguments are not provided
"""
from megatron.neox_arguments import NeoXArgs

try:
yaml_list = get_configs_with_path(["local_setup.yml"])
args_loaded = NeoXArgs.from_ymls(yaml_list)
Expand All @@ -89,6 +107,8 @@ def test_neoxargs_fail_instantiate_without_any_params():
"""
verify assertion error if required arguments are not provided
"""
from megatron.neox_arguments import NeoXArgs

try:
args_loaded = NeoXArgs()
assert False
Expand Down
5 changes: 1 addition & 4 deletions tests/neox_args/test_neoxargs_usage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import re

from megatron.neox_arguments import NeoXArgs
from ..common import get_root_directory


def test_neoxargs_usage():
""""
checks for code pieces of the pattern "args.*" and verifies that such used arg is defined in NeoXArgs
"""

from megatron.neox_arguments import NeoXArgs

declared_all = True
neox_args_attributes = set(NeoXArgs.__dataclass_fields__.keys())
Expand Down