deepspeedai / deepspeedai/DeepSpeed

How to properly use tensor_parallel while applying also Zero Stage 3

Open
#7,389 1 comment 0 reactions 1 assignee View on GitHub

@inkcherry is already working on this.

Since Jul 23, 2025.

Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

We were trying to pass the deepspeed config file to another training framework. We found that the configuration of tensor parallelism with Zero Stage 3 enabled is a bit confusing. For instance, if we set:

···
"tensor_parallel": {
    "autotp_size": 2
}

we would get the error

AssertionError Currently, the compatibility between autotp and zero_stage = 3 has been validated

To enable both TP and Zero 3, we would have to set:

···
"tensor_parallel": {
    "tensor_parallel": {"tp_size: 2}
}

We found the following commend in the code:

class TPConfig(DeepSpeedConfigModel):
""" Configure tensor parallelism settings """

tp_size: int = 1
""" Number of devices to split the model across using tensor parallelism. """

tp_grain_size: int = 1
"The variable required by the autoTP parser has not been activated in training yet"
"as it depends on the gather logic that supports uneven partitioning. "
"Desired MLP/lm_head tp size granularity. DNN library favors tensor size in granularity of power of 2, we pick  64 as a default size."

mpu: object = None
"""
A model parallelism unit object that implements
``get_{model,data}_parallel_{rank,group,world_size}()``.
"""

tp_group: object = None

What is the difference between this autotp_size and tp_size? Why autotp_size is not compatible with Zero 3? How should we properly avoid reduce GPU memory while Zero 3 still triggers OOM?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.