Skip to content

Commit

Permalink
fix name error when accelerate is not available (huggingface#26278)
Browse files Browse the repository at this point in the history
* fix name error when accelerate is not available

* fix `is_fsdp_available`
  • Loading branch information
pacman100 authored and blbadger committed Nov 8, 2023
1 parent 7195df7 commit 9eeeef6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def is_accelerate_available(min_version: str = None):


def is_fsdp_available(min_version: str = "1.12.0"):
return version.parse(_torch_version) >= version.parse(min_version)
return is_torch_available() and version.parse(_torch_version) >= version.parse(min_version)


def is_optimum_available():
Expand Down
1 change: 1 addition & 0 deletions tests/fsdp/test_fsdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def get_master_port(real_launcher=False):
# hack to restore original logging level pre #21700
get_regression_trainer = partial(tests.trainer.test_trainer.get_regression_trainer, log_level="info")

require_fsdp_version = require_fsdp
if is_accelerate_available():
from accelerate.utils.constants import (
FSDP_PYTORCH_VERSION,
Expand Down

0 comments on commit 9eeeef6

Please sign in to comment.