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

Create the FSDP Plugin in the trainer explicitly rather wait for it to be setup by accelerate #33085

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor building accelerator args so it can easily be extended in do…
…wnstream trainers
  • Loading branch information
winglian committed Aug 22, 2024
commit bfd24f29529b26c5bd072efa7c62bb147d5ed787
5 changes: 4 additions & 1 deletion src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4705,7 +4705,7 @@ def _add_sm_patterns_to_gitignore(self) -> None:
self.repo.git_commit("Add *.sagemaker patterns to .gitignore.")
self.repo.git_push()

def create_accelerator_and_postprocess(self):
def build_accelerator_args(self):
grad_acc_kwargs = {}
if is_accelerate_available("0.28.0") and self.args.accelerator_config.gradient_accumulation_kwargs is not None:
grad_acc_kwargs = self.args.accelerator_config.gradient_accumulation_kwargs
Expand Down Expand Up @@ -4758,7 +4758,10 @@ def create_accelerator_and_postprocess(self):
args["dataloader_config"] = dataloader_config
else:
args.update(accelerator_config)
return args

def create_accelerator_and_postprocess(self):
args = self.build_accelerator_args()
# create accelerator object
self.accelerator = Accelerator(**args)
# some Trainer classes need to use `gather` instead of `gather_for_metrics`, thus we store a flag
Expand Down