Mental model
Distributing AI workloads across multiple GPUs trades single-device memory and FLOP limits for explicit network collectives, scheduler synchronization, KV-cache locality challenges, and partial-failure blast radii. Sound cluster architecture names cleanly what gets replicated (model weights for throughput) vs. what gets partitioned (matrices or layers to fit VRAM or drop single-stream latency) alongside the exact interconnect hardware boundary carrying those barriers.
Learning outcomes
- Select cleanly among Data Parallelism (
DP), Tensor Parallelism (TP), Pipeline Parallelism (PP), and Expert Parallelism (EP) based on model weights, batch SLA, and fabric bandwidth. - Account explicitly for AllReduce, AllGather, ReduceScatter, and All-to-All communication stalls along transformer layers.
- Design graceful health fencing, queue backpressure, and prefill/decode disaggregation without cascading cross-node retries.
Theory
Partitioning a 70B or 671B model across multi-GPU clusters fails whenever engineers deploy generic web microservice assumptions (arbitrary stateless autoscaling) onto tightly coupled collective communication graphs. Every parallelism dimension stresses a different hardware interconnect:
| Parallelism Mode | What Splits Across Ranks | Sync Frequency per Forward Step | Interconnect Requirement | Optimal Use Case |
|---|---|---|---|---|
Data Parallel (DP / Replicas) | Independent requests / microbatches | Zero per forward step (inference); 1 AllReduce per grad step | Standard Ethernet / cross-rack | Always maximize first while single replica fits node memory |
Tensor Parallel (TP) | Columns/rows inside each QKV/MLP GEMM | 2x AllReduce per transformer layer (160+ per token!) | Intra-node NVLink / NVSwitch (450–900 GB/s) | Mandatory when model weights exceed 1 GPU or cutting interactive TTFT/TPOT |
Pipeline Parallel (PP) | Contiguous subsets of layers across stages | Point-to-point hidden activation sends at stage cuts | PCIe / InfiniBand across nodes | Multi-node fits where single node lacks VRAM; watch bubble idle % |
Expert Parallel (EP) | MoE routed feedforward experts across ranks | 2x All-to-All dispatch & combine per MoE layer | High-bisection RDMA (400–800 Gbps) or NVLink | Massive sparse MoE checkpoints (DeepSeek-V3, Mixtral) |
Never span tightly synchronous Tensor Parallelism across slow inter-host Ethernet links: launching 160 sequential blocking AllReduce barriers over TCP latency destroys decoding throughput dramatically faster than running fewer replicas cleanly inside intra-node NVLink domains! For massive mixed-latency clusters, Prefill-Decode Disaggregation separates compute-heavy prompt ingestion workers (high TP, saturating FLOPs) from memory-bandwidth-bound decode pools (high KV concurrency), streaming initial KV pages once over RDMA.
pythonfrom dataclasses import dataclass@dataclass(frozen=True)class ClusterSpec:gpu_vram_gb: floatgpus_per_node: intintra_node_nvlink: boolmodel_weights_gb: floatkv_headroom_gb: floatdef select_serving_parallelism(spec: ClusterSpec, max_tp_latency_target: bool) -> dict[str, object]:"""Select safest distributed topology respecting VRAM fit and NVLink hardware boundaries."""required_vram = spec.model_weights_gb + spec.kv_headroom_gbmin_gpus_for_fit = max(1, int(-(-required_vram // spec.gpu_vram_gb))) # Ceiling divif min_gpus_for_fit == 1 and not max_tp_latency_target:return {"strategy": "pure_data_parallel", "tp": 1, "pp": 1, "note": "Zero collective overhead per step"}if min_gpus_for_fit <= spec.gpus_per_node and spec.intra_node_nvlink:# Round up to next power of 2 cleanly bounded inside single NVLink servertp = 1while tp < min_gpus_for_fit:tp *= 2return {"strategy": "intra_node_tp", "tp": tp, "pp": 1, "note": "Keep AllReduce inside NVLink"}return {"strategy": "hybrid_tp_plus_pp","tp": spec.gpus_per_node if spec.intra_node_nvlink else 1,"pp": max(2, -(-min_gpus_for_fit // spec.gpus_per_node)),"note": "Avoid cross-node TP AllReduce over network fabric",}
Trade-offs
Independent single-node Data Parallelism isolates hardware failures cleanly per host, scales horizontally effortlessly via Kubernetes HPAs, and incurs zero cross-rank runtime stalls—making it the strict default whenever checkpoints (7B–70B FP8) fit comfortably within one HGX/DGX server. Splitting a single request across TP=8 or multi-node PP expands total KV capacity and cuts interactive prefill TTFT dramatically, while magnifying blast radius cleanly so one unresponsive ECC-faulty GPU stalls the entire partitioned rank ring unless liveness heartbeats evict and respawn cleanly.
Failure modes and misconceptions
- Running
TPOver Cross-Rack Ethernet: Extending tensor parallelism across multi-server NIC hops turns microsecondAllReducebarriers into multi-millisecond stalls, collapsing tokens-per-second below a smaller un-split server. - Autoscaling Without Weights Warmup Budgets: Configuring aggressive Kubernetes HPA scaling policies on
40B–140GBweights triggers 5-minute cold-pull startup thrashing whenever burst spikes arrive unless model weights sit pre-staged on local NVMe caches. - Uncapped Pre-Alloc Queues Causing Retry Amplification: Letting slow failed TP workers stay registered in router load balancers triggers timeouts plus blind client retries that overwhelm surviving healthy replicas.
Decision scenario
A model platform deploys a 140 GB FP8 dense checkpoint onto 8-GPU nodes (80 GB VRAM per GPU) with high-speed intra-node NVLink and 200 Gbps inter-node Ethernet. Traffic spikes demand both sub-second interactive streaming and zero cross-rack bottlenecks. Size exact intra-node TP, inter-node DP replicas, AZ failure boundaries, and load shedding policies cleanly.
When should a serving cluster prefer replicating full model instances (Data Parallelism) over partitioning single requests across devices (Tensor or Pipeline Parallelism)?