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

Distributed Inference Parallelism

Choose replication, tensor, pipeline, data, or expert parallelism from model fit and service objectives.

Freshness: current•15 min read•Production Infrastructure and AI Economics

Key Learning Outcomes

  • ✓Explain the operating model behind Distributed Inference Parallelism.
  • ✓Evaluate trade-offs and failure modes for Distributed Inference Parallelism.
  • ✓Apply Distributed Inference Parallelism to a production decision.
Full Technical Reference Document

Mental model

Choosing distributed inference parallelism solves one core equation cleanly: VRAM capacity fit + interactive latency vs. inter-GPU collective overhead. Always prioritize un-split Data Replication (DP) while model weights and KV headroom fit cleanly inside one device; introduce Tensor Parallelism (TP) strictly across ultra-fast intra-node NVLink islands to cut single-stream TTFT/TPOT or fit mid-size checkpoints; and keep Pipeline (PP) / Expert Parallelism (EP) reserved strictly when total weights outgrow one physical server chassis.

Compute weights + KV headroom
Test 1-GPU fit (quantization first?)
Apply intra-node NVLink TP if needed
Add DP replicas across fault domains
Bind topology-aware K8s placement
Conceptual teaching model synthesized from:vLLM V1 GPU model runner at v0.10.2Kubernetes resource management for Pods and containers

Learning outcomes

  • Size exact VRAM consumption (weights + activation buffers + target concurrent KV cache) cleanly before partitioning workloads across GPUs.
  • Explain why quantization (BF16 -> FP8/INT4) or smaller tiered models often beat cross-device TP=2 cleanly on real throughput per dollar.
  • Configure Kubernetes/cluster topology awareness so distributed ranks stay packed on shared PCIe/NVLink switches rather than spanning availability zones.

Theory

Throwing more GPUs at an inference checkpoint never delivers free linear speedups cleanly cleanly because splitting matrices creates continuous barrier synchronization (AllReduce) across transformer forward passes. Selecting the narrowest sufficient distribution scope keeps latency predictable and prevents single-GPU ECC faults from crashing entire multi-rack jobs cleanly:

Parallelism TopologySynchronization ScopeNVLink / Fabric DependencyEffect on Single-Request LatencyFailure Blast Radius
Independent Replicas (DP, TP=1)Zero communication during inferenceStandard cluster Ethernet load balancerBaseline 1-GPU FLOP + HBM speed1 isolated node/GPU (highest availability)
Intra-Node Tensor Parallel (TP=2..8)2x AllReduce every decoder layer (60–160x per token)Mandatory (NVLink / NVSwitch inside node)Cuts prefill & decode latency dramatically cleanly up to bus limitsTP-sized group restarts jointly cleanly
Inter-Node Pipeline Parallel (PP)Hidden states pushed at layer boundariesTolerates RoCE / InfiniBand (point-to-point)Adds pipeline bubble wait; mainly raises capacity rather than speedEntire multi-node pipeline (highest complexity)
MoE Expert Parallel (EP)All-to-All token dispatch/combine per MoE layerHigh-bisection RDMA / NVSwitch requiredEnables trillion-param MoE sparse decode at scale cleanlyHigh sensitivity cleanly to any slow straggler rank

Always verify arithmetic fit alternatives before jumping into multi-GPU parallelism: a 70B checkpoint consuming 140 GB at BF16 drops immediately to 70 GB under verified FP8 (~35 GB under AWQ INT4), comfortably freeing KV cache space on one 80 GB H100 or two TP=2 GPUs with double the replica count per server cleanly!

python
from dataclasses import dataclass
​
@dataclass(frozen=True)
class FitAudit:
params_billions: float
bytes_per_param: float
target_kv_gb: float
gpu_vram_gb: float
nvlink_gpus_per_node: int
​
def recommend_inference_topology(spec: FitAudit, latency_critical: bool) -> dict[str, object]:
"""Choose minimal viable parallelism favoring DP replication and NVLink-bounded TP."""
weight_gb = spec.params_billions * spec.bytes_per_param
total_gb = weight_gb + spec.target_kv_gb + 4.0 # 4GB CUDA graph & activation headroom
usable_per_gpu = spec.gpu_vram_gb * 0.90
​
if total_gb <= usable_per_gpu and not latency_critical:
return {"tp": 1, "pp": 1, "strategy": "independent_dp_replicas"}
​
needed = max(1, int(-(-total_gb // usable_per_gpu)))
if needed <= spec.nvlink_gpus_per_node:
tp = 1
while tp < needed:
tp *= 2
if latency_critical and total_gb <= usable_per_gpu and spec.nvlink_gpus_per_node >= 2:
tp = 2 # Deliberate TP=2 cuts interactive TTFT/TPOT cleanly inside NVLink
return {"tp": min(tp, spec.nvlink_gpus_per_node), "pp": 1, "strategy": "intra_node_nvlink_tp"}
​
return {
"tp": spec.nvlink_gpus_per_node,
"pp": max(2, -(-needed // spec.nvlink_gpus_per_node)),
"strategy": "multi_node_tp_plus_pp_topology_pinned",
}

Trade-offs

Independent DP replicas maximize total fleet requests per dollar cleanly under high throughput workloads (0% collective synchronization tax) and ensure a crashing replica drains quickly without harming peers. Moving up to TP=4 or TP=8 inside an NVLink server slices interactive time-to-first-token (TTFT) and memory-bound TPOT dramatically cleanly while uniting 4–8 GPUs into a shared failure domain. Spanning across nodes via PP or multi-host EP unlocks giant frontier checkpoints exceeding single-chassis memory cleanly at substantial tail-latency jitter and Kubernetes topology-scheduling operational complexity.

Failure modes and misconceptions

  • Assuming TP=4 Always Runs 4x Faster: Collective communication overhead, smaller per-GPU GEMM tiling efficiency, and uneven attention heads rapidly flatten scaling beyond TP=4 on smaller checkpoints (8B–14B).
  • Missing Kubernetes Topology Placement Managers: Scheduling TP=4 pods randomly across mismatched PCIe switches without NVLink verification starves collectives silently across CPU root complexes.
  • Adding Tensor Parallelism Before Testing Quantization (FP8) or Distillation: Burning multi-GPU complexity cleanly to host unquantized weights when lossless FP8 fits cleanly onto single-GPU DP replicas doubles serving bills unnecessarily.
  • Placing All Replicas in One Fault Domain: Running replicas without spread constraints across racks/AZs lets one power breaker outage wipe 100% serving capacity cleanly.

Decision scenario

A model (45 GB at FP8 weights) barely misses fitting with 30 GB desired KV cache headroom cleanly inside a single 48 GB L40S GPU during moderate daytime load. Compare shifting to verified INT4 quantization vs. TP=2 NVLink pairing vs. smaller fast routing tiers cleanly across hardware cost, tail latency, and fault isolation.

Reflect before revealing the guide

When is deploying multiple independent single-GPU replicas (Data Parallelism) preferable to splitting single requests cleanly across Tensor Parallelism?

Prerequisites & Related Concepts (4)

Private notes

0 words
Included In Free Course
Free · Verifiable Credential

FS-201Production LLM Engineer

Design an observable full-stack LLM product from capability validation through interfaces retrieval evaluation security and operations.

37 concepts~35h 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.

Next