What Do 1D, 2D, 2.5D, and 3D Mean in Tensor Parallelism?

July 10, 2025

Tensor parallelism puts several GPUs to work on the same layer. Take a Transformer's linear layer: forward propagation computes β€œoutput = input Γ— weights + bias.” During training, both this multiplication and the multiplications that compute gradients during backpropagation can be distributed. Inference uses only the forward pass when generating text, but can use the same partition.12

Reading Colossal-AI's training documentation, I kept returning to the 2D, 2.5D, and 3D pages. A matrix only has rows and columns, so where does a third dimension come from? Why stop short of 4D or 5D? Readers familiar with linear layers can skip to the two-GPU 1D example.345

Prerequisites: how a linear layer computes its output

How many rows and columns do the input and output have?

Consider one text, tokenized into three tokens with integer IDs 17,42,817,42,8. The token embedding layer looks up rows 17,42,817,42,8 of its embedding table. With four numbers in each row, each token gains a vector of length 4. Arrange the three vectors in sequence order to obtain a 3Γ—43\times4 matrix with one row per position in the text.

The embedding layer performs lookups; subsequent linear layers combine existing token features into new ones. For a batch of BB texts padded to nn positions each, token IDs have shape BΓ—nB\times n, and the lookup output has shape BΓ—nΓ—dinB\times n\times d_{\mathrm{in}}, where dind_{\mathrm{in}} is the vector length. Consider just one sequence below. At an intermediate linear layer, stacking the incoming feature vectors by position gives the input matrix XX. The layer multiplies XX by its weight matrix WW, sharing the same WW across positions.

Suppose there are nn tokens with dind_{\mathrm{in}} input features each, and this layer produces hh output features per token. WW and the optional bias vector bb are trainable parameters; XX comes from this input. The forward formula is:

Y⏟nΓ—h=X⏟nΓ—dinW⏟dinΓ—h+b\underbrace{Y}_{n\times h} =\underbrace{X}_{n\times d_{\mathrm{in}}} \underbrace{W}_{d_{\mathrm{in}}\times h}+b

The length of bb is hh. Add the same bb to every output row. For three tokens going from four features each to two, multiply a 3Γ—43\times4 input by 4Γ—24\times2 weights to get a 3Γ—23\times2 output. The number of tokens stays at three; the number of features per token changes. Retaining the batch dimension gives input shape BΓ—nΓ—dinB\times n\times d_{\mathrm{in}} and output shape BΓ—nΓ—hB\times n\times h.

For output jj of input row ii, dot row ii of XX with column jj of WW and add bias bjb_j:

Yij=βˆ‘k=1dinXikWkj+bjY_{ij} = \sum_{k=1}^{d_{\mathrm{in}}} X_{ik} W_{kj} + b_j

As kk runs from 1 to dind_{\mathrm{in}}, each input feature is multiplied by its weight for output jj. Here YY is the linear layer's output. An activation function such as ReLU subsequently maps negative values to zero, yielding activations Aij=max⁑(0,Yij)A_{ij}=\max(0,Y_{ij}). In training memory discussions, activations more broadly means intermediate forward-pass data that the backward pass may need. The incoming XX can be called input activations; WW consists of model parameters.

How does a column of weights combine input features?

Gilbert Strang's Introduction to Linear Algebra gives a difference matrix example. The inputs are three squares 1,4,91,4,9, transformed into successive differences starting from zero. The book uses column vectors. In this article's row-vector notation the same calculation is:6

[149][1βˆ’1001βˆ’1001]=[135]\begin{bmatrix}1&4&9\end{bmatrix} \begin{bmatrix}1&-1&0\\0&1&-1\\0&0&1\end{bmatrix} =\begin{bmatrix}1&3&5\end{bmatrix}

Look at the second weight column, (βˆ’1,1,0)(-1,1,0). It subtracts the first number from the second and ignores the third. If the inputs are cumulative mileage readings starting from zero, the second output, 4βˆ’1=34-1=3, is the distance traveled on the second leg. Add other trips as rows of XX, and the same matrix gives each trip's distances row by row. Each column of a linear layer's WW likewise defines a combination of input features yielding one new feature, though its coefficients are usually learned.

Suppose we have three tokens. The first output neuron has four weights (1,0,1,0)(1,0,1,0). Set the bias to zero to see the relationship clearly. The neuron dots its four weights with the four input features of each token, yielding one number per token. Sharing the same weight column across all three positions gives a column of three values:

[123401012010]⏟3Γ—4[1010]⏟4Γ—1=[403]⏟3Γ—1\underbrace{\begin{bmatrix}1&2&3&4\\0&1&0&1\\2&0&1&0\end{bmatrix}}_{3\times4} \underbrace{\begin{bmatrix}1\\0\\1\\0\end{bmatrix}}_{4\times1} =\underbrace{\begin{bmatrix}4\\0\\3\end{bmatrix}}_{3\times1}

Generally, with dind_{\mathrm{in}} input features per token, one neuron has dind_{\mathrm{in}} weights. For a sequence of nn tokens, it produces nn scalars arranged as nΓ—1n\times1. Increasing to hh neurons expands the output to nΓ—hn\times h, with dinhd_{\mathrm{in}}h weights in the layer. Bias adds one parameter per neuron.

Letters help show that splitting does not drop connections. One token is [a,b,c,d], and the first output neuron's weights are [p₁,pβ‚‚,p₃,pβ‚„]. The first two inputs contribute aΒ·p₁ + bΒ·pβ‚‚, the last two contribute cΒ·p₃ + dΒ·pβ‚„, and only their sum gives the token's first output. The second output uses the same four inputs with the four weights of the second column. A dot product produces one number: multiplying 1Γ—2 by 2Γ—2 computes two dot products to obtain 1Γ—2. A vector cross product produces a vector, whereas the neuron needs a sum of corresponding products.

How does PyTorch store the weights and output?

Keep the three tokens and add an output neuron with weights (0,1,1,0)(0,1,1,0). The weights of nn.Linear(4, 2) have shape [2, 4], each row holding one neuron's four weights. The output has shape [3, 2], each row holding one token's two outputs. Fill in the example weights to compare indices directly:7

import torch
from torch import nn

x = torch.tensor([[1., 2., 3., 4.], [0., 1., 0., 1.], [2., 0., 1., 0.]])
layer = nn.Linear(4, 2, bias=False)
with torch.no_grad():
    layer.weight.copy_(torch.tensor([[1., 0., 1., 0.], [0., 1., 1., 0.]]))

y = layer(x)
# y.tolist()           β†’ [[4., 5.], [0., 1.], [3., 1.]]
# y[0].tolist()        β†’ [4., 5.]     第一δΈͺθ―ε…ƒηš„δΈ€δΈͺθΎ“ε‡Ί
# y[:, 0].tolist()     β†’ [4., 0., 3.]  第一δΈͺη₯žη»ε…ƒε―ΉδΈ‰δΈͺθ―ε…ƒηš„θΎ“ε‡Ί

layer.weight[0] corresponds to the first column of this article's WW. We write Y=XWY=XW, and the layer(x) call above is mathematically equivalent to x @ layer.weight.T. Thus splitting WW by columns across two GPUs corresponds in PyTorch to splitting rows of layer.weight.7

πŸ““ Noteγ€€To group results by neuron in each inner list, y.T.tolist() gives [[4., 0., 3.], [5., 1., 1.]]. To feed the next layer, pass the [3, 2]-shaped y directly to a linear layer with two input features. Here y.T swaps the indices of a two-dimensional output, whereas layer.weight.T aligns weights for multiplication. For ordinary dense tensors, transposition shares the original storage. If later operations require contiguous memory, calling .contiguous() on a noncontiguous transpose makes a contiguous copy.8

What does backpropagation send to the preceding layer?

Suppose this layer receives three tokens with four input features each. Its two output neurons have weights (1,0,1,0)(1,0,1,0) and (0,1,1,0)(0,1,1,0) and zero bias. Put each token in a row of XX and each neuron's weights in a column of WW. The forward calculation yields:

[123401012010]⏟XΒ (3Γ—4)[10011100]⏟WΒ (4Γ—2)=[450131]⏟YΒ (3Γ—2)\underbrace{\begin{bmatrix}1&2&3&4\\0&1&0&1\\2&0&1&0\end{bmatrix}}_{X\ (3\times4)} \underbrace{\begin{bmatrix}1&0\\0&1\\1&1\\0&0\end{bmatrix}}_{W\ (4\times2)} = \underbrace{\begin{bmatrix}4&5\\0&1\\3&1\end{bmatrix}}_{Y\ (3\times2)}

