Tensor Parallelism › Column Parallelism
Language AI HandbookAll chapters Tensor Parallelism › Column ParallelismOne section · Sections in this chapter3 / 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
Column parallelism splits a weight matrix along its output (column) dimension. Given GPUs with indices , we partition the weight matrix into column slices:
where each .
Each GPU stores its slice and computes:
where:
- is the full input, replicated on all GPUs
- is the column shard on GPU
- is the partial output on GPU
The partial outputs together form the full output: concatenating along the column dimension recovers the full . This is correct because matrix multiplication with a partitioned weight matrix produces a partitioned result:
The critical observation is that each GPU's computation is completely independent. No communication is needed during the forward pass to produce ; each device can compute its shard without knowledge of what the other devices are doing. The price is that the input must be fully available on every GPU before computation begins. In practice, this is handled by an all-gather operation at the start of the layer or by keeping the input in the replicated state (which happens automatically when tensor parallelism is paired with data parallelism).
Why is replicating the input acceptable? Because the input to each transformer layer is the residual stream, which after an all-reduce from the previous layer is identical on all GPUs. There is no communication cost to have a replicated input in steady-state operation, since the previous layer's row-parallel all-reduce already distributed it.
Column Parallelism for Multi-Head Attention
Column parallelism is natural for the query, key, and value projections in multi-head attention. Recall that multi-head attention splits the model's hidden dimension into heads, where each head operates on a dimensional subspace. When you have GPUs and split the weight matrix along the head dimension, each GPU naturally handles attention heads. The column-parallel split corresponds exactly to distributing heads across devices.
This alignment between tensor parallelism and multi-head attention is not a coincidence. The original Megatron-LM paper was designed with this correspondence in mind. Because attention heads are completely independent of one another during the self-attention computation (they attend to the full sequence in parallel subspaces without interacting), you can assign entire heads to individual GPUs and have each GPU compute attention for its assigned heads without ever communicating with other GPUs during the attention computation itself. The interaction between heads happens only when their outputs are projected back to the model's hidden dimension, and that projection is handled by the row-parallel output projection.
For an attention layer with hidden size and 32 heads on 4 GPUs, each GPU holds the Q, K, V projection weights for 8 heads: matrices of size rather than . Each GPU attends over its 8 heads independently and produces attention outputs of size . The output projection then acts on these 1024-dimensional features row-parallel, accumulating the full 4096-dimensional output across GPUs via all-reduce.
Column Parallelism for the Feed-Forward Network
The feed-forward network (FFN) also benefits from column parallelism. A standard transformer FFN applies two linear transformations with a nonlinearity between them:
where:
- is the input batch with tokens and hidden dimension
- is the expansion weight matrix, increasing the dimension by a factor of 4
- is the expansion bias
- is the activation function (GeLU in most modern transformers, ReLU in older ones)
- is the contraction weight matrix, reducing back to
- is the output bias
Column parallelism applied to splits the expansion across GPUs. GPU receives the full input and computes using its column shard (for a 4-way split of a -dimensional FFN). The activation function is then applied locally because GeLU and ReLU operate element-wise on each dimension independently. This is a subtle but important point: element-wise nonlinearities are trivially parallelizable because each output element depends on exactly one input element, which lies entirely within the local shard.
After the nonlinearity, each GPU holds . These shards together form the full intermediate activation , ready to be consumed by the row-parallel second layer.
