-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Parallelism config + TP + HSDP + BYODM (Bring Your Own Device Mesh) #3682
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
Parallelism config + TP + HSDP + BYODM (Bring Your Own Device Mesh) #3682
Conversation
d9aec5c
to
a402faf
Compare
src/accelerate/accelerator.py
Outdated
clip_context_manager = implicit_replication | ||
else: | ||
clip_context_manager = contextlib.nullcontext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice ! We will be able to clean up a bit trainer code after that
src/accelerate/utils/dataclasses.py
Outdated
def build_device_mesh(self, device_type: str): | ||
mesh = self.get_mesh() | ||
if not len(list(mesh)): | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we should probably raise an error but tbh we don't really need to deal with this case
examples/fsdp2/README.md
Outdated
@@ -2,6 +2,23 @@ | |||
|
|||
This folder contains examples of using FSDP2 with Accelerate, utilizing extra methods to improve training speed, performance or accuracy. | |||
|
|||
### FSDP2 + ND Parallelism | |||
|
|||
With `AccelerateDistributedConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean ParallelConfig
no ?
With `AccelerateDistributedConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: | |
With `ParallelConfig`, you can use 🤗 accelerate to train with n-dimensional parallelism. Script `nd_parallel.py` showcases just how you can do it. We enable you to configure 3 different parallel dimensions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have both because of the duplicate config upstream in transformers - but it would be good to clarify which to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be better to use the one from accelerate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Just a few nits
<Tip> | ||
Only use TP intra-node - therefore max TP size you should need is 8, you can also lower this as FSDP (`--dp-shard-size`) can be faster on smaller models with | ||
shorter sequence lengths. If you still cannot fit into memory, utilize `--dp-shard-size` as much as you can. Then to scale up to utilize all your GPUs, fill the rest | ||
with `--dp-replicate-size`. This is only a general guideline, you can (and should) experiment with different parallelism configurations to find the best one for your model and hardware. You can learn more about the general strategies for parallelism in our [blog](TODO) or if you wanna dive deep, read the [Ultra-Scale Playbook](https://huggingface.co/spaces/nanotron/ultrascale-playbook). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the blog isn't ready, so we kind of need to keep the todo there haha (we'll finish before release)
src/accelerate/accelerator.py
Outdated
def parallelism_config(self) -> ParallelismConfig | None: | ||
return self.state.parallelism_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
syntax only works with py3.10 but we still need to support py3.9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will drop py3.9 in october btw !
What does this PR do?
Building on #3651
Dependencies:
ParallelismConfig
in HFTrainerFixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
cc @S1ro1
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.