The 44 and 55 in the first row are the two neurons' outputs for the first token. Suppose ReLU follows, giving A=ReLU⁑(Y)A=\operatorname{ReLU}(Y), then AA is compared with a target to compute loss LL. Backpropagation walks this path in reverse, using the chain rule at each step to calculate how the loss depends on the previous result:

  1. The loss function provides the starting gradient. For every position of AA, calculate the sensitivity of the loss to a small change, giving βˆ‚L/βˆ‚A\partial L/\partial A. The loss is a scalar, but its gradient has three rows and two columns like AA.
  2. ReLU passes gradients position by position. At row one, column two, Y12=5Y_{12}=5 in the forward pass and remains 55 after ReLU, so the incoming gradient passes straight back. At a negative input, ReLU produces zero and zeroes that position's gradient. Applying this across positions yields the loss gradient with respect to the linear output, G=βˆ‚L/βˆ‚YG=\partial L/\partial Y.
  3. The linear layer computes gradients by matrix multiplication. It uses the forward input XX and incoming GG to calculate weight gradients for the optimizer. It uses GG and weights WW to calculate the input gradient for the preceding layer. For trainable bias, sum the rows of GG along the token dimension. Here are the three results:
GradientCalculationShape in this exampleDestination
Weight gradientβˆ‚L/βˆ‚W=X⊀G\partial L/\partial W=X^\top G4Γ—24\times2, like WWOptimizer, to update weights
Input gradientβˆ‚L/βˆ‚X=GW⊀\partial L/\partial X=GW^\top3Γ—43\times4, like XXPrevious layer, to continue backpropagation
Bias gradient (when used)βˆ‚L/βˆ‚bj=βˆ‘iGij\partial L/\partial b_j=\sum_i G_{ij}Length 2, like bbOptimizer, to update bias

Here ⊀\top denotes transposition, swapping a matrix's rows and columns.2

What occupies GPU memory during training?

Keep the same three tokens, four features per token, two output neurons, and the bias-free setting from the code. Start on one GPU, assuming FP32 weights, activations, gradients, and both Adam statistics, at 4 bytes per number. Dense tensor data occupies element count Γ— bytes per element. Input XX, for instance, has 3Γ—4=123\times4=12 numbers and takes 48 bytes.9

When usedTensor on GPUShapeSize hereWhy retain it?
Forward, backward, updateWeights WW4Γ—24\times232 bytesAll tokens share eight weights, reused after updating for the next batch.
Forward, kept for backwardInput activations XX3Γ—43\times448 bytesUsed for XWXW in forward and for weight gradients in backward.
ForwardLinear output YY and ReLU output AA3Γ—23\times2 each24 bytes eachYY goes to ReLU, AA goes to the next step, and AA indicates where gradients pass during backward.
BackwardIncoming ReLU gradient βˆ‚L/βˆ‚A\partial L/\partial A and linear gradient GG3Γ—23\times2 each24 bytes eachCarries the loss gradient backward for each output position.
BackwardInput gradient βˆ‚L/βˆ‚X\partial L/\partial X3Γ—43\times448 bytesPassed back to the previous layer.
Backward, retained for updateWeight gradient βˆ‚L/βˆ‚W\partial L/\partial W4Γ—24\times232 bytesOne gradient per weight for the optimizer.
Parameter update, retained across stepsAdam's first and second moments4Γ—24\times2 each32 bytes each, 64 totalMoving averages of each weight's gradient and squared gradient.

At update time, weights, weight gradients, and Adam's two statistics total 128 bytes. Two trainable biases add 8 bytes each for bias, bias gradient, and the two statistics, bringing that subtotal to 160 bytes. At the model input, three int64 token IDs occupy 24 bytes. At the end, a single FP32 loss value occupies 4 bytes. Count each at its own location.

πŸ““ Noteγ€€Each row gives tensor data size. Peak memory depends on simultaneous lifetimes. For example, keep XX until computing the weight gradient. ReLU can save AA for backward, allowing YY to be released after use. Count an activation shared between adjacent layers once. Operator workspaces and allocation behavior also affect peaks. Ordinary forward-only inference can release intermediates after use and dispenses with weight gradients and Adam state.10

Now assign one output neuron to each GPU. Resident weights per GPU fall from 32 to 16 bytes and local linear outputs from 24 to 12 bytes, but both neurons still need the complete 48-byte input. Which other data shrinks with the weights depends on the split direction.

1D: when two GPUs each do half, do we concatenate or add?

Compute Y=XWY=XW on two GPUs with zero bias. Three quantities are distinct: three tokens, four input features, and two output features. However we split, each token needs two outputs.

[123401012010]⏟XΒ (3Γ—4)[10011100]⏟WΒ (4Γ—2)=[450131]⏟YΒ (3Γ—2)\underbrace{\begin{bmatrix}1&2&3&4\\0&1&0&1\\2&0&1&0\end{bmatrix}}_{X\ (3\times4)} \underbrace{\begin{bmatrix}1&0\\0&1\\1&1\\0&0\end{bmatrix}}_{W\ (4\times2)} =\underbrace{\begin{bmatrix}4&5\\0&1\\3&1\end{bmatrix}}_{Y\ (3\times2)}

Column split: each GPU finishes some output features

Divide the two output features between GPUs. GPU A gets the first column of WW, B the second. Each column has four weights, so both read the complete XX. Each performs a (3Γ—4)(4Γ—1)(3\times4)(4\times1) multiplication, yielding its neuron's output for all three tokens:

XWA=[403],XWB=[511],Y=[XWAXWB]XW_A=\begin{bmatrix}4\\0\\3\end{bmatrix},\qquad XW_B=\begin{bmatrix}5\\1\\1\end{bmatrix},\qquad Y=\begin{bmatrix}XW_A & XW_B\end{bmatrix}

The complete input multiplies two differently colored weight columns to produce two adjacent output columns, starting with 4 and 5.

Teal represents GPU A, orange GPU B. Each finishes one column. Diagram drawn for this example.111

To obtain the full output, concatenate the two 3Γ—13\times1 results by column. For the first token, A has completed output 44 and B has completed output 55. More generally, splitting WW evenly by column leaves dinΓ—(h/2)d_{\mathrm{in}}\times(h/2) weights on each GPU, with nn rows and h/2h/2 columns of output.

GeLU acts elementwise. A can calculate GeLU(4)\mathrm{GeLU}(4) while B calculates GeLU(5)\mathrm{GeLU}(5), without concatenating their columns before activation.111

Row split: each GPU contributes partial sums to every output

Split the four input features between GPUs. A gets the first two rows of WW and first two columns of XX. B gets the remaining two rows and the last two columns of XX. Each GPU performs a (3Γ—2)(2Γ—2)(3\times2)(2\times2) multiplication and produces 3Γ—23\times2 numbers, but each number includes contributions from only two input features:

Y=[120120]⏟XAWA+[330011]⏟XBWB=[450131]Y=\underbrace{\begin{bmatrix}1&2\\0&1\\2&0\end{bmatrix}}_{X_AW_A} +\underbrace{\begin{bmatrix}3&3\\0&0\\1&1\end{bmatrix}}_{X_BW_B} =\begin{bmatrix}4&5\\0&1\\3&1\end{bmatrix}

Input columns and matching weight rows are color-coded. Two GPUs produce same-shaped outputs that are added elementwise.

Multiply inputs and weights of the same color. The first rows of the two products are (1,2)(1,2) and (3,3)(3,3). Drawn for this example.111

This time the full result requires elementwise addition. For the first token, A computes (1,2)(1,2) and B computes (3,3)(3,3). If both need the complete output after local multiplication, use an all-reduce: corresponding positions are added across the group and both receive (4,5)(4,5). With an even row split of WW, the GPUs each perform half the dind_{\mathrm{in}} multiply-adds for each neuron, and each partial result has nn rows and hh columns.

If GeLU follows, the first neuron needs GeLU(1+3)\mathrm{GeLU}(1+3). A's 11 and B's 33 are only partial sums. Activating each separately and then adding gives a different result. Finish the sum before GeLU.111

