FullStack AI Hub
Studio
lesson depth
Mastery
not started · 0%

Distributed AI Systems

How computation communication memory placement and failure domains shape large-scale AI platforms.

Freshness: current•17 min read•Distributed AI Platforms

Key Learning Outcomes

  • ✓Identify compute memory communication and failure domains
  • ✓Compare data tensor and pipeline partitioning
  • ✓Design bounded degradation and recovery
Full Technical Reference Document

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.

Workload memory & SLA sizing
Select DP, TP, PP, or EP layout
Place within NVLink vs RoCE domain
Route requests & migrate KV state
Detect node stall & fence replica
Shed load cleanly across AZs
Conceptual teaching model synthesized from:Efficient Memory Management for Large Language Model Serving with PagedAttentionvLLM inference and serving engineHorizontal Pod Autoscaling

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 ModeWhat Splits Across RanksSync Frequency per Forward StepInterconnect RequirementOptimal Use Case
Data Parallel (DP / Replicas)Independent requests / microbatchesZero per forward step (inference); 1 AllReduce per grad stepStandard Ethernet / cross-rackAlways maximize first while single replica fits node memory
Tensor Parallel (TP)Columns/rows inside each QKV/MLP GEMM2x 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 stagesPoint-to-point hidden activation sends at stage cutsPCIe / InfiniBand across nodesMulti-node fits where single node lacks VRAM; watch bubble idle %
Expert Parallel (EP)MoE routed feedforward experts across ranks2x All-to-All dispatch & combine per MoE layerHigh-bisection RDMA (400–800 Gbps) or NVLinkMassive 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.

python
from dataclasses import dataclass
​
@dataclass(frozen=True)
class ClusterSpec:
gpu_vram_gb: float
gpus_per_node: int
intra_node_nvlink: bool
model_weights_gb: float
kv_headroom_gb: float
​
def 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_gb
min_gpus_for_fit = max(1, int(-(-required_vram // spec.gpu_vram_gb))) # Ceiling div
​
if 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 server
tp = 1
while tp < min_gpus_for_fit:
tp *= 2
return {"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 TP Over Cross-Rack Ethernet: Extending tensor parallelism across multi-server NIC hops turns microsecond AllReduce barriers 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–140GB weights 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.

Reflect before revealing the guide

When should a serving cluster prefer replicating full model instances (Data Parallelism) over partitioning single requests across devices (Tensor or Pipeline Parallelism)?

Prerequisites & Related Concepts (2)

Private notes

0 words
Included In Free Course
Free · Verifiable Credential

FS-101Model Serving and Inference

Understand inference engines memory scheduling batching routing scaling distributed execution lifecycle controls observability and economics.

19 concepts~23h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.