Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_fsdp_enabled() logic and make low_cpu_mem_usage by default #29961

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def is_fsdp_enabled():
torch.distributed.is_available()
and torch.distributed.is_initialized()
and strtobool(os.environ.get("ACCELERATE_USE_FSDP", "False")) == 1
and strtobool(os.environ.get("FSDP_CPU_RAM_EFFICIENT_LOADING", "False")) == 1
)


Expand Down Expand Up @@ -2869,7 +2868,10 @@ def from_pretrained(
adapter_name = kwargs.pop("adapter_name", "default")
use_flash_attention_2 = kwargs.pop("use_flash_attention_2", False)

if is_fsdp_enabled():
# FSDP_CPU_RAM_EFFICIENT_LOADING is set by Accelerate launcher not by TrainingArguments.
# Unless it is turned off explicitly low_cpu_mem_usage should be turned on by default
# when FSDP is on since sync_module_states is also default on.
if is_fsdp_enabled() and strtobool(os.environ.get("FSDP_CPU_RAM_EFFICIENT_LOADING", "True")) == 1:
low_cpu_mem_usage = True

if use_auth_token is not None:
Expand Down