Column split followed by row split: no activation communication between layers

Follow the first token, (1,2,3,4)(1,2,3,4). Both GPUs hold this input. The first layer is split by column: A uses the first weight column to compute 1+3=41+3=4, B uses the second to compute 2+3=52+3=5. Write a=GeLU(4)a=\mathrm{GeLU}(4) and b=GeLU(5)b=\mathrm{GeLU}(5). Choose W(2)=[2βˆ’113]W^{(2)}=\begin{bmatrix}2&-1\\1&3\end{bmatrix} as the second layer's weights, split by row. A holds row (2,βˆ’1)(2,-1) and already has the input aa it needs. B holds row (1,3)(1,3) and already has bb. This is the Megatron 1D tensor-parallel layout used for the feedforward network (MLP) in BLOOM training: first layer by column, second by row.112

The input row (1,2,3,4) is dotted with each first-layer weight column to yield 4 and 5. Each GPU applies GeLU locally and multiplies by its matching second-layer weight row. Finally, add elementwise across GPUs.

Both upper dot products use the entire input row. A sums its local products to 4, applies GeLU to get aa, then multiplies by the teal weight row below. Only the plus sign between the two lower vectors requires inter-GPU communication. Diagram based on Megatron's layout.1

Follow only the first output of the second layer to locate the communication. A calculates 2a2a, B calculates bb, and only after the second multiplication do they need to add these to get 2a+b2a+b. The second output, βˆ’a+3b-a+3b, completes in the same all-reduce. If the second layer were column-split too, the GPU with weight column (2,1)⊀(2,1)^\top would need to compute 2a+b2a+b itself, requiring the missing activation bb from its peer before multiplication.

The table counts only communication within the tensor-parallel group for these two layers. With Megatron's layout both GPUs have the full input at the start of forward and the complete output gradient at the start of backward. Read forward from layer one to two and backward from two to one.12

Weight splitForwardBackward
First layer by columnEach GPU finishes its output columns, applies GeLU locally, and passes them directly to the second layer.Each computes local weight gradients from its column's gradients. Both outputs used the same input, so before returning to the preceding layer an all-reduce sums both GPUs' gradient contributions for each input position.
Second layer by rowEach multiplies local activations by local weight rows. Afterward an all-reduce combines partial sums before supplying the complete output to the next operator.Each uses the full output gradient and its local weight rows to compute the gradient for its assigned input features. These pass locally back through GeLU, and each GPU can compute its own weight gradients.

Thus this pair needs one forward all-reduce after the second multiplication, and one backward all-reduce before the first layer returns its input gradient.1

πŸ““ Noteγ€€Why is column then row still 1D? The first layer splits by output neuron and the second by input feature. Each splits its weights in just one direction. The next section's 2D SUMMA splits a single layer simultaneously by token and output neuron, assigning each GPU an output block.23

How much memory does 1D tensor parallelism save per GPU?

Suppose a forward microbatch has BB equal-length sequences of length SS, giving the linear layer T=BST=BS tokens. For a dense padded batch, include the padding positions actually computed. The model sets input width HH and output width EE. Thus XX has shape TΓ—HT\times H, WW has shape HΓ—EH\times E, and YY has shape TΓ—ET\times E. The size of this multiplication depends jointly on T,H,ET,H,E. For a fixed model, doubling the tokens doubles input and output while all tokens still share the same weights.

Suppose there are PP GPUs, and each input, weight, and output element takes bb bytes. All dimensions divide evenly, and input is already laid out as this layer requires. Counting only the three local multiplication tensors gives the following per GPU.2

Bytes per GPUInput XXWeights WWLocal product
Full layer on one GPUbTHbTHbHEbHEbTEbTE
Column-split weightsbTHbTHbHE/PbHE/PbTE/PbTE/P, output shard
Row-split weightsbTH/PbTH/PbHE/PbHE/PbTEbTE, partial output sums

Both splits reduce resident weights per GPU to 1/P1/P of the full layer. If each updates its own shard, its weight gradients and optimizer states are divided in the same proportion.

πŸ““ Noteγ€€The Colossal-AI 2D tutorial says β€œ1DεΌ ι‡εΉΆθ‘Œζ²‘ζœ‰ε―Ή activations θΏ›θ‘Œεˆ’εˆ†β€ (β€œ1D tensor parallelism does not partition activations”). In the column-split layer above, input still takes bTHbTH, but output has fallen to bTE/PbTE/P, and GeLU can operate on that shard. The tutorial summarizes activation memory as O(1)O(1) because each GPU still holds a full input growing with TT and HH as GPU count increases.32

2D: why does a square of four GPUs need two rounds?

To work equal-sized blocks by hand on four GPUs, add a token row below XX from the 1D example and two output weight columns to the right of WW. Now XX and WW are both 4Γ—44\times4, while the first two outputs for the first three tokens remain as before.

X=[1234010120101100],W=[1020010211000011]X=\begin{bmatrix} 1&2&3&4\\ 0&1&0&1\\ 2&0&1&0\\ 1&1&0&0 \end{bmatrix}, \qquad W=\begin{bmatrix} 1&0&2&0\\ 0&1&0&2\\ 1&1&0&0\\ 0&0&1&1 \end{bmatrix}

Arrange four GPUs in two rows and two columns. Split XX and WW horizontally and vertically into four 2Γ—22\times2 submatrices each. Indices start at zero. Each GPU begins with one input and one weight block and is responsible for the output block in the corresponding position. To calculate YijY_{ij}, walk block row ii of XX and block column jj of WW, multiplying two block pairs in turn and adding the products locally:

Round one uses the upper-left blocks of X and W. Round two uses upper-right X and lower-left W. Both contribute to the upper-left block of Y.

Follow only the first number in Y00Y_{00}. Each round multiplies a block pair. The upper-left GPU records 1, then adds 3. Diagram drawn for the SUMMA example.3

GPU and output blockFirst-round productSecond-round productLocally summed output
Upper left Y00Y_{00}X00W00X_{00}W_{00}X01W10X_{01}W_{10}[4501]\begin{bmatrix}4&5\\0&1\end{bmatrix}
Upper right Y01Y_{01}X00W01X_{00}W_{01}X01W11X_{01}W_{11}[6813]\begin{bmatrix}6&8\\1&3\end{bmatrix}
Lower left Y10Y_{10}X10W00X_{10}W_{00}X11W10X_{11}W_{10}[3111]\begin{bmatrix}3&1\\1&1\end{bmatrix}
Lower right Y11Y_{11}X10W01X_{10}W_{01}X11W11X_{11}W_{11}[4022]\begin{bmatrix}4&0\\2&2\end{bmatrix}

In round one, X00X_{00} is needed by both upper GPUs because it affects both upper outputs. Similarly, W00W_{00} goes to both left GPUs because both input groups multiply it. Broadcast input blocks along rows and weight blocks down columns. In round two switch blocks: the upper-left GPU receives X01X_{01} from the right and W10W_{10} from below, then adds this round's product to its result. Check the numbers: the upper-left output block's first row starts at (1,2)(1,2) and adds (3,3)(3,3), giving the 1D example's (4,5)(4,5).

The lower-right GPU also participates in round one, using X10X_{10} from its row and W01W_{01} from its column. This algorithm broadcasts along device rows and columns and accumulates local products over rounds. It is called SUMMA and applies to dense multiplications that permit this blocking.3

Animated four-GPU 2D SUMMA: input blocks broadcast along rows and weights along columns. All four GPUs multiply and accumulate, then switch broadcast sources for round two.

Follow GPU A at upper left. In round one it sends blocks it already holds to neighbors and obtains the first upper-left contribution, 1, using X00W00X_{00}W_{00}. In round two it receives X01X_{01} from the right and W10W_{10} from below and adds 3. The four boxes remain the same GPUs. Open the animation for step-by-step playback. Drawn for this four-GPU SUMMA example.3

πŸ““ Noteγ€€How many blocks are transmitted in two rounds? Each round broadcasts one input in each of two rows and one weight in each of two columns. With only two GPUs in each group, each broadcast sends exactly one block to its peer. The four GPUs send four blocks per round, totaling four input and four weight blocks. A remote activation block participates in the local multiplication; its temporary copy can be freed after the round.

Now count computation: four GPUs each perform one block multiplication per round, eight in total. Both products for an output block are computed on the same GPU, so each GPU needs one local block addition. All four can add concurrently, with zero extra cross-GPU communication.3

