Tensor Parallelism › Worked Example: Column-Parallel FFN
Language AI HandbookAll chapters Tensor Parallelism › Worked Example: Column-Parallel FFNOne section · Sections in this chapter8 / 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
Let's trace through a specific numerical example to make the computation concrete. Suppose we have a feed-forward network with input dimension , hidden dimension , and we are using GPUs.
The full weight matrix is split column-wise:
where lives on GPU 0 and lives on GPU 1.
Given an input (batch of 2 tokens, each with 4 features), both GPUs have the full input. GPU 0 computes:
and GPU 1 computes:
After the GeLU nonlinearity applied locally on each GPU, the activations and together form the full intermediate representation . Neither GPU needed to communicate with the other to reach this point.
The second weight matrix is split row-wise:
where on GPU 0 and on GPU 1.
GPU 0 multiplies its activation shard by its weight shard: . GPU 1 multiplies its activation shard by its weight shard: .
The final output is obtained by all-reducing (summing) across GPUs:
This is identical to the full computation , but computed with weight matrices that fit on individual GPUs. The only communication is the final all-reduce that sums and .
What makes this example particularly illuminating is the absence of intermediate communication. Between the column-parallel step and the row-parallel step, GPUs 0 and 1 proceed completely independently. GPU 0 never needs to know what looks like. GPU 1 never needs to know what looks like. They only need to coordinate once, at the very end, to produce the final output. This one communication per two linear layers is the core efficiency of Megatron-style tensor parallelism.