Skip to content

Commit 2e3a21a

Browse files
committed
[dtensor][debug] tutorial showing users how to use commdebugmode and giving access to visual browser
1 parent 6f9b767 commit 2e3a21a

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

distributed_comm_debug_mode.rst

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Prerequisites:
1111

1212

1313
What is CommDebugMode and why is it useful
14-
------------------
14+
------------------------------------------
1515
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.
1616

1717

@@ -26,7 +26,7 @@ Using CommDebugMode and getting its output is very simple.
2626
output = model(inp)
2727
2828
# print the operation level collective tracing information
29-
print(comm_mode.generate_comm_debug_tracing_table(noise_level=2))
29+
print(comm_mode.generate_comm_debug_tracing_table(noise_level=0))
3030
3131
# log the operation level collective tracing information to a file
3232
comm_mode.log_comm_debug_tracing_table_to_file(
@@ -36,16 +36,35 @@ Using CommDebugMode and getting its output is very simple.
3636
# dump the operation level collective tracing information to json file,
3737
# used in the visual browser below
3838
comm_mode.generate_json_dump(noise_level=2)
39-
.. code-block:: python
4039
41-
All users have to do is wrap the code running the model in CommDebugMode and call the API that they want to use to display the data.
42-
Documentation Title
43-
===================
40+
"""
41+
This is what the output looks like for a MLPModule at noise level 0
42+
Expected Output:
43+
Global
44+
FORWARD PASS
45+
*c10d_functional.all_reduce: 1
46+
MLPModule
47+
FORWARD PASS
48+
*c10d_functional.all_reduce: 1
49+
MLPModule.net1
50+
MLPModule.relu
51+
MLPModule.net2
52+
FORWARD PASS
53+
*c10d_functional.all_reduce: 1
54+
"""
55+
56+
All users have to do is wrap the code running the model in CommDebugMode and call the API that they want to use to display the data. One important thing to note
57+
is that the users can use a noise_level arguement to control how much information is displayed to the user. You can see what each noise_level will display to the user.
58+
59+
| 0. prints module-level collective counts
60+
| 1. prints dTensor operations not included in trivial operations, module information
61+
| 2. prints operations not included in trivial operations
62+
| 3. prints all operations
4463
45-
Introduction to the Module
46-
--------------------------
64+
In the example above, users can see in the first picture that the collective operation, all_reduce, occurs once in the forward pass of the MLPModule. The second picture provides a greater level of detail, allowing users to pinpoint that the all-reduce operation happens in the second linear layer of the MLPModule.
4765

48-
Below is the interactive module tree visualization:
66+
67+
Below is the interactive module tree visualization that users can upload their JSON dump to:
4968

5069
.. raw:: html
5170

@@ -155,5 +174,3 @@ Below is the interactive module tree visualization:
155174
<script src="https://cdn.jsdelivr.net/gh/pytorch/pytorch@main/torch/distributed/_tensor/debug/comm_mode_broswer_visual.js"></script>
156175
</body>
157176
</html>
158-
159-
.. raw:: html

0 commit comments

Comments
 (0)