2.5D Tensor Parallelism
Author: Zhengda Bian, Yongbin Li
Prerequisite
Example Code
Related Paper
Introduction
Compared with 1D tensor parallelism, 2D parallelism reduces the memory cost, but may introduce more communication.
Therefore, a 2.5D tensor parallelism algorithm was proposed based on 2.5D SUMMA to reduce communication by using more devices.
Let's still take a linear layer Y=XA as an example.
Given P=q×q×d processors (necessary condition), e.g. q=d=2, we split the input X into d×q rows and q columns as
⎣⎢⎢⎢⎡X00X10X20X30X01X11X21X31⎦⎥⎥⎥⎤, which can be reshaped into d layers as
[X00X10X01X11] and [X20X30X21X31]. Also, the weight A is split into
[A00A10A01A11]. For each layer of X, we use the SUMMA algorithm to multiply X and A.
Then, we have the output
[Y00=X00A00+X01A10Y10=X10A00+X11A10Y01=X00A01+X01A11Y11=X10A01+X11A11] and [Y20=X20A00+X21A10Y30=X30A00+X31A10Y21=X20A01+X21A11Y31=X30A01+X31A11]. Efficiency
Given P=q×q×d processors, we present the theoretical computation and memory cost, as well as the communication cost based on the ring algorithm in both the forward and backward pass of 2.5D tensor parallelism.
Computation | Memory (parameters) | Memory (activations) | Communication (bandwidth) | Communication (latency) |
---|
O(1/dq2) | O(1/q2) | O(1/dq2) | O(3(q−1)(d+1)/dq) | O(6(q−1)) |
Usage
Currently the newest version of ColossalAI doesn't support 2.5D tensor parallelism, but this feature will be integrated into Shardformer
in future releases.
For more details about ideas and usages of Shardformer
, please refer to Shardformer Doc.
For users of older version of ColossalAI, please refer to ColossalAI-Examples - 2.5D Tensor Parallelism.