πŸ““ Note Take one token, eight input features, and four outputs. x is 1Γ—8, so in the mathematical expression xW the weight matrix must be 8Γ—4. PyTorch stores Linear.weight as 4Γ—8 and transposes it for the multiplication. Split the input evenly into a,b and split the weight matrix along both axes into four 4Γ—2 blocks. The two outputs on the left are aWβ‚€β‚€ + bW₁₀, and the two on the right are aW₀₁ + bW₁₁. Each addition supplies the four missing terms for the same output. Concatenate the left and right results only if the next operation needs all four values. Partitioning and communication play different roles here. Alternating column and row splits across adjacent layers determines which GPU holds the data. Ring communication determines which neighbors it passes through.72

Different layers may have shapes such as 8Γ—4 and 4Γ—7. In an ordinary dense layer each column has a weight for every input feature, so its columns have equal length. Different layers need not be padded to a common width. With seven outputs on two GPUs, an implementation supporting uneven shards can take four columns and three. Evenly split linear layers such as Megatron Core's first check divisibility. You could choose another axis or adjust the parallel group. If padding one extra column, ensure downstream computation ignores it, especially during normalization over output classes.713

Communication glossary: shards or partial sums, and who gets the result?

In SUMMA, sending along rows or columns is a broadcast. GPUs participating in an operation form a communication group. A broadcast along the first row involves only the upper-left and upper-right GPUs, so β€œthe whole group” can mean just two GPUs. Each member's number in the group is its rank. Some operations designate one sender or receiver of results called the root.

Here are common collectives on two GPUs, A and B. Each row is an independent operation, with A as root where one is required. Reduction combines corresponding positions across GPUs using a specified operation. The examples use summation; maximum is another possibility.14

TermOperationTwo-GPU example
broadcastRoot sends the same data to the whole group.A has [4,5] β†’ A and B both get [4,5]
scatterRoot partitions its data, giving each member one shard.A has [4,5] β†’ A gets [4], B gets [5]
gatherRoot collects every shard in rank order.A has [4], B has [5] β†’ A gets the complete [4,5]
all-gatherEach member collects every shard in rank order.A has [4], B has [5] β†’ both get [4,5]
reduceSum elementwise and deliver the result to root.A has [1,2], B has [3,3] β†’ A gets [4,5]
all-reduceSum elementwise and deliver the full result to every member.Same two inputs β†’ both get [4,5]
reduce-scatterSum elementwise, giving each member one shard of the result.Same two inputs β†’ A gets [4], B gets [5]
all-to-allEach member partitions data by destination and receives one shard from each source.A has [1,2], B has [3,4] β†’ A gets [1,3], B gets [2,4]

Another common term is send / recv, a form of point-to-point (P2P) communication. For instance, one pipeline stage sends its activations to the next, which calls recv.15

πŸ““ Noteγ€€Return to the first token. If A holds the first neuron's output [4] and B holds the second's output [5], use all-gather for both to see the complete output. If each GPU computed only half the input features, they hold partial sums [1,2] and [3,3] instead. Use all-reduce if both need both outputs next, or reduce-scatter if each needs one. A subsequent all-gather after reduce-scatter gives both [4,5] too.14

Still using four GPUs, when must we sum across devices?

Track just the first entry of the upper-left output block. Input is (1,2,3,4)(1,2,3,4), weights (1,0,1,0)(1,0,1,0). The first two features contribute 11 and the last two 33. Both 2D implementations obtain 44. The difference is: which GPU holds 11 and which holds 33 when they are computed?316

Forward stage2D SUMMA in Colossal-AI's tutorial2D MatMul in the MindSpore 2.4 tutorial
Before local multiplicationRound one broadcasts inputs along rows and weights along columns, giving the upper-left GPU everything for the first two features.First all-gather within group y. Each GPU gets the input required for this multiplication, while weights stay blocked.
While calculating partial sumsThe upper-left GPU computes and keeps 11. Round two supplies data for the remaining features. The same upper-left GPU computes 33 and adds it to its stored 11.Different GPUs compute the two contributions to the same output. One holds 11, another 33. Their local multiplication is complete.
Handing off to the next stepThe upper-left GPU already has 44 and can pass it on as part of its output block. This multiplication is complete.Perform reduce-scatter in group x, summing contributions at each position and distributing finished positions among GPUs. The GPU responsible for this position receives 44.

Here reduce means reduction across GPUs, specifically addition. SUMMA communicates every round, sending inputs and weights needed for the next multiplication; its two products accumulate locally. MindSpore moves some communication after multiplication and transmits partial sums. Before applying GeLU to complete outputs, reduce those sums. In contrast, with 1D column splitting, each GPU has finished its assigned outputs, so it can apply GeLU locally even without assembling both sets of columns.1316

πŸ““ Noteγ€€Group size, direct peers, bytes per multiply, and rounds of waiting are different quantities. In a ring all-reduce across ten thousand GPUs, each GPU can pass chunks to its next neighbor over successive rounds. In a 100Γ—100100\times100 square each GPU has 99 other members in its row and 99 in its column. These counts describe grouping; the broadcast algorithm determines actual routes.23

How many bytes does each 2D layout transmit for the same forward multiplication?

Notation for communication volume

SymbolMeaning in this multiplicationUnits
TTTokens processed together in this forward pass, or input rowsTokens
HHFeatures entering this layer per token, or input widthInput features/token
EEFeatures produced per token, or output widthOutput features/token
bbBytes per communicated tensor element, assuming identical precisionBytes/element
qqGPUs per row of the square device mesh, also GPUs per columnGPUs
PPTotal GPUs participating in tensor parallelism; for the square, P=q2P=q^2GPUs

One forward pass computes XW=YXW=Y. Input XX has THTH elements (tokens Γ— input width), weights WW have HEHE elements (input width Γ— output width), and output YY has TETE elements (tokens Γ— output width).

Count only bytes each GPU receives from other GPUs. Consider SUMMA's input. Each evenly divided block has TH/PTH/P elements. Each GPU uses qq blocks of the same block row, already has one, and must receive qβˆ’1q-1 blocks. The incoming volume is (qβˆ’1)Γ—(TH/P)Γ—b(q-1)\times(TH/P)\times b bytes. The analogous weight broadcast runs down device columns. MindSpore's square first gathers input within each group, then combines output partial sums with a ring reduce-scatter.316

Incoming bytes per GPUSUMMAMindSpore 2D
Inputb(qβˆ’1)TH/Pb(q-1)TH/Pb(qβˆ’1)TH/Pb(q-1)TH/P
Weights or partial output sumsb(qβˆ’1)HE/Pb(q-1)HE/P, weight blocksb(qβˆ’1)TE/Pb(q-1)TE/P, output partial sums

Both transmit the same input volume. If T>HT>H, sending weight blocks costs less than sending output partial sums. If T<HT<H, the opposite holds. This threshold assumes the square mesh and precision above. Runtime also depends on whether SUMMA's staged broadcasts overlap multiplication and how effectively the local matrix shapes use the hardware.316

Does 2D always use less forward memory than a 1D row split?

With in-place reduction in the output buffer, a 1D row split simultaneously holds b(TH/P+HE/P+TE)b(TH/P+HE/P+TE) bytes of input, weights, and partial sums. For 2D SUMMA suppose each GPU holds rXr_X input blocks and rWr_W weight blocks at a given time, including original shards and live broadcast/prefetch copies. Each GPU accumulates in one output block. The three categories total b(rXTH+rWHE+TE)/Pb(r_XTH+r_WHE+TE)/P bytes. Prefetching and buffer reuse affect rX,rWr_X,r_W.2317

Subtract the expressions to see the tradeoff. If (Pβˆ’1)TE>(rXβˆ’1)TH+(rWβˆ’1)HE(P-1)TE>(r_X-1)TH+(r_W-1)HE, the space saved on 2D's smaller output exceeds the extra input and weight blocks. Keep the token count TT in this comparison: with fixed layer widths, increasing sequence length or microbatch size changes activation memory, while weight block size stays fixed.

For two large feedforward layers, what else contributes to peak memory?

