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

[FSDP] Make env var and dataclass flag consistent for cpu_ram_efficient_loading #3307

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions src/accelerate/utils/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,16 @@ def __post_init__(self):
)
self.sync_module_states = True

if self.cpu_ram_efficient_loading != bool(
str_to_bool(os.environ.get(env_prefix + "CPU_RAM_EFFICIENT_LOADING", "False"))
):
env_var = env_prefix + "CPU_RAM_EFFICIENT_LOADING"
warnings.warn(
f"The `cpu_ram_efficient_loading` flag for `FullyShardedDataParallelPlugin` does not match the environment variable {env_var}. "
"Setting environment variable to match `cpu_ram_efficient_loading`."
)
os.environ[env_var] = str(self.cpu_ram_efficient_loading)

if isinstance(self.mixed_precision_policy, dict):
self.set_mixed_precision(self.mixed_precision_policy)

Expand Down