Ring

Description

This is the Ring algorithm. All NPUs are connected in a ring. Each NPU has a left NPU and a right NPU, where one is for receiving data and the other for sending data. The gradient accumulation is completed cyclically, and then the parameter synchronization is performed cyclically.

The Ring algorithm applies to the star or fat-tree topology. It connects the single-port duplex links of all NPUs in series through a ring.

The following figure shows the process of implementing the AllReduce operator using the Ring algorithm. In each step, the corresponding data block is sent to the downstream. After one round along the ring, the ReduceScatter phase is complete. After the second round along the ring, the AllGather phase is complete.

The time complexity of the Ring algorithm is O(n – 1), where n indicates the number of NPUs on the ring.

Required Time Calculation

The overall idea is as follows: All participating ranks form a ring. Each rank communicates only with its left and right ranks. If the number of ranks is p, the number of communication times is p – 1, and data is exchanged each time.

Table 1 Time required for each operation in the Ring algorithm

Operation

Time Required

Scatter

Gather

Broadcast

The implementation is Scatter+AllGather, and the time required is as follows.

Reduce

The implementation is ReduceScatter+Gather, and the time required is as follows.

ReduceScatter

AllGather

AllReduce

The implementation is ReduceScatter+AllGather, and the time required is as follows.