Consider two layers of shape H→E→HH\to E\to H, ignoring bias. Suppose the weight, gradient, master weight, and optimizer state together occupy mm bytes per parameter. The layers have 2HE2HE parameters. If weights and update state are divided evenly among PP GPUs, each GPU needs 2mHE/P2mHE/P bytes for model state in either 1D or 2D. mm varies with precision and optimizer configuration. If ZeRO also shards states across the data-parallel group, calculate each component for the relevant stage. Mixed-precision Adam breakdown in the earlier article

In a classic column-then-row 1D layout, the first layer's complete input and local output total bT(H+E/P)bT(H+E/P) bytes. The second layer's local input and partial output sums also occupy bT(E/P+H)bT(E/P+H) bytes. If the first input is saved for backward, add bTHbTH while processing the second layer. If 2D retains only evenly split original inputs, this term is bTH/PbTH/P per GPU, saving bTH(1βˆ’1/P)bTH(1-1/P) bytes. To find training peak memory, follow execution order, sum simultaneously live tensors, and take the maximum. Include activations kept by other layers, GeLU's backward inputs, and communication buffers. Recomputation changes which activations need retaining.1310

For the same layer pair, MindSpore's model of the two forward multiplications gives 2bT(Pβˆ’1)H/P2bT(P-1)H/P bytes per GPU for classic 1D and 2bT[E(xβˆ’1)+H(yβˆ’1)]/P2bT[E(x-1)+H(y-1)]/P bytes for 2D on P=xyP=xy GPUs. With fixed widths and layouts, increasing TT scales both communication volumes proportionately. Which transmits less depends on layer widths and layout together.16

2.5D and 3D: with the same eight GPUs, what does the third direction do?

The 3D tensor parallelism here splits along three natural directions of a matrix product: which tokens, which output neurons, and which input-feature segment of each dot product. The first two identify an output block. The third assigns segments of its dot products to different GPUs, which compute contributions and add them elementwise. 2D SUMMA also segments the dot products, but the GPU responsible for an output block computes every segment over successive rounds.35

Left to right: 1D divides into two columns, 2D into four squares, 2.5D adds dashed depth behind the plane, and 3D shows a solid cube.

The four layouts side by side in HPC-AI Tech's Colossal-AI overview. Both 2.5D and 3D have depth. To understand how two GPUs along that direction cooperate, check what each computes.18

Arrange eight GPUs in two square planes, four per plane. Both Colossal-AI layouts can be drawn this way. To tell them apart, ask whether the planes compute outputs for different tokens or different contributions to the same output.45

Still computing Y=XWY=XWEight-GPU 2.5D exampleEight-GPU 3D example
What do the planes store?The upper plane gets the first two rows of X, the lower the remaining two. Each plane splits its own input further and stores a copy of all four weight blocks.Inputs and weights are split more finely among eight GPUs. Data for one output block is distributed across groups in different directions.
How is the output obtained?Each plane runs independent 2D multiplication on its four-GPU square. The upper plane produces the first two rows of Y, the lower produces the rest.Gather necessary input and weight blocks along two directions, multiply locally, then sum partial outputs along the third direction, leaving each GPU a final output shard.
What does the extra direction do?Replicas of a weight block at different depths can process different input rows close to the data. Extra weight storage trades for less communication.It also combines results. Weights can be divided among more GPUs, but one multiplication requires coordinating three communication directions.

Track the first output 4=1+34=1+3 in row one. In 2.5D the plane holding that input row completes 44 itself. The other plane handles different tokens. In 3D, two GPUs compute 11 and 33 separately. If GeLU follows, they must first add across GPUs because activation requires GeLU(1+3)\mathrm{GeLU}(1+3).45

Six-step 3D tensor-parallel animation. Packets move along horizontal and vertical edges, target GPUs light up for local multiplication, and partial sums move along depth before local addition and activation.

Watch the front and rear GPUs at the upper right. Moving packets indicate transfers and gold halos indicate local computation. Track two positions during reduction: the front GPU keeps the first token's first output, 4, and the rear keeps the second token's second output, 1. Open the image to pause or step through. Drawn for Colossal-AI's 3D forward layout.5

During training, distinguish reducing outputs from reducing gradients. In the 2.5D forward example, the two device planes run SUMMA on different input rows. Their outputs can be assembled by row. During backward, both used the same weight blocks, so each obtains only its rows' contributions to the weight gradients. Combine the two gradients across planes before updating the block. The 3D example needs reduction sooner: while computing one forward multiplication, different depths produce partial sums for the same output position. Reduce-scatter along depth yields the correct output shards.4519

β€œ2.5” denotes an adjustable layered scheme. Write the device count as q Γ— q Γ— d, with a q Γ— q square per plane and d planes in depth. Setting d = 1 returns to a single 2D plane. Increasing depth can change each plane's size, the number of weight replicas, and per-GPU communication. Even at q = d = 2, if each plane independently performs 2D multiplication with a weight copy, it is still the left-hand scheme in the table.4

Deriving an algorithm and enabling it in a particular software release are separate questions. Colossal-AI's 2.5D tutorial, for instance, distinguishes the legacy example from a Shardformer interface still awaiting integration in its β€œUsage” section. Check installed versions and APIs for support in a training environment. Production adoption requires deployment data.4

With 16 GPUs, how different are one 4Γ—4 square and four 2Γ—2 squares?

Give input, weights, and output shape 16Γ—16, with two bytes per element. Consider only one forward SUMMA multiplication, with each GPU accumulating its output in place. The four smaller squares each own four different tokens and need all weights. As before, count only useful data a GPU receives from its peers.34

What each GPU holds or receives2D, one 4Γ—4 square2.5D, four 2Γ—2 squares
Resident input block / final output block4Γ—4 each, 32 bytes each2Γ—8 each, 32 bytes each
Resident weight block4Γ—4, 32 bytes8Γ—8, 128 bytes
Missing input for this multiplication3 more blocks, 96 bytes1 more block, 32 bytes
Missing weights for this multiplication3 more blocks, 96 bytes1 more block, 128 bytes
Total received per GPU in forward192 bytes160 bytes

For fixed GPU count, resident input per GPU is the same. The tutorial's intuition of β€œsame parameters, fewer activations” uses a different comparison: hold the side length of each square fixed and add device planes. Each plane retains the same weights and each GPU gets fewer input rows. Here we rearrange the same 16 GPUs into four planes. Each GPU stores 96 extra weight bytes and receives 32 fewer bytes per forward. The planes compute different tokens, so no cross-plane addition is required in forward. If a caller needs the full output, both layouts must deliver their shards. Training requires adding gradients for the same weight block across the four planes.419

3D moves reductions onto different coordinate axes. To track numbers on a specific GPU, see how eight GPUs calculate and redistribute input and weight gradients.

Does the extra 3D reduction before activation increase total forward traffic?

After a 3D reduction, each GPU keeps its own output shard, avoiding a full-result broadcast to everyone. Whether the entire forward pass transmits more than 2D SUMMA depends on whether input and weight savings before multiplication offset the additional reduction.

First look between multiplication and GeLU. In 2D SUMMA one GPU computes 11 and 33 in two rounds and adds locally. In Colossal-AI's 3D scheme the contributions reside on different GPUs, so multiplication is followed by reduce-scatter. MindSpore's 2D MatMul already uses reduce-scatter afterward, so both have this step in that comparison.3516

Reduce-scatter completes each output position's sum. The GPU responsible receives 44 and can calculate GeLU(4)\mathrm{GeLU}(4) locally, while its peers handle their own positions. All-reduce would give everyone the results for every position. Standard ring all-reduce follows reduce-scatter with all-gather. For elementwise GeLU that final gathering can be omitted.14

Now consider the inputs and weights delivered to multiplication. Fix matrix shapes and total GPU count P>1P>1 and compare two evenly divisible layouts. 2D SUMMA has qq GPUs per side of its square, while 3D has rr per side of its cube; take P=q2=r3P=q^2=r^3. Both initially partition inputs and weights into PP blocks each. For a given tensor, initial blocks have equal element counts across plans. What changes is how many GPUs need each block.35

Where one initial block goes2D SUMMAColossal-AI 3D
Input blockBroadcast to the other qβˆ’1q-1 GPUs in its rowDelivered to the other rβˆ’1r-1 GPUs in its input gather group
Weight blockBroadcast to the other qβˆ’1q-1 GPUs in its columnDelivered to the other rβˆ’1r-1 GPUs in its weight gather group

Since r<qr<q, both operands move less in 3D. Let TT denote tokens, H,EH,E the input and output widths respectively, and bb bytes per transmitted element. Counting only useful payload received per GPU in one forward pass, 3D saves b(qβˆ’r)(TH+HE)/Pb(q-r)(TH+HE)/P bytes on operands. However, its ring reduce-scatter requires each GPU to receive another rβˆ’1r-1 output shard equivalents, totaling b(rβˆ’1)TE/Pb(r-1)TE/P bytes. If the former exceeds the latter, 3D moves less overall; if equal, they tie. The same dependency can be met by sending operands to the output owner or by multiplying locally first and sending partial sums.3514

Does the conclusion hold for another 2D layout?

Introducing 2.5D and 3D, Zhou Boyang wrote, β€œζ―ε‡δΈ€δΈͺη»΄εΊ¦οΌŒι€šδΏ‘δ»£εΏιƒ½δΌšεΎ—εˆ°θΏ›δΈ€ζ­₯ηš„δΈ‹ι™β€ (β€œeach added dimension further reduces the communication overhead”). β€œEach” is too categorical. In MindSpore's implementation, moving from 2D to 3D can transmit fewer activations but more weights. The larger term depends on how many tokens in the batch share those weights.1116

Fix the GPU count P=xyzP=xyz and consider a pair of Hβ†’Eβ†’HH\to E\to H feedforward layers. Replace MindSpore's 2D layout (x,yz)(x,yz) with 3D layout (x,y,z)(x,y,z), where z>1z>1. From the documented two-layer forward formulas, 2D communicates 2bT[E(xβˆ’1)+H(yzβˆ’1)]/P2bT[E(x-1)+H(yz-1)]/P bytes per GPU, 3D 2b[TE(xβˆ’1)+TH(yβˆ’1)+HE(zβˆ’1)]/P2b[TE(x-1)+TH(y-1)+HE(z-1)]/P bytes. Subtracting activation savings from extra weight traffic, the change per GPU is

C3Dβˆ’C2D=2bH(zβˆ’1)P(Eβˆ’Ty).C_{\mathrm{3D}}-C_{\mathrm{2D}}=\frac{2bH(z-1)}{P}(E-Ty).

For these layouts, 3D saves communication when T>E/yT>E/y, and 2D saves it when T<E/yT<E/y. More tokens in one forward pass amortize the weight gather. With fixed TT, widening the intermediate layer EE can cross the threshold again. Increasing only the training corpus's token count while keeping the microbatch shape fixed repeats the original cost per forward. Redistributing GPUs among different axes can change elements transmitted per token, requiring a new comparison.16

Why are there only three natural directions in ordinary matrix multiplication? What can 4D and 5D mean?

Consider one output of the linear layer Y=XWY=XW. There are TT tokens, HH input features, and EE output neurons. To compute output neuron jj for token ii, dot row ii of XX with column jj of WW:

Yij=βˆ‘k=1HXikWkj.Y_{ij}=\sum_{k=1}^{H}X_{ik}W_{kj}.

Choosing (i,j,k)(i,j,k) uniquely determines which two values are multiplied and which output receives their product. For this ordinary dense multiplication there is no fourth or fifth independent computation index. Here are the three directions:

Index dividedWhere the matrix is cutResult computed by each group
ii: which of TT tokensGroup rows of XXDifferent rows of YY
jj: which of EE output neuronsGroup columns of WWDifferent columns of YY
kk: which segment of a dot product with HH termsGroup columns of XX with corresponding rows of WWPartial sums for the same output position, which must be combined

A 1D row split already uses kk: every GPU has every token, but only a segment of each row's features. 2D SUMMA uses device rows and columns for ii and jj respectively. In a qΓ—qq\times q square each GPU handles T/qT/q tokens and E/qE/q output neurons. Y00Y_{00} is usually a whole block containing many output values.23

If output blocks can be split further, why split the dot product?

Suppose two GPUs share an output block previously assigned to one. Cut along ii and each takes some tokens, both needing the original weights. Cut along jj and each takes some neurons, both needing the original inputs. Cut along kk and each takes a segment of inputs and matching weights, combining partial sums only after multiplication. Even before i,ji,j is down to a single output, changing the division may be worthwhile: for long dot products and small output blocks, transmitting partial sums may cost less than transmitting inputs or weights.

Revisit 4=1+34=1+3. In 2D SUMMA, one GPU computes 11 and 33 over two rounds and adds them locally. Colossal-AI's 3D approach gives two GPUs different segments of kk. One contributes 11, the other 33, and adding across GPUs gives the same output 44 for the same token and neuron.35

Can four or five coordinates describe the same work?

Any axis in i,j,ki,j,k can be subdivided. Write token index ii as β€œtoken group, position within group” and a product has four coordinates. Also split jj into β€œneuron group, position within group” to get five. The first pair still selects a row of XX, the second pair selects a column of WW, and the last index kk identifies the input feature used in the product. Device communication can be organized hierarchically the same way. HSUMMA adds inter-group and intra-group broadcasts within a 2D device square.20

Fix a token ii and output neuron jj, focusing on the GPUs that compute YijY_{ij}. Four GPUs arranged in a 2Γ—22\times2 plane have two within-group axes: horizontal pairs in rows and vertical pairs in columns. Arrange four such planes for two tokens and two neurons, and the mesh has four axes (i,j,g,s)(i,j,g,s), totaling 16 GPUs. For a third within-group axis, expand each group into a 2Γ—2Γ—22\times2\times2 cube of eight GPUs. The full mesh now has five dimensions and 32 GPUs. These are the smallest examples with two positions per axis.

Both animations compute the same output matrix. The upper-left circular group A and upper-right square group B handle the first token. Lower-left hexagonal C and lower-right diamond-shaped D handle the second. Moving horizontally between groups changes the output neuron.

Start from the preceding layer's output. Suppose an intermediate layer computes Y=XWY=XW. The previous layer has produced 16 features each for two tokens, so XX has shape 2Γ—162\times16 and the current layer's weights WW have shape 16Γ—216\times2. Divide the 16 features into eight dot-product segments of two terms. Choose an even layout: the two input values for a token are split between groups in one row, and the two weight values for a neuron between groups in one column. For each segment, each group already has one input and one weight. Each GPU covers two segments in the 4D diagram and one in 5D. Inputs come from the preceding layer, while weights are the current layer's own parameters.

For segment one, the four corresponding GPUs hold the numbers below. The two GPUs in each row together have the two input values for one token, and the two GPUs in each column have the two weights for one neuron.

Output neuron 0Output neuron 1
Token 0A: input 1, weight 3B: input 2, weight 6
Token 1C: input 3, weight βˆ’1D: input 6, weight βˆ’2

Follow D, which must compute (3,6)β‹…(6,βˆ’2)(3,6)\cdot(6,-2). It already has both numbers for the second term and could begin with 6Γ—(βˆ’2)6\times(-2), but lacks input 3 and weight 6 for the first term. The animation gathers first. D exchanges inputs horizontally with C, sending its 6 and receiving 3. It exchanges weights vertically with B, sending βˆ’2 and receiving 6. D can now compute the local sum 3Γ—6+6Γ—(βˆ’2)=63\times6+6\times(-2)=6. The other seven segments use the same layout. Segment rr scales the first segment's inputs by rr with unchanged weights, giving D eight contributions 6,12,…,486,12,\ldots,48.

If two GPUs need one value, how many transfers are required? Both C and D need input 3. If inputs start in external storage and each GPU can read just its required shard, C and D can each read it once, for two storage reads. Alternatively, C can read it once and send it to D, for one storage read and one inter-GPU transfer. Both routes deliver 3 to both GPUs. Compare costs by identifying the links traversed and bytes sent on each.

This diagram counts from an intermediate layer: the previous layer already produced 3 on C, so it shows only C sending it to D. If the previous activations and this layer's weights are already aligned for each GPU's features, local multiplication can begin immediately. Whether communication follows depends on which GPUs hold partial sums for the same output.

4D diagram: each output group uses a four-GPU plane. The horizontal coordinate is ss and the vertical is gg. Of eight dot-product segments, each GPU handles two. Group A's upper-left GPU, for example, takes segments 1 and 5 and locally obtains 1+5=61+5=6. Upper-right, lower-left, and lower-right obtain 8, 10, and 12. Now follow the two plane axes.

