You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,152 +15,25 @@ What is CommDebugMode and why is it useful
15
15
As the size of models continues to increase, users are seeking to leverage various combinations of parallel strategies to scale up distributed training. However, the lack of interoperability between existing solutions poses a significant challenge, primarily due to the absence of a unified abstraction that can bridge these different parallelism strategies. To address this issue, PyTorch has proposed DistributedTensor (DTensor)which abstracts away the complexities of tensor communication in distributed training, providing a seamless user experience. However, this abstraction creates a lack of transparency that can make it challenging for users to identify and resolve issues. To address this challenge, my internship project aims to develop and enhance CommDebugMode, a Python context manager that will serve as one of the primary debugging tools for DTensors. CommDebugMode is a python context manager that enables users to view when and why collective operations are happening when using DTensors, addressing this problem.
16
16
17
17
18
-
Why DeviceMesh is Useful
18
+
How to use CommDebugMode
19
19
------------------------
20
-
DeviceMesh is useful when working with multi-dimensional parallelism (i.e. 3-D parallel) where parallelism composability is required. For example, when your parallelism solutions require both communication across hosts and within each host.
21
-
The image above shows that we can create a 2D mesh that connects the devices within each host, and connects each device with its counterpart on the other hosts in a homogenous setup.
22
-
23
-
Without DeviceMesh, users would need to manually set up NCCL communicators, cuda devices on each process before applying any parallelism, which could be quite complicated.
24
-
The following code snippet illustrates a hybrid sharding 2-D Parallel pattern setup without :class:`DeviceMesh`.
25
-
First, we need to manually calculate the shard group and replicate group. Then, we need to assign the correct shard and
26
-
replicate group to each rank.
27
-
28
-
.. code-block:: python
29
-
30
-
import os
31
-
32
-
import torch
33
-
import torch.distributed as dist
34
-
35
-
# Understand world topology
36
-
rank =int(os.environ["RANK"])
37
-
world_size =int(os.environ["WORLD_SIZE"])
38
-
print(f"Running example on {rank=} in a world with {world_size=}")
39
-
40
-
# Create process groups to manage 2-D like parallel pattern
For simplicity of demonstration, we are simulating 2D parallel using only one node. Note that this code snippet can also be used when running on multi hosts setup.
75
-
76
-
With the help of :func:`init_device_mesh`, we can accomplish the above 2D setup in just two lines, and we can still
77
-
access the underlying :class:`ProcessGroup` if needed.
78
-
79
-
80
-
.. code-block:: python
81
-
82
-
from torch.distributed.device_mesh import init_device_mesh
When working with large scale training, you might have more complex custom parallel training composition. For example, you may need to slice out submeshes for different parallelism solutions.
141
-
DeviceMesh allows users to slice child mesh from the parent mesh and re-use the NCCL communicators already created when the parent mesh is initialized.
142
-
143
-
.. code-block:: python
144
-
145
-
from torch.distributed.device_mesh import init_device_mesh
0 commit comments