Skip to content

Commit

Permalink
add test for model instantiation sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Weinbach committed May 2, 2021
1 parent df57cf7 commit 5683f7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 15 additions & 0 deletions tests/model/test_configs/test_sparse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Add this to your config for sparse attention every other layer
{
"attention_config": [[["local"], "all"]],

# sparsity config:
# (these are the defaults for local sliding window sparsity, training will work without this here, but it's left in for
# illustrative purposes)
# see https://www.deepspeed.ai/tutorials/sparse-attention/#how-to-config-sparsity-structures for
# more detailed config instructions and available parameters

"sparsity_config": {
"block": 16, # block size
"num_local_blocks": 32,
}
}
6 changes: 4 additions & 2 deletions tests/model/test_model_instantiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def test_model_instantiation_small_test(self):
def test_model_instantiation_medium_test(self):
self.run_instantiation_test(get_test_configs_with_path(["test_local_setup.yml", "test_medium.yml"]), DeepSpeedEngine)

def test_model_instantiation_small_sparse_test(self):
self.run_instantiation_test(get_test_configs_with_path(["test_local_setup.yml", "test_small.yml", "test_sparse.yml"]), DeepSpeedEngine)

if __name__ == "__main__":
suite = unittest.TestSuite()
suite.addTest(TestModelInstantiation("test_model_instantiation_small_test"))
suite.addTest(TestModelInstantiation("test_model_instantiation_medium_test"))
suite.addTest(TestModelInstantiation("test_model_instantiation_small_sparse_test"))
unittest.TextTestRunner(failfast=True).run(suite)

0 comments on commit 5683f7a

Please sign in to comment.