What is Tensor parallelism?

Splitting one layer's weight matrix by rows or columns across GPUs, computing partial products and combining them through communication.

Field: AI Hardware & Software Stack

Japanese name: テンソル並列

Splitting a matrix for the computation

The core of a layer's computation is the product of the input and a weight matrix. Tensor parallelism cuts this matrix into pieces and gives one piece to each GPU. When it is split by output element, each GPU computes the product of the same input with its own share of the weights. What it gets is part of the output, and joining the parts gives the whole. If a layer with 4096 output elements is split across 4 GPUs, for example, each computes 4096 ÷ 4 = 1024 elements. When it is split by input element, the partial products from the GPUs are added together.

Frequent communication

Communication is needed in every layer to combine the results computed separately. It occurs in both the forward and the backward pass. Compared with data parallelism, whose communication is the gradient averaging of each step, it happens far more often. It is therefore generally used within one server, where the GPUs are joined by very fast links. Attention can be computed independently for each head, so a typical implementation divides the heads among the GPUs.

Difference from other kinds of parallelism

What each GPU holds is part of the layer's weights. Split across 4 GPUs, each holds about one quarter of that layer's weights. A large layer that does not fit on one GPU can therefore be handled. Data parallelism differs in that each GPU holds a replica of the whole model. Pipeline parallelism cuts between layers rather than inside a layer. Besides training, it is also used to spread inference of a large model over several GPUs.

Try it: questions about Tensor parallelism

Which describes tensor parallelism, which splits a large layer's matrix multiplication too big for one GPU across several GPUs?

  1. AEach GPU holds a full model replica and the data is split
  2. BThe weight matrix is split by rows or columns across GPUs, each computes a partial product, and results are combined through communication
  3. CEach layer is placed on a different GPU and processed in turn
Show answer and explanation

Answer: B. The weight matrix is split by rows or columns across GPUs, each computes a partial product, and results are combined through communication

In tensor parallelism, the weight matrix might be split column-wise into four parts held by four GPUs, each computing the product of the same input with its own columns. Combining results by concatenation or summation requires communication in every layer, so it is generally used among GPUs in the same server joined by very fast links. Combined with data and pipeline parallelism, it is used to train enormous models.

FAQ

How does it differ from pipeline parallelism?

The direction in which the model is cut is different. Pipeline parallelism cuts the sequence of layers and assigns groups of layers to GPUs. Tensor parallelism divides the matrix of one layer among GPUs, so communication is needed in every layer.

Does splitting the computation change the result?

Mathematically the result is the same. The matrix product is simply computed in parts and combined afterwards. Because the order of addition changes, small differences from floating-point rounding can appear.

Books on AI Hardware & Software Stack Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary