Notes

Tensor Parallelism

A 70-billion-parameter model in 16-bit precision needs about 140 GB for its weights alone — more than any single accelerator holds. One answer is to cut each layer into pieces and have several devices compute that one layer together. That is tensor parallelism.

Splitting the matrices

A transformer layer is mostly large matrix multiplications, and a matrix multiplication divides cleanly. A feed-forward weight matrix is partitioned across devices, each computes its slice of the output, and a collective all-reduce stitches the partial results together before the next operation needs them. Attention splits along heads instead: each device owns a subset of the heads and the matching slice of the KV cache. Every device holds a fraction of the parameters and sees every token, which is the defining difference from the other parallelism strategies.

What it buys, what it demands
  • It fits the unfittable — weights, activations and KV cache all divide by the device count, which is what puts a 70B model on two 80 GB cards.
  • It cuts latency — several devices work on the same token simultaneously, so time-per-token falls. Pipeline parallelism, which assigns whole layers to devices, raises throughput but not single-request speed.
  • It demands a fast fabric — there is a communication step inside every layer, so tensor parallelism is kept inside one node across NVLink. Stretched over an Ethernet cluster it loses more to communication than it gains.

Megatron-LM introduced it at scale, it forms the inner dimension of the 3D parallelism used to train frontier models, and the tensor-parallel size setting in vLLM is the same idea at serving time.

Tensor parallelism splits the weight matrices inside a single layer across several accelerators: each device computes part of the output and a collective all-reduce combines the pieces before the next operation. Parameters, activations and KV cache all divide by the device count, which is how models too large for one GPU are trained and served, and per-token latency falls because the devices work on the same token together. It communicates inside every layer, so it stays within one fast-interconnected node.

Some jobs are too big for one worker, so you split the work itself rather than the queue — four people each add up one column of a long invoice, then combine their totals. Tensor parallelism does this with AI models. The biggest ones will not fit in a single graphics card's memory, so each calculation inside the model is sliced up, every card handles a share, and the pieces are added back together at each step. Several chips end up acting as one bigger chip. The catch is that they must talk to each other constantly, so they need to sit in the same machine.