Inference, Serving & Production·Question 24 of 76Intermediate

Explain tensor parallelism vs pipeline parallelism for inference. When do you need each?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Both split a too-big model across GPUs; they cut along different axes with different communication and latency profiles.

Full worked answer with diagram

Both split a too-big model across GPUs; they cut along different axes with different communication and latency profiles.

Tensor parallelism (TP) shards within each layer: attention heads and MLP matrices are split across N GPUs, each computes its slice of every layer, and results are combined with all-reduces (typically two per transformer block - after attention's output projection and after the MLP). Every GPU participates in every token, so TP genuinely reduces per-token latency (each GPU does ~1/N of the FLOPs and streams ~1/N of the weight bytes) - but it's chatty: an all-reduce every layer, dozens of times per token, demands NVLink-class bandwidth. Rule of thumb: TP within a node (2/4/8 GPUs), never across slow interconnects. TP=8 over NVLink is the standard way a 70B+ FP16 model gets served.

Pipeline parallelism (PP) shards across layers: GPU 0 holds layers 1-20, GPU 1 holds 21-40, etc.; activations flow stage to stage. Communication is tiny (one hidden-states tensor per stage boundary), so PP tolerates Ethernet/IB across nodes. But it does not reduce per-token latency - each token still traverses all layers serially, plus hop overhead - and stages idle ("bubbles") unless enough concurrent work keeps every stage busy. Interviewers like this contrast stated plainly: TP is a latency and capacity tool; PP is a capacity tool whose throughput depends on keeping the pipeline full (which continuous batching happily provides).

Practical serving playbook: fit on one GPU if quantization allows (parallelism-free is simplest); TP within a node for bigger models; add PP only when a model exceeds a single node (e.g., frontier-scale or long-context monsters) - TP intra-node × PP inter-node. One-liner extensions worth naming: expert parallelism for MoE (experts sharded across GPUs, all-to-all routing) and data parallelism (independent replicas behind a load balancer) as the scaling mechanism once a single replica's shape is chosen.

Worth sketching. Drawing the cut axis next to its communication cost is what justifies "TP inside a node, PP across nodes" without hand-waving.

flowchart LR
    TP["Tensor parallel: every layer<br/>sharded across N GPUs"] --> TC["Two all-reduces per block,<br/>dozens of times per token"]
    TC --> TR["Cuts per-token latency,<br/>needs NVLink, keep in one node"]
    PP["Pipeline parallel: layers 1-20 here,<br/>21-40 there"] --> PC["One hidden-state tensor<br/>per stage boundary"]
    PC --> PR["Same per-token latency, tolerates Ethernet,<br/>bubbles unless the pipe stays full"]

What a good answer covers

  • Both split a too-big model across GPUs; they cut along different axes with different communication and…
  • Tensor parallelism (TP) shards within each layer
  • Every GPU participates in every token, so TP genuinely reduces per-token latency (each GPU does ~1/N of…
  • Rule of thumb: TP within a node (2/4/8 GPUs), never across slow interconnects
  • TP=8 over NVLink is the standard way a 70B+ FP16 model gets served

Key terms: Tensor parallelism (TP) · reduces per-token latency · Pipeline parallelism (PP) · not · expert parallelism · data parallelism

Interviewer follow-ups to expect

  1. Why does TP=8 across two 4-GPU nodes over Ethernet perform terribly?

  2. How does MoE change the parallelism picture?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep