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

Introduce no_sync context wrapper + clean up some more warnings for DDP #428

Merged
merged 81 commits into from
Jun 8, 2022

Conversation

muellerzr
Copy link
Collaborator

Introduce no_sync context wrapper

What does this add?

  • This PR adds a no_sync wrapper that shadows torch.nn.parallel.DistributedDataParallel.no_sync but will do nothing if we're not in a DDP process
  • It also refactors launch args for torchrun into a separate util to make reusing it in tests + launch easier

Why is it needed?

This lets us use Accelerator eventually for gradient accumulation

What parts of the API does this impact?

User-facing:

  • Introduces Accelerator.no_sync(model) to perform the equivalent of model.no_sync() (if in ddp, if not it does nothing)

Non-user facing:

  • Introduced tests that mimic the official tests for no_sync in PyTorch to ensure those work, and CPU tests to make sure that when not in DDP it's a noop context manager

@muellerzr muellerzr requested a review from sgugger June 8, 2022 13:43
@muellerzr
Copy link
Collaborator Author

@sgugger good for a rereview, slow test logs can be seen here passing: https://github.com/huggingface/accelerate/runs/6794400970?check_suite_focus=true

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating on this!

Just missing a by-feature example of use :-)

@muellerzr muellerzr merged commit 1424a8e into main Jun 8, 2022
@muellerzr muellerzr deleted the no_sync branch June 8, 2022 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants