Tensor Parallelism
Tensor Parallelism is a model-parallel training and inference strategy in which individual weight tensors (typically large matrix multiplications) are partitioned across multiple devices, allowing each device to compute a shard of every layer rather than a disjoint subset of layers. It is foundational to training trillion-parameter models that cannot fit on a single accelerator, and it operates orthogonally to both data parallelism and pipeline parallelism, enabling multi-dimensional parallelism hierarchies. A counterintuitive fact: tensor parallelism deliberately increases total floating-point operations (by requiring all-reduce collectives), yet consistently achieves near-linear throughput scaling because communication and computation can be perfectly overlapped on modern interconnects.
The key insight is that a matrix multiplication can be split along either the column or row dimension of such that each device computes a partial result, and these partial results can be recombined with a single collective communication — meaning the algebraic structure of matrix multiplication naturally tolerates partitioning. The "aha moment" is recognizing that this is not an approximation: the mathematics is exact, and the only overhead is the all-reduce at partition boundaries, not any approximation error. This makes tensor parallelism fundamentally different from model compression — it is exact arithmetic distributed across hardware.
How It Works
Column-Parallel and Row-Parallel Linear Layers
The fundamental decomposition follows from the block-matrix identity for matrix products. Consider a linear layer with weight and input , where is batch size, is input dimension, and is output dimension. Partition column-wise across devices:
Explanation: Each device holds exactly of the output neurons, enabling all devices to simultaneously compute partial outputs from the full input without any prior communication. Each device independently computes:
Explanation: This local computation is embarrassingly parallel — no inter-device communication is needed before the activation function if the activation is elementwise. For a row-parallel layer (e.g., the second linear in an MLP), partition row-wise and column-wise (the output of the previous column-parallel layer):
Explanation: The full output is the sum of rank- outer products, recovered exactly by an all-reduce collective .
Communication Complexity
For a tensor-parallel degree , a forward pass through one transformer block requires exactly 2 all-reduce operations (one after the attention projection and one after the second MLP linear). The communication volume per all-reduce is:
Explanation: The factor arises from the ring-all-reduce algorithm, which requires point-to-point messages each of size , converging to bytes asymptotically for large — independent of in the large- limit. Here is sequence length and is hidden dimension.
Attention Head Parallelism
Multi-head attention with heads decomposes naturally: assign heads per device. The per-device query, key, and value projections are:
Explanation: Because each attention head operates independently before the output projection, the multi-head split is a special case of column parallelism where must be divisible by , and the output projection becomes a row-parallel layer requiring a single all-reduce.
Backward Pass
The gradient flow is dual: the backward pass through a column-parallel layer requires an all-gather (to reconstruct the full gradient w.r.t. ), and the backward pass through a row-parallel layer requires a reduce-scatter. In practice, these collapse to the same all-reduce pattern as the forward pass when combined in the standard column–row layout, so the total collective count per transformer block is 4 (2 forward + 2 backward).
Mohammad Shoeybi is a principal research scientist at NVIDIA whose work on large-scale language model training systems has shaped the infrastructure behind many of the largest models in existence. In the landmark 2019 paper Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism, Shoeybi and colleagues formalized the column-parallel/row-parallel decomposition described here and demonstrated 8-way tensor parallelism on 72 GPUs with 76% scaling efficiency for an 8.3B parameter GPT-2 variant. A surprising historical detail: the Megatron-LM codebase was initially an internal NVIDIA project and was released open-source almost as an afterthought, yet it became the de facto reference implementation that most academic and industrial large-model efforts forked from.
Intuition
Imagine a very long arithmetic exam with 1000 problems. One approach (pipeline parallelism) is to divide the exam booklet into sections and assign different sections to different students — student A does problems 1–250, student B does 251–500, etc. But tensor parallelism is different: every student works on every problem simultaneously, except each student only computes a fraction of each answer. For a multiplication like , you could assign each student a subset of the partial products (the columns of the long multiplication grid), and then everyone shouts out their partial sums at the end, which a coordinator adds up in one step. The coordinator step is the all-reduce — fast, exact, and required only once per problem. The insight is that matrix multiplication is naturally decomposable this way: the column structure of the weight matrix means each shard is completely self-contained until the very last addition. This is why modern interconnects like NVLink (with 900 GB/s bandwidth) make tensor parallelism so efficient: the "shouting" step is extremely fast relative to the computation itself, especially for the large batch sizes and hidden dimensions characteristic of large language models.