-
Notifications
You must be signed in to change notification settings - Fork 4.9k
[AutoTP] Allow ZeRO stage 3 inference with tensor parallelism #8167
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -628,10 +628,11 @@ def _configure_tensor_parallel_states(self, model): | |
| and registering a pre-hook to ensure that the Dataloader inputs are consistent across ranks. | ||
| """ | ||
| self._set_client_model(model) | ||
| # sanity check | ||
| # currently, the compatibility between 'autotp' and 'zero > 1' has not been validated | ||
| assert self.zero_optimization_stage( | ||
| ) <= 2, "Currently, the compatibility between 'autotp' and 'zero_stage = 3' has not been validated" | ||
| if self.zero_optimization_stage() > 2 and (self.client_optimizer or self.optimizer_name()): | ||
| raise NotImplementedError("AutoTP together with ZeRO stage 3 is currently supported only for inference " | ||
| "(no optimizer). Running it with an optimizer is disabled because TP-aware " | ||
| "checkpoint consolidation is not yet implemented and would silently produce " | ||
| "incomplete checkpoints.") | ||
|
|
||
| self.mpu = groups | ||
| self.mpu._init_tp_mesh_device(tensor_model_parallel_size=self.autotp_size()) | ||
|
Comment on lines
637
to
638
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comments had been addressed by allow autotp only in zero3-inference mode. If there is an optimizer, the assertion will block it. The compatibility between autotp and checkpoint saving should be tracked with a seperate issue and fixed in a seperate PR. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -763,7 +763,7 @@ Configuring the asynchronous I/O module for offloading parameter and optimizer s | |
| | Submit requests to storage device in an overlapped fashion without waiting for completion of earlier requests. | `true` | | ||
|
|
||
| ### Tensor Parallel (AutoTP) | ||
| Configure AutoTP tensor parallelism for training via the DeepSpeed config and hybrid TP + ZeRO. AutoTP supports ZeRO stages 0, 1, and 2 (stage 3 is not supported). `deepspeed.tp_model_init()` remains supported for backward compatibility but is not required when `tensor_parallel` is set in the config. | ||
| Configure AutoTP tensor parallelism for training via the DeepSpeed config and hybrid TP + ZeRO. AutoTP supports ZeRO stages 0, 1, and 2. ZeRO stage 3 is supported only for inference (no optimizer); training with stage 3 is not yet supported. `deepspeed.tp_model_init()` remains supported for backward compatibility but is not required when `tensor_parallel` is set in the config. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel this description is a little confusing. Shall we say ZeRO stage 3 is supported only for inference in the context of on-policy distillation?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zero inference can also support other scenario where model is too large to fit in GPU memory, so not only for OPD. |
||
|
|
||
| When a HuggingFace model provides a built-in `tp_plan` (via `model.config.base_model_tp_plan`), DeepSpeed automatically detects and uses it. In this case, neither `preset_model` nor `partition_config` is required -- just set `autotp_size`. If `partition_config` is also provided, it takes precedence over the model's `tp_plan`. | ||
| ```json | ||
|
|
||
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.
So this means we cannot apply AutoTP + ZeRO stage 3 to student models?
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.
Yes, student model need to have checkpoint saved, and zero stage 3 checkpoint saving does not support AutoTP yet. This would be taken care of in another PR (still work in progress).