From fd06ad5438249a055d0b2fd2fc2567d8265a7e4b Mon Sep 17 00:00:00 2001 From: Marc Sun <57196510+SunMarc@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:42:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=F0=9F=9A=A8=F0=9F=9A=A8=20Update?= =?UTF-8?q?=20min=20version=20of=20accelerate=20to=200.26.0=20(#32627)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update min version of accelerate to 0.26.0 * dev-ci * update min version in import * remove useless check * dev-ci * style * dev-ci * dev-ci --- setup.py | 2 +- src/transformers/dependency_versions_table.py | 2 +- src/transformers/trainer.py | 17 ++++++++--------- src/transformers/training_args.py | 6 ++---- src/transformers/utils/import_utils.py | 2 +- tests/fsdp/test_fsdp.py | 6 +----- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/setup.py b/setup.py index e79cd46197..e49b40ac97 100644 --- a/setup.py +++ b/setup.py @@ -96,7 +96,7 @@ if stale_egg_info.exists(): # 2. once modified, run: `make deps_table_update` to update src/transformers/dependency_versions_table.py _deps = [ "Pillow>=10.0.1,<=15.0", - "accelerate>=0.21.0", + "accelerate>=0.26.0", "av==9.2.0", # Latest version of PyAV (10.0.0) has issues with audio stream. "beautifulsoup4", "codecarbon==1.2.0", diff --git a/src/transformers/dependency_versions_table.py b/src/transformers/dependency_versions_table.py index 7644d8d68d..68e7661288 100644 --- a/src/transformers/dependency_versions_table.py +++ b/src/transformers/dependency_versions_table.py @@ -3,7 +3,7 @@ # 2. run `make deps_table_update`` deps = { "Pillow": "Pillow>=10.0.1,<=15.0", - "accelerate": "accelerate>=0.21.0", + "accelerate": "accelerate>=0.26.0", "av": "av==9.2.0", "beautifulsoup4": "beautifulsoup4", "codecarbon": "codecarbon==1.2.0", diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index 4bd2e1ef5c..7d116d2679 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -4761,16 +4761,15 @@ class Trainer: fsdp_plugin.limit_all_gathers = self.args.fsdp_config.get( "limit_all_gathers", fsdp_plugin.limit_all_gathers ) - if is_accelerate_available("0.23.0"): - fsdp_plugin.activation_checkpointing = self.args.fsdp_config.get( - "activation_checkpointing", fsdp_plugin.activation_checkpointing + fsdp_plugin.activation_checkpointing = self.args.fsdp_config.get( + "activation_checkpointing", fsdp_plugin.activation_checkpointing + ) + if fsdp_plugin.activation_checkpointing and self.args.gradient_checkpointing: + raise ValueError( + "The activation_checkpointing in FSDP config and the gradient_checkpointing in training arg " + "can't be set to True simultaneously. Please use FSDP's activation_checkpointing logic " + "when using FSDP." ) - if fsdp_plugin.activation_checkpointing and self.args.gradient_checkpointing: - raise ValueError( - "The activation_checkpointing in FSDP config and the gradient_checkpointing in training arg " - "can't be set to True simultaneously. Please use FSDP's activation_checkpointing logic " - "when using FSDP." - ) if self.is_deepspeed_enabled and getattr(self.args, "hf_deepspeed_config", None) is None: self.propagate_args_to_deepspeed() diff --git a/src/transformers/training_args.py b/src/transformers/training_args.py index ca6f32279f..638875bb53 100644 --- a/src/transformers/training_args.py +++ b/src/transformers/training_args.py @@ -1915,10 +1915,8 @@ class TrainingArguments: for fsdp_option in self.fsdp: if fsdp_option.upper() in FSDP_SHARDING_STRATEGY: # set environment variable for FSDP sharding strategy - os.environ[f"{prefix}SHARDING_STRATEGY"] = ( - str(FSDP_SHARDING_STRATEGY.index(fsdp_option.upper()) + 1) - if is_accelerate_available("0.26.0") - else fsdp_option.upper() + os.environ[f"{prefix}SHARDING_STRATEGY"] = str( + FSDP_SHARDING_STRATEGY.index(fsdp_option.upper()) + 1 ) elif fsdp_option == FSDPOption.OFFLOAD: os.environ[f"{prefix}OFFLOAD_PARAMS"] = "true" diff --git a/src/transformers/utils/import_utils.py b/src/transformers/utils/import_utils.py index 6840921ddc..e58c1eaf62 100755 --- a/src/transformers/utils/import_utils.py +++ b/src/transformers/utils/import_utils.py @@ -87,7 +87,7 @@ FORCE_TF_AVAILABLE = os.environ.get("FORCE_TF_AVAILABLE", "AUTO").upper() # This is the version of torch required to run torch.fx features and torch.onnx with dictionary inputs. TORCH_FX_REQUIRED_VERSION = version.parse("1.10") -ACCELERATE_MIN_VERSION = "0.21.0" +ACCELERATE_MIN_VERSION = "0.26.0" FSDP_MIN_VERSION = "1.12.0" XLA_FSDPV2_MIN_VERSION = "2.2.0" diff --git a/tests/fsdp/test_fsdp.py b/tests/fsdp/test_fsdp.py index ff5bd85106..7e14cc8c9e 100644 --- a/tests/fsdp/test_fsdp.py +++ b/tests/fsdp/test_fsdp.py @@ -196,11 +196,7 @@ class TrainerIntegrationFSDP(TestCasePlus, TrainerIntegrationCommon): self.assertEqual(trainer.args.fsdp[0], sharding_strategy) self.assertEqual(trainer.args.fsdp[1], FSDPOption.OFFLOAD) self.assertEqual(trainer.args.fsdp[2], FSDPOption.AUTO_WRAP) - fsdp_sharding_strategy = ( - str(FSDP_SHARDING_STRATEGY.index(sharding_strategy.upper()) + 1) - if is_accelerate_available("0.26.0") - else sharding_strategy.upper() - ) + fsdp_sharding_strategy = str(FSDP_SHARDING_STRATEGY.index(sharding_strategy.upper()) + 1) self.assertEqual(os.environ[f"{prefix}SHARDING_STRATEGY"], fsdp_sharding_strategy) self.assertEqual(os.environ[f"{prefix}OFFLOAD_PARAMS"], "true") self.assertEqual(os.environ[f"{prefix}AUTO_WRAP_POLICY"], "TRANSFORMER_BASED_WRAP")