Tensor Parallelism › Why Split Tensors?

Michael BrenndoerferJanuary 19, 20263 min read
Language AI HandbookAll chapters
Part 31 of 67Training Infrastructure
Chapter 223Tensor Parallelism › Why Split Tensors?
Reading section 2 of 12 · Why Split Tensors? · 3 minSection 2 of 12 · 3 min

Book contents

Section 2 of 12 · 3 min read

Tensor Parallelism › Why Split Tensors?One section · Sections in this chapter2 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Before diving into how tensor parallelism works, it helps to be precise about the problem it solves and why the solutions take the forms they do.

A standard linear layer computes Y=XAY = XA, where X∈Rb×dX \in \mathbb{R}^{b \times d} is a batch of bb tokens each with hidden dimension dd, and A∈Rd×hA \in \mathbb{R}^{d \times h} is a weight matrix mapping to some output dimension hh. The output Y∈Rb×hY \in \mathbb{R}^{b \times h} is dense: every output element depends on every input element. At first glance, this density suggests that any partitioning of the computation must involve data dependencies, and therefore communication, across devices.

But the density of the output does not mean the computation is inseparable. Matrix multiplication has a fundamental block structure that allows it to be decomposed in multiple ways. Understanding this structure is the conceptual key to tensor parallelism.

When dd and hh are large (e.g., d=12288d = 12288 for GPT-3's hidden size), the weight matrix AA can be enormous. A single linear layer in GPT-3's attention has four weight matrices for Q, K, V, and output projections, each of size 12288×1228812288 \times 12288, consuming roughly 576 MB each in fp16. Across 96 layers, the attention weights alone exceed 200 GB. The FFN layers add another 150 GB or more. No single device, regardless of generation, can hold this.

The key insight enabling tensor parallelism is that matrix multiplication is separable. Different columns of AA contribute to different columns of YY without any cross-dependency, and different rows of AA can each be multiplied with the corresponding input slice independently, with results accumulated at the end. This separability is the mathematical foundation for both column-parallel and row-parallel splitting strategies. The question is not whether the computation can be split, but how to split it such that the communication required to assemble final results is minimized and falls at convenient points in the computation graph.

The choice of splitting direction is not arbitrary. Different layers and positions in the transformer have different mathematical structures, and the clever design of tensor parallelism is that it exploits these structures to pair column splits with row splits in a way that eliminates intermediate communication. The column-parallel output of one layer is exactly the right input format for a row-parallel next layer, creating a natural pipeline that requires only a single all-reduce per sub-layer rather than a communication step between every layer.