4D communication: each of four output groups has a four-GPU plane. After exchanging inputs and weights between groups, each GPU computes two segments, then sums horizontally along s and vertically along g.

In A, simultaneously compute 6+8=146+8=14 and 10+12=2210+12=22 along ss, then combine 14+22=3614+22=36 along gg. Open the animation to step through. Intergroup exchange tracks only segment one. Diagram designed for this article.

5D diagram: each output group uses an eight-GPU cube. With the same eight segments, each GPU computes one. Left/right tt, up/down hh, and front/back gg provide three within-group axes, giving full coordinates (i,j,g,h,t)(i,j,g,h,t).

5D communication: four groups share inputs and weights along j and i. After local multiplication each group sums along t, h, and g.

In A again, the rear four GPUs compute 5+6=115+6=11 and 7+8=157+8=15 along tt, then combine to 26 along hh. Finally send forward along gg and combine with 10 from the front plane to obtain 36. Diagram designed for this article.

How many GPUs does a mesh with dd independent axes need? In a regular full mesh each axis has at least two positions, so dd dimensions need at least 2d2^d GPUs. The minima for 1D through 5D are 2, 4, 8, 16, and 32. To add depth to a four-GPU plane, each front position needs a corresponding GPU behind it, giving a cube of eight. Re-pairing the original four creates new communication groups but leaves only the original four device positions.

Conversely, how many dimensions can PP GPUs occupy? For axis lengths n1,…,ndn_1,\ldots,n_d, we have P=n1β‹―ndP=n_1\cdots n_d and hence dβ‰€βŒŠlog⁑2PβŒ‹d\le\lfloor\log_2 P\rfloor. To use every GPU exactly once, the exact maximum is the number of prime factors of PP, counting multiplicity, since each can supply one axis length. Broadcasting and reducing repeatedly in the same group doesn't change mesh dimensionality.

Whether grouping saves communication depends on ownership and routes. Suppose a token's HH activations are evenly split over PP GPUs. If every GPU needs the complete input for the next layer, each lacks Hβˆ’H/PH-H/P values. Hierarchical gathering doesn't eliminate that deficit. If the next weight rows already align with local activations, multiply locally and reduce outputs afterward. With a β€œ4D” or β€œ5D” description, ask what a new coordinate indexes: subdivisions of an existing index, a hierarchy of device communication, or a different division of labor in training.141

πŸ““ Noteγ€€What does D count in β€œ2D” or β€œ3D”? Zhou Boyang's fourth lesson on distributed LLM training gives β€œTP+PPοΌŒζˆ–θ€…TP+DDP” (β€œTP+PP, or TP+DDP”). Here 2D counts two training strategies: tensor parallelism paired with pipeline parallelism, or with distributed data parallelism that synchronizes training across replicas.11

HPC-AI Tech's 2021 Colossal-AI introduction called DeepSpeed and Megatron's 3D hybrid parallelism β€œdata parallelism, pipeline parallelism, and 1D tensor parallelism.” Immediately afterward, it listed 2D, 2.5D, and 3D tensor-parallel strategies in Colossal-AI. The first counts strategies for an entire training run. The second counts how within-layer computation is split.18

BLOOM splits examples using data parallelism and successive layers using pipeline parallelism, while employing Megatron-style 1D tensor parallelism inside layers. Its first feedforward layer is column-split, its second row-split, both across the same group of devices. This article's 3D tensor parallelism divides tokens ii, output neurons jj, and dot-product sum positions kk across GPUs within one layer multiplication.125 Revisit the roles of BLOOM's 384 GPUs

DeepSpeed's 32-GPU hybrid example: two vertical levels represent data replicas, four horizontal columns are pipeline stages, and four devices arranged along depth jointly compute the same layer.

Redrawn from DeepSpeed's 32-GPU example. Each block is a GPU with its number on the front face. Four blocks of one color extend front to back, computing a single stage for one replica. The original labels depth Model Parallel; in this example it uses Megatron's tensor partitioning.21

Start at GPU 0. Behind it is 1: they process the same layer, stage, and sample batch, handling different shards. Below it is 4, which handles the same layers and shards but reads another sample batch. ZeRO can share optimizer states between these data-parallel partners. To the right is 8, the next network stage for the same replica. Now take a step along depth in the earlier 3D tensor-parallel cube: both GPUs still compute the same layer and output block, but handle different dot-product segments and must sum their contributions.215

Can algorithms automatically find the best combination of network partitions?

An algorithm can select partitions. For the two-layer feedforward network, column then row splitting lets activations stay local. Optimizing both layers independently may select each layer's fastest multiplication yet introduce an all-gather between them. Compare time to complete the same training step, including forward, backward, and parameter updates.122

How does automatic scheduling relate to partition selection? HPC-AI Tech's 2021 overview calls one feature Adaptive task scheduling: a scheduler can scale using factors such as batch size and migrate jobs through NCCL communication.18 If a job expands from eight GPUs to sixteen, what next? Add data-parallel replicas to process more samples simultaneously or spread the matrices in one layer over more GPUs? Scaling changes available resources; partitioning decides how they participate. Resource changes can trigger a new search. The choice requires comparing memory, communication, and full step time.

To follow code into an execution plan, see drawing a computation graph from two multiplications and costing two layouts operation by operation.

What does β€œfastest within budget” mean?

Fix the model, input shape and tokens per step, GPU count, and interconnect. Suppose there are two hard budgets: no GPU may exceed peak memory during the step, and total bytes sent across nodes cluster-wide must remain below a per-step limit, counted once at the sender. Exclude candidates exceeding either budget, then choose the remaining plan that finishes the step soonest.

πŸ““ Noteγ€€Bandwidth and communication volume have different units. Assume both layouts fit in memory. A sends 120 GB across nodes per step and takes 0.8 seconds. B sends 80 GB and takes 1 second. With a 100 GB cap, choose B. If only link bandwidth (GB/s) is specified and the step times already include communication waits, choose A. Extra data movement may overlap other computation.

Can the matrix shape alone determine the partition?

Start with Y=XWY=XW. Let pi,pj,pkp_i,p_j,p_k denote the numbers of groups along token, output neuron, and dot-product length. A regular mesh of PP GPUs with one per coordinate requires pipjpk=Pp_i p_j p_k=P. For evenly divisible dimensions, enumerate compatible integer combinations, specify broadcasts, reductions, and inter-layer handoffs for each, and compare costs. This is grid search. The axes with more than one group are the ones actually split; you needn't guess a best dimension count in advance.

The earlier formulas directly compare communication bytes for a forward pass in two specified layouts. To derive a blocking scheme for one product, COSMA starts from shape, processor count, and available memory, derives a lower bound on data movement, and constructs a parallel algorithm close to it. Optimizing a whole network's step time also requires each local multiplication's performance on the target GPUs and where the next layer needs its data.23

How can we estimate the cost of a training step?

Calculon models hardware costs. Its A100 configuration describes matrix throughput, memory capacity and bandwidth, and interconnects, with compute efficiency varying by operation size. Halving a matrix halves each GPU's work, but the smaller multiplication may achieve a lower fraction of peak throughput. Given a model and parallel configuration, Calculon estimates batch execution time, throughput, and memory, and compares multiple configurations.24

Proteus simulates dependencies and overlap. It expands a plan into per-GPU compute and transfer tasks, simulating dependencies and competing transfers on shared links. In the 3D reduce-scatter, GeLU waits for its local sums to complete, but another microbatch may already have multiplication ready. Step time depends on how far the reduction delays completion of the whole step. Proteus's authors tested three hardware configurations and reported 3.0% average error in training throughput prediction for the tested plans.25

How does the search handle network-wide combinations?

With a few candidates, a cost model can estimate each layout. As layer count rises, exhaustive tests of all combinations quickly become expensive. Automatic parallelization systems use dependencies between neighboring layers or pipeline structure to narrow the search.

SystemWhat the algorithm decidesHow the paper handles budgets and time
AlpaUses integer linear programming for operator partitions, including resharding between neighbors. Dynamic programming then chooses pipeline stages and assigns devices to them.Checks whether each stage fits per-GPU memory and compares candidate execution times including cross-device communication.22
GalvatronPrunes candidates, then uses dynamic programming to combine data, sharded data, and tensor parallelism per layer and compares pipeline stage counts.At a fixed batch size, seeks a fast plan under the device-memory budget, including communication time. The paper also searches batch size to optimize samples per second.26

