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

don't use no_sync when deepspeed doesn't support it for certain zero stages #35157

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

winglian
Copy link
Contributor

@winglian winglian commented Dec 9, 2024

What does this PR do?

Deepspeed 0.16 has assertions preventing the use of no_sync with zero 2/3. see https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/engine.py#L1986-L2004

it seems people are reporting this here microsoft/DeepSpeed#6793, and I'm assuming that everyone is using accelerate/transformers as downgrading to deepspeed 0.15.4 makes it "work" for them.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@muellerzr

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@winglian
Copy link
Contributor Author

winglian commented Dec 9, 2024

might have to broaden deepspeed for all zero cases? https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/engine.py#L2208-L2209

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Since we should disable it for all DS (apparently), let's just go ahead and do that. I'll apply a similar fix in Accelerator.

cc @SunMarc

context = (
functools.partial(self.accelerator.no_sync, model=model)
if i != len(batch_samples) - 1
if i != len(batch_samples) - 1 and not disable_deepspeed_no_sync
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if i != len(batch_samples) - 1 and not disable_deepspeed_no_sync
if i != len(batch_samples) - 1 and not self.accelerator.distributed_type == DistributedType.DEEPSPEED

Choose a reason for hiding this comment

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

may i ask which version of transformers support this fix-up? mine is 4.46.0. same problem with deepspeed 0.16

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

LGTM with zach suggestion !

Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Thanks! We've also confirmed this fixes up all the fails users reported wrt deepspeed. cc @ArthurZucker for final post wing doing quality ;)

@SunMarc SunMarc requested a review from ArthurZucker December 13, 2024 13:17
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

sorry for breaking this ... and thanks for the fix!

@ArthurZucker
Copy link
Collaborator

can you just run make fixup

@ArthurZucker ArthurZucker merged commit add53e2 into huggingface:main Dec 13, 2024
1 of 5 checks passed
ArthurZucker pushed a commit that referenced this pull request Dec 13, 2024
…stages (#35157)

* don't use no_sync when deepspeed doesn't support it for certain zero stages

* chore: lint

* fix no_sync context for deepspeed across all zero types

* chore: lint
inkcherry pushed a commit to inkcherry/transformers that referenced this pull request Jan 15, 2025
…stages (huggingface#35157)

* don't use no_sync when deepspeed doesn't support it for certain zero stages

* chore: lint

* fix no_sync context for deepspeed across all zero types

* chore: lint
@AetherPrior
Copy link

Strangely, this issue still exists on deepspeed==0.16.2, has this fix been pushed to a stable release yet?

@ArthurZucker
Copy link
Collaborator

This is on 4.48 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants