Skip to content

Commit 1cd543c

Browse files
authored
Add img to collective docs (#4038)
* add img to collective docs * add reduce img to docs * modified img * modified some bugs and add docs to recompute * complement global_gather and global_scatter docs * modified the scatter op img * fix small error * complement the docs by review * complement the annotations to the communication operators according to the figures * add annotation to the rank * modified the split figures * modified the annotation of paddle.distributed.split
1 parent c06723e commit 1cd543c

23 files changed

+172
-8
lines changed

docs/api/paddle/distributed/all_gather_cn.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ all_gather
77
.. py:function:: paddle.distributed.all_gather(tensor_list, tensor, group=0)
88
99
进程组内所有进程的指定tensor进行聚合操作,并返回给所有进程聚合的结果。
10+
如下图所示,4个GPU分别开启4个进程,每张卡上的数据用卡号代表,
11+
经过all_gather算子后,每张卡都会拥有所有卡的数据。
12+
13+
.. image:: ./img/allgather.png
14+
:width: 800
15+
:alt: all_gather
16+
:align: center
1017

1118
参数
1219
:::::::::

docs/api/paddle/distributed/all_reduce_cn.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ all_reduce
77
.. py:function:: paddle.distributed.all_reduce(tensor, op=ReduceOp.SUM, group=0)
88
99
进程组内所有进程的指定tensor进行归约操作,并返回给所有进程归约的结果。
10+
如下图所示,4个GPU分别开启4个进程,每张卡上的数据用卡号代表,规约操作为求和,
11+
经过all_reduce算子后,每张卡都会拥有所有卡数据的总和。
12+
13+
.. image:: ./img/allreduce.png
14+
:width: 800
15+
:alt: all_reduce
16+
:align: center
1017

1118
参数
1219
:::::::::

docs/api/paddle/distributed/alltoall_cn.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ alltoall
66

77
.. py:function:: paddle.distributed.alltoall(in_tensor_list, out_tensor_list, group=None, use_calc_stream=True)
88
9-
将in_tensor_list里面的tensors分发到所有参与的卡并将结果tensors汇总到out_tensor_list。
10-
9+
将in_tensor_list里面的tensors按照卡数均分并按照卡的顺序分发到所有参与的卡并将结果tensors汇总到out_tensor_list。
10+
如下图所示,GPU0卡的in_tensor_list会按照两张卡拆分成0_0和0_1, GPU1卡的in_tensor_list同样拆分成1_0和1_1,经过alltoall算子后,
11+
GPU0卡的0_0会发送给GPU0,GPU0卡的0_1会发送给GPU1,GPU1卡的1_0会发送给GPU0,GPU1卡的1_1会发送给GPU1,所以GPU0卡的out_tensor_list包含0_0和1_0,
12+
GPU1卡的out_tensor_list包含0_1和1_1。
13+
14+
.. image:: ./img/alltoall.png
15+
:width: 800
16+
:alt: alltoall
17+
:align: center
1118

1219
参数
1320
:::::::::

docs/api/paddle/distributed/broadcast_cn.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ broadcast
66

77
.. py:function:: paddle.distributed.broadcast(tensor, src, group=0)
88
9-
广播一个Tensor给其他所有进程
9+
广播一个Tensor给其他所有进程。
10+
如下图所示,4个GPU分别开启4个进程,GPU0卡拥有数据,经过broadcast算子后,会将这个数据传播到所有卡上。
11+
12+
.. image:: ./img/broadcast.png
13+
:width: 800
14+
:alt: broadcast
15+
:align: center
1016

1117
参数
1218
:::::::::
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.. _cn_api_distributed_fleet_utils_recompute:
2+
3+
recompute
4+
-------------------------------
5+
6+
7+
.. py:function:: paddle.distributed.fleet.utils.recompute(function, *args, **kwargs)
8+
9+
重新计算中间激活函数值来节省显存。
10+
11+
参数
12+
:::::::::
13+
- function (paddle.nn.Sequential) - 模型前向传播的部分连续的层函数组成的序列,
14+
它们的中间激活函数值将在前向传播过程中被释放掉来节省显存,并且在反向梯度计算的时候会重新被计算。
15+
- args (Tensor) - function的输入。
16+
- kwargs (Dict) - kwargs只应该包含preserve_rng_state的键值对,用来表示是否保存前向的rng,如果为True,那么在反向传播的重计算前向时会还原上次前向的rng值。默认preserve_rng_state为True。
17+
18+
返回
19+
:::::::::
20+
function作用在输入的输出
21+
22+
代码示例
23+
:::::::::
24+
COPY-FROM: paddle.distributed.fleet.utils.recompute
51.2 KB
Loading
35.9 KB
Loading
30.4 KB
Loading
44.9 KB
Loading
75.5 KB
Loading

0 commit comments

Comments
 (0)