safeguard torch distributed check (#26056)

This commit is contained in:
Sourab Mangrulkar 2023-09-13 10:26:37 +05:30 committed by GitHub
parent 12f043eaea
commit 73b13ac099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,11 @@ _init_weights = True
def is_fsdp_enabled():
return torch.distributed.is_initialized() and strtobool(os.environ.get("ACCELERATE_USE_FSDP", "False")) == 1
return (
torch.distributed.is_available()
and torch.distributed.is_initialized()
and strtobool(os.environ.get("ACCELERATE_USE_FSDP", "False")) == 1
)
def is_fsdp_enabled_and_dist_rank_0():