Skip to content

Commit 6ebddcd

Browse files
authored
fixing fsdp autowrap functionality (#475)
* fixing fsdp autowrap functionality * updating version requirements * update version to latest torch stable version * quality
1 parent 4a7bc3b commit 6ebddcd

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

examples/by_feature/fsdp_with_peak_mem_tracking.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ def training_function(config, args):
112112
# We need to initialize the trackers we use, and also store our configuration
113113
if args.with_tracking:
114114
if accelerator.is_main_process:
115-
run = os.path.split(__file__)[-1].split(".")[0]
116-
if args.logging_dir:
117-
run = os.path.join(args.logging_dir, run)
118-
accelerator.print(run)
119-
accelerator.init_trackers(run, config)
115+
experiment_config = vars(args)
116+
accelerator.init_trackers("fsdp_glue_no_trainer", experiment_config)
120117

121118
tokenizer = AutoTokenizer.from_pretrained(args.model_name_or_path)
122119
datasets = load_dataset("glue", "mrpc")

src/accelerate/accelerator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def __init__(
188188
deepspeed_plugin.set_deepspeed_weakref()
189189

190190
if os.environ.get("USE_FSDP", "false") == "true" or isinstance(fsdp_plugin, FullyShardedDataParallelPlugin):
191-
if is_torch_version("<", "1.12.0.dev20220418+cu113"):
192-
raise ValueError("FSDP requires PyTorch >= 1.12.0.dev20220418+cu113")
191+
if is_torch_version("<", "1.12.0"):
192+
raise ValueError("FSDP requires PyTorch >= 1.12.0")
193193

194194
if fsdp_plugin is None: # init from env variables
195195
fsdp_plugin = FullyShardedDataParallelPlugin() if os.environ.get("USE_FSDP", "false") == "true" else None

src/accelerate/utils/dataclasses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class FullyShardedDataParallelPlugin:
442442

443443
def __post_init__(self):
444444
from torch.distributed.fsdp.fully_sharded_data_parallel import CPUOffload, ShardingStrategy
445-
from torch.distributed.fsdp.wrap import default_auto_wrap_policy
445+
from torch.distributed.fsdp.wrap import size_based_auto_wrap_policy
446446

447447
if self.sharding_strategy is None:
448448
self.sharding_strategy = ShardingStrategy(int(os.environ.get("FSDP_SHARDING_STRATEGY", 1)))
@@ -458,4 +458,6 @@ def __post_init__(self):
458458

459459
if self.auto_wrap_policy is None:
460460
if self.min_num_params > 0:
461-
self.auto_wrap_policy = functools.partial(default_auto_wrap_policy, min_num_params=self.min_num_params)
461+
self.auto_wrap_policy = functools.partial(
462+
size_based_auto_wrap_policy, min_num_params=self.min_num_params
463+
)

0 commit comments

Comments
 (0)