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
All reduce `input` between specified collection. This is a distributed API.
90
+
91
+
Args:
92
+
input (list|numpy.array): The input variable to do all_reduce between specified collection.
93
+
mode (str): "sum" or "min" or "max".
94
+
comm_world (str, optional): Collection used to execute all_reduce operation. Supported collections incude `worker` , `server` and `all` . The default is `worker` .
95
+
96
+
Returns:
97
+
output(Numpy.array|None): A numpy array with the same shape as the `input` .
98
+
99
+
Examples:
100
+
.. code-block:: python
101
+
102
+
# Save the following code in `train.py` , and then execute the command `fleetrun --server_num 2 --worker_num 2 train.py` .
103
+
from paddle.distributed.fleet.base.util_factory import fleet_util
104
+
import paddle.distributed.fleet as fleet
105
+
from paddle.distributed.fleet import PaddleCloudRoleMaker
comm_world (str, optional): Collection used to execute barrier operation. Supported collections incude `worker` , `server` and `all` . The default is `worker` .
142
+
143
+
Examples:
144
+
145
+
.. code-block:: python
146
+
# Save the following code in `train.py` , and then execute the command `fleetrun --server_num 2 --worker_num 2 train.py` .
147
+
148
+
from paddle.distributed.fleet.base.util_factory import fleet_util
149
+
import paddle.distributed.fleet as fleet
150
+
from paddle.distributed.fleet import PaddleCloudRoleMaker
151
+
import sys
152
+
153
+
def train():
154
+
role = PaddleCloudRoleMaker(
155
+
is_collective=False,
156
+
init_gloo=True,
157
+
path="./tmp_gloo")
158
+
fleet.init(role)
159
+
fleet_util._set_role_maker(role)
160
+
161
+
if fleet.is_server():
162
+
fleet_util.barrier("server")
163
+
print("all server arrive here")
164
+
elif fleet.is_worker():
165
+
fleet_util.barrier("worker")
166
+
print("all server arrive here")
167
+
fleet_util.barrier("all")
168
+
print("all servers and workers arrive here")
169
+
170
+
if __name__ == "__main__":
171
+
train()
172
+
"""
94
173
_comm_world=self.__check_comm_world(comm_world)
95
174
self.role_maker._barrier(_comm_world)
96
175
97
176
defall_gather(self, input, comm_world="worker"):
177
+
"""
178
+
All gather `input` between specified collection.
179
+
180
+
Args:
181
+
input (Int|Float): The input variable to do all_gather between specified collection.
182
+
comm_world (str, optional): Collection used to execute all_reduce operation. Supported collections incude `worker` , `server` and `all` . The default is `worker` .
183
+
184
+
Returns:
185
+
output (List): A list of gathered values.
186
+
187
+
Examples:
188
+
189
+
.. code-block:: python
190
+
191
+
# Save the following code in `train.py` , and then execute the command `fleetrun --server_num 2 --worker_num 2 train.py` .
192
+
from paddle.distributed.fleet.base.util_factory import fleet_util
193
+
import paddle.distributed.fleet as fleet
194
+
from paddle.distributed.fleet import PaddleCloudRoleMaker
0 commit comments