← Questions

Tensor parallelism versus pipeline parallelism

0
AmazonAI/ML designLast asked Dec 2025

An AI/ML design interview question asked in Amazon's system design round, last asked Dec 2025. It tests distributed training, parallelism and llm.

A transformer is too large to fit on one accelerator, for training or for serving. Compare the two classic ways of splitting the model across devices, tensor parallelism and pipeline parallelism: what each one cuts, what has to be communicated and when, where devices sit idle, and how each behaves as you add devices. Then say when you would use each and how they combine with data parallelism.

Requirements

  • Functional:
    • Tensor parallelism: how a layer's weight matrices are split across devices (column-parallel then row-parallel for the MLP; attention heads split across devices) and which collectives that forces in the forward and backward pass.
    • Pipeline parallelism: how consecutive layers are assigned to stages, what moves between stages (activations forward, gradients backward), and where the pipeline bubble comes from.
    • How micro-batches shrink the bubble, and how schedules such as GPipe and 1F1B trade bubble size against activation memory.
    • How each choice changes memory per device (weights, activations, optimizer state) and the communication volume.
  • Non-functional: reason about interconnect bandwidth and latency (fast links inside a node, slower ones across nodes), and about training versus serving, where batch sizes and latency goals differ.

Clarifying questions

  • Is this for training, serving, or both? For serving, is the goal latency or throughput?
  • How many devices, and what is the interconnect inside a node and between nodes?
  • How large is the model relative to device memory, and how large are the batches and sequences?
  • Is the model a dense transformer, or does it have mixture-of-experts layers?

What a strong answer covers

  • Tensor parallelism splits every layer, so it needs an all-reduce (or reduce-scatter plus all-gather) inside each block, two per layer in the forward pass (after attention and after the MLP); it is communication-heavy and latency-sensitive, which is why it usually stays within one node on the fastest links, and its efficiency drops as the per-device matrices shrink.
  • Pipeline parallelism sends only activations at stage boundaries, point to point, so it tolerates slower links and spans nodes well; its cost is the bubble, about (p - 1) / (m + p - 1) of the time for p stages and m micro-batches with a simple schedule, plus balancing layers so stages take equal time.
  • Micro-batching and interleaved or 1F1B schedules reduce the bubble and the activation memory held in flight; more micro-batches means a larger global batch, which interacts with optimization.
  • For serving: tensor parallelism lowers the latency of a single request; pipeline parallelism raises throughput but not single-request latency, since a token still passes through every stage.
  • 3D parallelism: tensor parallel inside a node, pipeline parallel across nodes, data parallel (or fully sharded data parallel) on top to scale the batch; how the device mesh is laid out to match the network.
  • The trade-offs named and decided for a concrete case, for example a 70B model on 8-GPU nodes.

Follow-ups

  • Where does sequence parallelism fit, and why does it pair with tensor parallelism for long contexts?
  • How would you pick the tensor and pipeline degrees for a given model, cluster and batch size?
  • How does fully sharded data parallelism (ZeRO-3) differ from tensor parallelism in what it shards and what it communicates?
  • What changes when one pipeline stage is slower than the others, or a device fails mid-run?

Where it's asked

What it tests

distributed training · parallelism · llm

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing