From 7811eb0658dbf12fa4f9355d3cbb8af0555b7df3 Mon Sep 17 00:00:00 2001 From: regisss <15324346+regisss@users.noreply.github.com> Date: Tue, 26 Apr 2022 00:10:45 +0200 Subject: [PATCH] Update Gaudi configurations (#35) - Add configurations from the Hub to tests so that non-regression tests rely on publicly available Gaudi configurations for each model - Remove log_device_mem_alloc in GaudiConfig --- README.md | 5 ++--- optimum/habana/gaudi_configuration.py | 3 --- tests/configs/gaudi_config_example_test.json | 3 +-- tests/configs/gaudi_config_trainer_test.json | 3 +-- tests/test_examples.py | 3 --- tests/test_gaudi_configuration.py | 1 - tests/utils.py | 14 +++++++------- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9c2a7f356d..a3ad47e47f 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ from optimum.habana import GaudiConfig, GaudiTrainer, GaudiTrainingArguments # Loading the GaudiConfig needed by the GaudiTrainer to fine-tune the model on HPUs gaudi_config = GaudiConfig.from_pretrained( - training_args.gaudi_config_name if training_args.gaudi_config_name else model_args.model_name_or_path, + training_args.gaudi_config_name, cache_dir=model_args.cache_dir, revision=model_args.model_revision, use_auth_token=True if model_args.use_auth_token else None, @@ -111,7 +111,7 @@ trainer = GaudiTrainer( ) ``` -with for example the following Gaudi configuration written in a JSON file: +where `training_args.gaudi_config_name` is the name of a model from the [Hub](https://huggingface.co/Habana) (Gaudi configurations are stored in model repositories). You can also give the path to a custom Gaudi configuration written in a JSON file such as this one: ```json { "use_habana_mixed_precision": true, @@ -119,7 +119,6 @@ with for example the following Gaudi configuration written in a JSON file: "hmp_is_verbose": false, "use_fused_adam": true, "use_fused_clip_norm": true, - "log_device_mem_alloc": false, "hmp_bf16_ops": [ "add", "addmm", diff --git a/optimum/habana/gaudi_configuration.py b/optimum/habana/gaudi_configuration.py index 027d761329..ff28127240 100644 --- a/optimum/habana/gaudi_configuration.py +++ b/optimum/habana/gaudi_configuration.py @@ -62,9 +62,6 @@ def __init__(self, **kwargs): # Use Habana's custom fused clip norm implementation self.use_fused_clip_norm = kwargs.pop("use_fused_clip_norm", False) - # Log live memory allocations on device at the given point - self.log_device_mem_alloc = kwargs.pop("log_device_mem_alloc", False) - def write_bf16_fp32_ops_to_text_files( self, path_to_bf16_file: Path, diff --git a/tests/configs/gaudi_config_example_test.json b/tests/configs/gaudi_config_example_test.json index f4c0db4e8d..53b5d6c81c 100644 --- a/tests/configs/gaudi_config_example_test.json +++ b/tests/configs/gaudi_config_example_test.json @@ -3,6 +3,5 @@ "hmp_opt_level": "O1", "hmp_is_verbose": false, "use_fused_adam": true, - "use_fused_clip_norm": true, - "log_device_mem_alloc": false + "use_fused_clip_norm": true } \ No newline at end of file diff --git a/tests/configs/gaudi_config_trainer_test.json b/tests/configs/gaudi_config_trainer_test.json index a6e0286ff1..c46a4f8891 100644 --- a/tests/configs/gaudi_config_trainer_test.json +++ b/tests/configs/gaudi_config_trainer_test.json @@ -3,6 +3,5 @@ "hmp_opt_level": "O1", "hmp_is_verbose": false, "use_fused_adam": true, - "use_fused_clip_norm": true, - "log_device_mem_alloc": true + "use_fused_clip_norm": true } \ No newline at end of file diff --git a/tests/test_examples.py b/tests/test_examples.py index 6a19946363..5f2df7dac2 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -117,9 +117,6 @@ def _create_test(cls, model_name: str, gaudi_config_name: str, multi_card: bool The test function that runs the example. """ - if not gaudi_config_name: - gaudi_config_name = PATH_TO_DEFAULT_GAUDI_CONFIG - @slow def test(self): if self.EXAMPLE_NAME is None: diff --git a/tests/test_gaudi_configuration.py b/tests/test_gaudi_configuration.py index d37bef8801..ef45820d1d 100644 --- a/tests/test_gaudi_configuration.py +++ b/tests/test_gaudi_configuration.py @@ -55,7 +55,6 @@ def test_default_parameter_types(self): self.assertIsInstance(gaudi_config.hmp_is_verbose, bool) self.assertIsInstance(gaudi_config.use_fused_adam, bool) self.assertIsInstance(gaudi_config.use_fused_clip_norm, bool) - self.assertIsInstance(gaudi_config.log_device_mem_alloc, bool) self.assertTrue(is_list_of_strings(gaudi_config.hmp_bf16_ops)) self.assertTrue(is_list_of_strings(gaudi_config.hmp_fp32_ops)) diff --git a/tests/utils.py b/tests/utils.py index e6684f225a..e85a504465 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,19 +17,19 @@ # TODO: add configuration names once they have been pushed to the hub MODELS_TO_TEST_MAPPING = { "bert": [ - # ("bert-base-uncased", ""), # removed from CI to save time - ("bert-large-uncased-whole-word-masking", ""), + # ("bert-base-uncased", "Habana/bert-base-uncased"), # removed from CI to save time + ("bert-large-uncased-whole-word-masking", "Habana/bert-large-uncased-whole-word-masking"), ], "roberta": [ - ("roberta-base", ""), - ("roberta-large", ""), + ("roberta-base", "Habana/roberta-base"), + ("roberta-large", "Habana/roberta-large"), ], "albert": [ - ("albert-large-v2", ""), - # ("albert-xxlarge-v1", ""), # make Github action job exceed the limit of 6 hours + ("albert-large-v2", "Habana/albert-large-v2"), + # ("albert-xxlarge-v1", "Habana/albert-xxlarge-v1"), # make Github action job exceed the limit of 6 hours ], "distilbert": [ - ("distilbert-base-uncased", ""), + ("distilbert-base-uncased", "Habana/distilbert-base-uncased"), ], }