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

Add auto_wrap option in fairscale integration #10673

Merged
merged 2 commits into from
Mar 12, 2021
Merged

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Mar 11, 2021

What does this PR do?

This PR adds support for the auto_wrap function added by fairscale to automatically wrap the model's modules in the FSDP container (necessary for ZeRO-DP3).

cc @stas00 So you are informed for when you want to experiment more with fairscale.

@sgugger sgugger requested a review from LysandreJik March 11, 2021 20:14
@@ -470,10 +470,10 @@ class TrainingArguments:
sharded_ddp: str = field(
default="",
metadata={
"choices": ["simple", "zero_dp_2", "zero_dp_3", "zero_dp_2 offload", "zero_dp_3 offload"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Choices started to grow longer as there are 4 more possibilities of options now. Can put it back if you really want to but I think the doc is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

but why do all combinations? why not just list the components

Copy link
Contributor

Choose a reason for hiding this comment

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

"choices": ["simple", "zero_dp_2", "zero_dp_3", "offload", "auto_wrap"],

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This instruction will fail if we pass anything not in the list of choices, like `"zero_dp_2 offload".

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I understand! It doesn't know of composite values and would have failed anyway if one were to pass: "offload zero_dp_2 offload" (reverse).

So it's either subclassing this argparse behavior to support compose values or removing it as you did.

I think as long as the help entry for that option lists all the choices, which it does, then it's good enough.

@@ -570,7 +570,7 @@ def __post_init__(self):
"`--sharded_ddp offload` can't work on its own. It needs to be added to `--sharded_ddp zero_dp_2` or "
'`--sharded_ddp zero_dp_3`. For example, `--sharded_ddp "zero_dp_2 offload"`.'
)
elif len(self.sharded_ddp) > 1 and ShardedDDPOption.Simple in self.sharded_ddp:
elif len(self.sharded_ddp) > 1 and ShardedDDPOption.SIMPLE in self.sharded_ddp:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Typo fix

@stas00 stas00 self-requested a review March 12, 2021 03:44
Copy link
Contributor

@stas00 stas00 left a comment

Choose a reason for hiding this comment

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

Awesome!

Let's merge this and hopefully I will start testing tomorrow.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Very nice, it's cool that they introduced this!

@sgugger sgugger merged commit e8246f7 into master Mar 12, 2021
@sgugger sgugger deleted the fairscale_autowrap branch March 12, 2021 12:50
Iwontbecreative pushed a commit to Iwontbecreative/transformers that referenced this pull request Jul 15, 2021
* Add auto_wrap option in fairscale integration

* Style
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.

3 participants