AI ENGVisual Encyclopedia

SCENE 22 / 24 · DISTRIBUTED INFERENCE & INFRASTRUCTURE SCALE

KV caches across nodes

Offload, stream and balance attention memory over the network fabric.

QUEUE DEPTH16,384 TOK × 8 REQ
HBM · HOT32.00 GBHOST MEM / NVMe · COLD32.00 GBRDMAfetch cold block over fabric · 1374 ms @ 25 GB/svs recompute from scratch · 1475 ms→ offload wins

Placement is the decision: streaming a cold KV block over the fabric beats recomputing it — until it doesn't. Balance keeps hot prefixes resident and long tails tiered.

TECHNICAL BREAKDOWNModule 7: Distributed Inference & Infrastructure Scale

Distributed KV cache: offloading, streaming & tiered memory

As context windows expand to 100k+ tokens, KV cache footprint exceeds GPU VRAM. Tiered KV management offloads inactive or cold KV cache blocks to CPU RAM or NVMe storage over PCIe/RDMA, streaming them back to GPU VRAM only when needed, avoiding expensive recomputation.

Hierarchy of Memory

GPU HBM (fastest, tiny) → CPU RAM (fast, large) → NVMe SSD (slowest, massive). Managing KV caches across this hierarchy optimizes overall system cost.

Offload vs Recompute Decision

If fetching a cold KV cache from CPU RAM over PCIe takes longer than recomputing the prefill on GPU, recomputation is preferred.

RDMA Remote Caching

In multi-node clusters, a node with idle VRAM/RAM can host KV caches for other nodes using Remote Direct Memory Access (RDMA).

MATHEMATICAL FORMULATION · OFFLOAD VS RECOMPUTE THRESHOLD
t_fetch = KV_bytes / PCIe_BW vs t_recompute = N_tokens / 1000 × prefill_ms_per_1k

Transferring 10 GB of KV over PCIe Gen5 (64 GB/s) takes ~156 ms. Recomputing 20k tokens at 40ms/1k takes 800 ms. Fetching wins by 5x.

REAL-WORLD PRODUCTION ENGINEERING
  • FlexGen and DeepSpeed-Inference pioneer tiered KV offloading to serve long-context models on single consumer GPUs.
  • vLLM's multi-tier cache manager coordinates page migration between GPU HBM and Host CPU RAM seamlessly.