Neither system separately budgets maximum cross-node bytes per step. If that limit exists, track sent bytes per candidate and reject even the estimated fastest plan if it exceeds the cap. With a finite candidate set and exact costs, a complete solver can find the fastest feasible plan, possibly with ties. Real systems prune and can only estimate GPU efficiency and communication overlap. Benchmark full steps with identical inputs on the target cluster to determine which top candidates are actually fastest.222625

How do Alpa's automatic plans compare with hand-tuned plans?

Start with the user's code. Alpa's quickstart uses JAX to write one training step: accept a batch, calculate prediction error, and update the weights. Add @alpa.parallelize to allow the same computation to run on multiple GPUs. The tutorial first compares updated weights with a single-GPU result, then compares step time and per-GPU memory. The tuning guide recommends trying plain data parallelism with a small model, splitting samples among GPUs. Its pipeline tutorial then demonstrates two ways to use one network: manually mark where the next GPU group takes over, or let Alpa choose stage boundaries and device assignments.2728

πŸ““ Noteγ€€JAX is a Python library for array computation. Here jax.grad automatically differentiates the error function to obtain each weight's gradient, telling us how the error changes with a small weight change. Alpa takes the training step containing these operations and schedules it across GPUs.27

Figure 7 of Alpa's paper reports hardware measurements. For both comparison systems the authors tried multiple parallel settings and kept each system's best. On the GPT-3 family, Alpa's automatically found plans matched tuned Megatron-LM v2 throughput. For mixture-of-experts models (MoE, where each token uses only some experts), they compared against DeepSpeed. Each machine had eight V100s connected by fast local links. The network between machines was much slower. Alpa kept frequently communicating computations together on a host where possible and placed groups of consecutive layers on different machines. For the GShard MoE models in the paper, Alpa achieved 3.5Γ— the throughput of the contemporary DeepSpeed configuration on two hosts and 9.7Γ— on four. Each ratio compares the same training task within that scale; the four-host model was larger than the two-host one.22

Once a partition is chosen, how do processes on different machines run their assigned stages? See how Ray distributes work during multi-GPU training.

Footnotes

  1. Shoeybi, M., et al. (2019). Megatron-LM: Training multi-billion parameter language models using model parallelism. arXiv. Section 3, figure 3, column and row partitions of consecutive layers ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13

  2. Bian, Z., & Li, Y. (n.d.). 1D tensor parallelism. Colossal-AI. Two-layer partition in β€œIntroduction,” ring communication and activation memory estimate in β€œEfficiency” ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10

  3. Bian, Z., & Li, Y. (n.d.). 2D tensor parallelism. Colossal-AI. Four-GPU blocking and two broadcast rounds in β€œIntroduction” ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 ↩16 ↩17 ↩18 ↩19 ↩20 ↩21

  4. Bian, Z., & Li, Y. (n.d.). 2.5D tensor parallelism. Colossal-AI. Layering and weight partition example in β€œIntroduction” ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8

  5. Bian, Z., & Li, Y. (n.d.). 3D tensor parallelism. Colossal-AI. Three-axis partitioning and reduction in β€œIntroduction” ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12

  6. Strang, G. (2016). Introduction to linear algebra (5th ed.). Wellesley-Cambridge Press. Section 1.3, β€œMatrices,” p. 23, equations (3)–(4) ↩

  7. PyTorch. (n.d.). Linear. PyTorch documentation. Forward formula, input/output shapes, and weight layout ↩ ↩2 ↩3 ↩4

  8. PyTorch. (n.d.). Tensor views. PyTorch documentation. Transposed views and contiguous storage ↩

  9. Kingma, D. P., & Ba, J. (2015). Adam: A method for stochastic optimization. ICLR. Section 2, first and second moments in Algorithm 1 ↩

  10. PyTorch. (n.d.). Autograd mechanics. PyTorch documentation. Saved tensors ↩ ↩2

  11. Zhou Boyang. (2024, March 23). Distributed LLM Training, Lesson Four: Tensor Model Parallelism. Zhihu. Discussion of GeLU after β€œColumn Parallelism,” opening of β€œ2D/2.5D and 3D Parallelism,” and paragraph after the 3D block matrix formula. Original article ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  12. Bekman, S. (2022, July 14). The technology behind BLOOM training. Hugging Face. Tensor Parallelism ↩ ↩2

  13. NVIDIA. (2025). Megatron Core tensor-parallel layers (core_v0.12.0). GitHub. Implementation dividing input width equally by GPU count. ↩

  14. NVIDIA. (n.d.). Collective operations. NCCL User Guide. Definitions and diagrams of the collectives ↩ ↩2 ↩3 ↩4 ↩5

  15. NVIDIA. (n.d.). Point-to-point communication. NCCL User Guide. Two-sided communication ↩

  16. MindSpore. (n.d.). Higher-dimensional tensor parallelism. MindSpore 2.4.0 documentation. Communication behavior in 2D tensor-parallel computation ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8

  17. Xu, Q., Li, S., Gong, C., & You, Y. (2021). An efficient 2D method for training super-large deep learning models. arXiv. Page 7, communication workspace and table 1 communication and computation costs ↩

  18. HPC-AI Tech. (2021, November 18). Colossal-AI: A unified deep learning system for large-scale parallel training. Medium. β€œMultiple parallelisms,” opening paragraph, sentences 1–2 Β· β€œMulti-dimensional model parallel” diagram Β· β€œAdaptive task scheduling” ↩ ↩2 ↩3

  19. Wang, B., Xu, Q., Bian, Z., & You, Y. (2021). Tesseract: Parallelize the tensor parallelism efficiently. arXiv. Figure 3 and synchronization between device planes ↩ ↩2

  20. Quintin, J.-N., Hasanov, K., & Lastovetsky, A. (2013). Hierarchical parallel matrix multiplication on large-scale distributed memory platforms. arXiv. Device grouping and two-level communication in hierarchical SUMMA ↩

  21. DeepSpeed Team, Majumder, R., & Wang, J. (2020, September 10). DeepSpeed: Extreme-scale model training for everyone. Microsoft Research. β€œ3D parallelism,” figures 1 and 2, grouping and device mapping for 32 GPUs ↩ ↩2

  22. Zheng, L., et al. (2022). Alpa: Automating inter- and intra-operator parallelism for distributed deep learning. OSDI 2022. Sections 4–5, operator layouts, pipeline search, and memory constraint in equation 5; section 8.1, experiment configuration, figure 7, and comparisons; appendix B, table 7, MoE model sizes for each GPU count. ↩ ↩2 ↩3 ↩4

  23. Kwasniewski, G., et al. (2019). Red-blue pebbling revisited: Near optimal parallel matrix-matrix multiplication. SC19. Communication lower bound and COSMA algorithm ↩

  24. Isaev, M., McDonald, N., Dennison, L., & Vuduc, R. (2023). Calculon: A methodology and tool for high-level codesign of systems and large language models. SC23. Hardware cost model, batch time and memory breakdown Β· A100 efficiency and bandwidth settings Β· Single estimates and configuration search examples ↩

  25. Duan, J., et al. (2023). Proteus: Simulating the performance of distributed DNN training. arXiv. Execution graphs, shared bandwidth, and throughput prediction experiments ↩ ↩2

  26. Miao, X., et al. (2022). Galvatron: Efficient Transformer training over multiple GPUs using automatic parallelism. arXiv. Algorithm 1 and section 3.4, strategy search under memory budgets and communication time estimates ↩ ↩2

  27. Alpa contributors. (n.d.). Alpa quickstart. Alpa 0.2.3.dev17. Official training step, automatic parallelization, and numerical validation. ↩ ↩2

  28. Alpa contributors. (n.d.). Performance tuning guide and Distributed training with both shard and pipeline parallelism. Alpa 0.2.3.dev17. Tuning sequence starting from data parallelism; manual and automatic stage examples. ↩

Β© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-07-10). What Do 1D, 2D, 2.5D, and 3D Mean in Tensor Parallelism?. https://caiborui.com/blog/2025-07-10-zh-tensor-parallelism-dimensions-entrans

@misc{borui2025-82b496d9,
  author = {borui},
  title = {{What Do 1D, 2D, 2.5D, and 3D Mean in Tensor Parallelism?}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-07-10-zh-tensor-parallelism-dimensions-entrans}
}