DavidGadyan

GPU Mind Map: Attention (Q, K, V), KV Cache, PCIe, NVLink, InfiniBand, RDMA and NCCL Explained

Why LLMs need GPUs and fast links: CPU against GPU cores, attention and the KV cache, why PCIe is too slow, and how NVLink, InfiniBand and RDMA move tensors between GPUs and servers.

Section 1: LLM foundations and hardware

  1. CPU vs GPU

    Few strong, many small

    What it is
    A CPU has a few powerful cores built to finish one hard, branching task as fast as possible. A GPU has thousands of small, simple cores built to run the same operation on a huge amount of data at once. LLMs are mostly giant matrix multiplications, which is exactly that second kind of work.
    When to use it
    The first answer to "why do we need GPUs for LLMs?".
    1. What a core is

      One unit that executes

      What it is
      A core is the unit that fetches an instruction, does the arithmetic and writes the result. A CPU core is large and clever (deep caches, branch prediction, out-of-order execution). A GPU "core" is much simpler, and it only works because thousands of them run in lock-step.
      When to use it
      Reading a spec sheet: core counts of a CPU and a GPU are not comparable numbers.
    2. CPU: low latency

      One hard job, fast

      What it is
      Designed to minimise the time of a single task: operating system, databases, web servers, control logic with many if/else branches. A handful to a few hundred cores, each very fast on serial work.
      When to use it
      Tokenisation, request handling, scheduling and anything that branches a lot.
    3. GPU: high throughput

      Many small jobs at once

      What it is
      Designed to maximise the work done per second: thousands of simple cores apply the same instruction to different data (SIMT). Each operation is slower than on a CPU core, but ten thousand of them in parallel finish a matrix far sooner.
      When to use it
      Matrix multiplication, convolutions, attention: anything that is the same maths over many numbers.
    4. SMs and warps

      How GPU cores are grouped

      What it is
      NVIDIA GPU cores are grouped into streaming multiprocessors (SMs). Threads run in warps of 32 that execute the same instruction together. The GPU hides memory delays by switching to another warp, which is why it needs far more work in flight than it has cores.
      When to use it
      Understanding why batching requests raises GPU utilisation.
    5. Tensor Cores

      Matrix maths in hardware

      What it is
      Special units inside each SM that multiply small matrix tiles in one step, in low precisions such as FP16, BF16, FP8 and FP4. They are why a modern GPU is far faster at LLM maths than its plain CUDA core count suggests.
      When to use it
      Why quantised models run faster on newer GPUs that support the format natively.
    6. Why LLMs fit GPUs

      Matrices, not branches

      What it is
      A transformer layer is a chain of matrix multiplications over thousands of independent numbers, with almost no branching. Each output element can be computed in parallel, so the work spreads over every core.
      When to use it
      Explaining GPU choice to a non-technical stakeholder in one sentence.
    7. Compute- vs memory-bound

      Prefill vs decode

      What it is
      Prefill (reading the prompt) multiplies big matrices and is limited by compute. Decode (one token at a time) must stream every weight and the whole KV cache from memory for each token, so it is limited by memory bandwidth, not by core count.
      When to use it
      Why a GPU with more memory bandwidth can beat one with more raw FLOPS for chat serving.
  2. Attention: Q, K, V

    A search inside the model

    What it is
    Think of Query, Key and Value as a search system inside the model, like looking for information in a library. Each token asks a question (Q), every earlier token advertises what it holds (K) and carries its content (V). The model gives more weight to the tokens whose K matches the Q.
    When to use it
    The core idea behind every transformer LLM; the base for the KV cache and the memory maths.
    1. Q: Query

      What am I looking for?

      What it is
      The question a token asks of the others. In the sentence "The cat sat on the mat because it was tired", the Query of "it" asks: what does "it" refer to?
      When to use it
      Computed fresh for the current token only; it is never cached.
    2. K: Key

      What does each word hold?

      What it is
      The matching label of each earlier token. The Query is compared with the Keys of cat, sat, mat and tired to find which ones are relevant. K answers "how do I identify relevant information?".
      When to use it
      Stored in the KV cache so past tokens never recompute it.
    3. V: Value

      The actual information

      What it is
      The content a token hands over once it is judged relevant: the information inside the book. After matching, the model retrieves the Values of the matching tokens, mostly "cat" in the example.
      When to use it
      Stored in the KV cache next to K.
    4. Q K V in one table

      Question, label, content

      What it is
      Q is the question, K the matching label, V the actual information. Q searches, K finds, V retrieves. Library version: Q is what I want, K is what each book says it contains, V is what is written inside.
      When to use it
      A memory aid for interviews: Question, Matching label, Actual information.
    5. Why three vectors

      Need, identify, retrieve

      What it is
      The model must separate three jobs: what information it needs (Q), how to identify relevant information (K), and what information to retrieve (V). With one shared vector, the signal used to match could not differ from the content passed on.
      When to use it
      The standard follow-up question after "explain Q, K, V".
    6. Scores and softmax

      Turn matches into weights

      What it is
      Each Query is multiplied with every Key to get a score; softmax turns the scores into weights that sum to 1; the output is the weighted sum of the Values. Relevant tokens such as "cat" get most of the weight.
      When to use it
      The formula behind every attention layer: softmax(QKᵀ / √d) · V.
      In code
      attention = softmax(Q @ K.T / sqrt(d)) @ V
    7. Multi-head attention

      Several searches in parallel

      What it is
      The model runs many attention searches side by side, each with its own Q, K and V projections, so one head can track grammar while another tracks who "it" refers to. Their outputs are joined. Variants share K and V across heads (MQA, GQA) to shrink the KV cache.
      When to use it
      Reading a model card: "8 KV heads" means GQA and a much smaller KV cache.
    8. FlashAttention

      Fewer trips to HBM

      What it is
      Computes attention in tiles that stay in fast on-chip memory instead of writing the full score matrix to HBM. Same result, far less memory traffic, and long contexts become practical.
      When to use it
      Default in modern serving stacks; the reason long prompts do not explode memory.
  3. KV cache

    Remember K and V

    What it is
    The KV cache stores the Keys and Values of every earlier token so they do not need to be recalculated for each new token. Only the new token's Q, K and V are computed; its Q is matched against the cached Ks and the cached Vs are read back.
    When to use it
    The reason generation speed does not collapse as the answer grows, and the reason memory does.
    1. Without it

      Recompute everything

      What it is
      Without a cache, producing token 500 would redo the K and V maths for tokens 1 to 499. Generation cost would grow with the square of the length instead of staying close to flat per token.
      When to use it
      Explaining why every inference engine has a KV cache.
    2. Memory it takes

      Grows with every token

      What it is
      The cache grows with context length and with the number of simultaneous requests, per layer and per KV head. It lives in GPU memory next to the weights and is what runs out first at long context or high concurrency. The exact formula is in the LLMs & VRAM map.
      When to use it
      Capacity planning: a model that "fits" can still fail with ten concurrent users.
      Key figures
      • KV cache size = 2 × layers × KV heads × head dimension × precision bytes × sequence length × batch.Source: NVIDIA blog, Mastering LLM Techniques: Inference Optimization
    3. PagedAttention

      Cache in small blocks

      What it is
      vLLM stores the KV cache in fixed-size blocks that do not need to be contiguous, like virtual memory pages. This removes fragmentation and wasted reserved space, so more requests fit in the same GPU.
      When to use it
      Higher throughput on a given GPU without changing the model.
    4. Prefix caching

      Reuse a shared prompt

      What it is
      When many requests start with the same system prompt or document, the cached K and V of that prefix are reused instead of recomputed. Providers sell the same idea as prompt caching.
      When to use it
      Chatbots with a long fixed system prompt, RAG over one document, agents with big tool lists.
    5. Quantise and offload

      Shrink or spill the cache

      What it is
      The cache can be stored in FP8 instead of FP16 to halve it, or moved to CPU RAM when the GPU is full. Offloading crosses PCIe on every use, so it trades speed for capacity.
      When to use it
      Squeezing more concurrent users or a longer context into the same card.
      In code
      vllm serve <model> --kv-cache-dtype fp8 --max-model-len 32768
    6. What a token is

      A piece of text

      What it is
      A token is the small piece of text an LLM processes: a whole word, part of a word, punctuation, a number or a symbol. "The cat is sitting on the table." is roughly The / cat / is / sitting / on / the / table / . (illustrative: real boundaries depend on the tokenizer). The model works on numerical representations of tokens, and every token adds to attention work, context-window use, generation time and memory.
      When to use it
      Estimating cost and memory: both scale with the number of tokens, not words.
    7. How important is this token

      Q scored against every K

      What it is
      To decide how important an earlier token is for the one being generated, the model scores the new token's Query against that token's Key (QKᵀ divided by √d_k), then softmax turns all scores into weights that sum to 1. A high weight means "pay attention to this token", and its Value is mixed into the output in that proportion.
      When to use it
      Answering "how does the model know which words matter" in plain terms.
      In code
      Attention(Q, K, V) = softmax(Q @ K.T / sqrt(d_k)) @ V
    8. The cache formulas

      K_t, V_t and the cache

      What it is
      For each new token t the model computes K_t = W_K · x_t and V_t = W_V · x_t from the token's hidden state x_t, and appends them: K_cache = [K_1 … K_t], V_cache = [V_1 … V_t]. The next step is Attention_t = softmax(Q_t · K_cacheᵀ / √d_k) · V_cache, so earlier tokens are never recomputed: only Q_t, K_t and V_t are new.
      When to use it
      Showing in an interview exactly what is cached (K and V) and what is not (Q).
      In code
      K_t = W_K @ x_t
      V_t = W_V @ x_t
      K_cache = [K_1, K_2, ..., K_t]
      V_cache = [V_1, V_2, ..., V_t]
      Attention_t = softmax(Q_t @ K_cache.T / sqrt(d_k)) @ V_cache
    9. Memory formula

      2 × L × B × S × H × D

      What it is
      For standard multi-head attention: KV memory = 2 × L × B × S × H_kv × D_h × bytes. The 2 is Key plus Value, L the layers, B the batch size, S the sequence length in tokens, H_kv the number of KV heads, D_h the dimension per head, and bytes the size per element (FP16 = 2).
      When to use it
      Sizing GPU memory for a context length and a number of users.
      In code
      kv_bytes = 2 * L * B * S * H_kv * D_h * bytes
    10. Worked example

      8K tokens = 1.05 GB

      What it is
      A model with 32 layers, 8 KV heads, head dimension 128 and FP16, one sequence of 8,000 tokens: 2 × 32 × 1 × 8000 × 8 × 128 × 2 = about 1.05 GB. At 32,000 tokens the cache is about 4.19 GB, four times larger. This is the cache of one sequence, without weights or other GPU allocations.
      When to use it
      Why long context windows need so much VRAM: the cache grows linearly with tokens and with concurrent users.
      In code
      python -c "print(2*32*1*8000*8*128*2/1e9)"   # 1.048576 GB
      python -c "print(2*32*1*32000*8*128*2/1e9)"  # 4.194304 GB
  4. Inside one GPU

    Compute and HBM

    What it is
    Within a single GPU the cores talk to HBM (high-bandwidth memory) stacked right next to the chip. This is the fastest link in the whole system and where weights and the KV cache live.
    When to use it
    Level one of the ladder: GPU compute to HBM.
    1. HBM

      Memory on the package

      What it is
      Stacks of DRAM dies connected to the GPU through a very wide interface, giving terabytes per second instead of the tens to low hundreds of GB/s of ordinary system RAM. It is expensive and limited in size, which is why GPU memory is the scarce resource.
      When to use it
      Explaining why a 80 GB card costs far more than 80 GB of server RAM.
      Key figures
      • H100 SXM: 80 GB of memory at 3.35 TB/s.Source: NVIDIA H100 datasheet
    2. Registers, SRAM, HBM

      Small and fast to big

      What it is
      Registers and on-chip shared memory (SRAM) are tiny and extremely fast; HBM is large and slower; system RAM is larger and slower still. Fast kernels such as FlashAttention keep data in the small tiers as long as possible.
      When to use it
      Why the same maths can run several times faster with a better memory access pattern.
    3. Bandwidth sets decode speed

      Bytes per token

      What it is
      Each generated token reads the active weights and the KV cache from HBM once, so the ceiling on tokens per second is roughly memory bandwidth divided by bytes read per token. A single stream cannot go faster than that, whatever the core count.
      When to use it
      Back-of-the-envelope speed estimates before renting a GPU.
    4. When it does not fit

      Shard across GPUs

      What it is
      When weights plus the KV cache exceed one GPU's memory, the model is split over several GPUs. From that moment the speed of the links between GPUs decides how well it runs, which is the rest of this map.
      When to use it
      The bridge from single-GPU to multi-GPU serving.
  5. Why PCIe is not enough

    The general-purpose bus

    What it is
    PCIe is the standard bus that connects a GPU to the CPU, RAM, disks and network cards. It was designed for general-purpose devices, so its bandwidth is a small fraction of what GPU memory or a GPU-to-GPU link provides.
    When to use it
    The answer to "why not just use PCIe between GPUs?".
    1. The numbers

      x16 slot against HBM

      What it is
      A PCIe 5.0 x16 slot gives about 64 GB/s in each direction (128 GB/s both ways), while HBM on a data-centre GPU delivers terabytes per second. Moving data over PCIe is roughly 25 to 50 times slower than reading it from HBM.
      When to use it
      Putting the gap in one sentence in an interview.
      Key figures
      • PCIe 5.0 x16: 64 GB/s per direction, 128 GB/s bidirectional.Source: PCI-SIG PCIe 5.0 specification figures
      • H100 SXM memory bandwidth: 3.35 TB/s.Source: NVIDIA H100 datasheet
    2. Detours through the CPU

      GPU to RAM to GPU

      What it is
      Without a direct GPU link, data between two GPUs on PCIe goes through a root complex and often through host memory, with extra copies and CPU involvement. Lanes are shared with disks and network cards, so concurrent transfers compete.
      When to use it
      Spotting why 4 PCIe-only GPUs scale worse than 4 NVLink GPUs.
    3. Offloading to RAM

      Capacity at a speed price

      What it is
      Keeping weights or the KV cache in CPU RAM lets a model run on a small GPU, but every token must pull the offloaded part across PCIe. Generation drops from HBM speed to PCIe speed for that part.
      When to use it
      Hobby and edge setups where fitting matters more than tokens per second.
      In code
      llama-server -hf <repo>:Q4_K_M -c 16384 -ngl 20
    4. CPU and RAM still matter

      Feeding and control

      What it is
      The CPU still tokenises, schedules batches, launches GPU kernels and loads weights from disk over PCIe at start-up. PCIe is right for that control and loading traffic; it is wrong for the constant tensor exchange between GPUs.
      When to use it
      Not over-correcting: PCIe is fine for what it was built for.
  6. Between servers

    InfiniBand, RoCE, RDMA

    What it is
    When a model or a training job spans several servers, GPUs must exchange tensors across the network. Ordinary TCP/IP over Ethernet is too slow and CPU-hungry for that, so AI clusters use InfiniBand or RoCE with RDMA.
    When to use it
    Level three of the ladder: between servers.
    1. InfiniBand

      Lossless HPC fabric

      What it is
      A network built for high-performance computing: very low latency, high bandwidth, lossless by design and with RDMA built in. It is the standard fabric of large GPU training clusters.
      When to use it
      Multi-node training and large multi-node inference where every microsecond counts.
    2. RoCE

      RDMA over Ethernet

      What it is
      RDMA over Converged Ethernet carries RDMA on Ethernet hardware, so a data centre can keep its Ethernet switches. It needs careful flow control and congestion settings to behave like a lossless network.
      When to use it
      Clouds and enterprises that standardise on Ethernet but need RDMA speeds.
    3. RDMA

      Memory to memory, no CPU

      What it is
      Remote Direct Memory Access lets a network adapter read or write registered memory on another machine directly, with minimal CPU involvement. It cuts latency and CPU overhead, which matters for distributed AI where GPUs constantly exchange tensors.
      When to use it
      The technology behind both InfiniBand and RoCE performance.
    4. TCP: the normal path

      Through the OS stack

      What it is
      TCP transfers data through the traditional operating system networking stack, which adds CPU overhead, kernel processing and often extra memory copies. Fine for web traffic and APIs, costly for a flood of tensors.
      When to use it
      The baseline to compare RDMA against.
    5. GPUDirect RDMA

      NIC reads GPU memory

      What it is
      Lets the network card read and write GPU memory directly, skipping the copy through host RAM and the CPU. Tensors travel GPU to NIC to network to NIC to GPU.
      When to use it
      Multi-node jobs where host-memory copies would waste bandwidth.
    6. Ethernet + TCP/IP

      General networking

      What it is
      The standard communication layer for everything else: user requests, API calls, storage, monitoring. Still the right choice for most traffic even in an AI cluster.
      When to use it
      Front-end and control traffic, while the RDMA fabric carries tensors.
    7. RDMA does not replace TCP

      Use it where it pays

      What it is
      Most applications still use TCP. RDMA is especially valuable for performance-critical communication such as distributed GPU workloads, where the CPU and latency savings add up.
      When to use it
      The one-line caveat that makes an interview answer sound experienced.
  7. NCCL

    Library for GPU collectives

    What it is
    NVIDIA's Collective Communications Library. Frameworks such as PyTorch and engines such as vLLM call it to exchange tensors; it detects the topology and picks the best transport (NVLink, PCIe, InfiniBand or RoCE with RDMA, or plain sockets) by itself.
    When to use it
    The next concept after the hardware: how software uses these links.
    1. All-reduce

      Sum and share to all

      What it is
      Every GPU contributes a tensor, the tensors are summed, and every GPU receives the total. It is the main collective of tensor parallelism and of gradient averaging in data-parallel training.
      When to use it
      The operation to name when asked what travels over NVLink.
    2. All-gather, reduce-scatter

      Collect or split pieces

      What it is
      All-gather lets every GPU collect the pieces held by all the others; reduce-scatter sums tensors and leaves each GPU with one slice of the result. Together they make an all-reduce and are used by sharded training.
      When to use it
      Sharded optimisers and fully sharded data parallel (FSDP) training.
    3. All-to-all

      Everyone sends to everyone

      What it is
      Each GPU sends a different slice to every other GPU. Mixture-of-experts models use it to route tokens to the GPU that holds the chosen expert and to bring results back.
      When to use it
      Serving large MoE models across several GPUs or nodes.
    4. Transport choice

      NVLink, PCIe, IB, sockets

      What it is
      NCCL prefers NVLink inside a server, then PCIe, and between servers uses InfiniBand or RoCE with RDMA (and GPUDirect where available), falling back to TCP sockets. A slow fallback is a common reason for a mysteriously slow cluster.
      When to use it
      Debugging with NCCL_DEBUG=INFO to see which transport was chosen.
      In code
      NCCL_DEBUG=INFO python train.py
    5. Tensor parallelism

      Split each layer

      What it is
      Each layer's matrices are split across GPUs that work on the same token together. Lowest latency per request but the heaviest communication: an all-reduce per layer. Keep it inside one NVLink domain.
      When to use it
      One big model on 2 to 8 GPUs of the same server.
    6. Pipeline parallelism

      Layers in stages

      What it is
      Consecutive groups of layers sit on different GPUs or servers and pass activations forward like an assembly line. It sends little data between stages, so it tolerates slower links such as InfiniBand or PCIe, at the cost of idle gaps (bubbles).
      When to use it
      Models too big for one server, split across nodes.
    7. Data parallelism

      Copies of the model

      What it is
      Several replicas of the model each handle different requests or batches. For serving it needs almost no GPU-to-GPU traffic; for training the gradients are all-reduced after each step.
      When to use it
      Scaling throughput once one replica already fits.
    8. Expert parallelism

      Experts on different GPUs

      What it is
      The experts of a mixture-of-experts model are spread across GPUs and tokens travel to them with all-to-all. Heavy on the network, so large deployments pair it with fast NVLink or InfiniBand.
      When to use it
      Frontier-size open MoE models that do not fit on one node.
  8. Cluster architectures

    Six ways to serve

    What it is
    There are several ways to lay out an LLM inference cluster, and the right one depends on four things: prompt length (input tokens), generation length (output tokens), number of concurrent users, and GPU memory, memory bandwidth and network bandwidth. Splitting prefill from decode is one option, not the best for every workload.
    When to use it
    Start from the comparison table under the map, then open the architecture that fits.
    1. 1. Combined

      Prefill + decode together

      What it is
      One GPU node handles prefill and decode: the prompt arrives, the GPU processes it, generates the tokens and keeps the KV cache locally. No KV transfer, simple scheduling, easy to deploy and debug; but prefill and decode compete for the same GPU and cannot be scaled separately.
      When to use it
      Small and medium deployments, low concurrency, short prompts, or when simplicity matters most.
    2. 2. Disaggregated

      Separate prefill / decode

      What it is
      Separate GPU pools: prefill nodes process prompts, the KV cache is transferred, decode nodes generate the answer. Each pool scales on its own and can use a different GPU configuration, with better control of time to first token and token latency. The price is KV transfer overhead, harder scheduling and a need for fast networking.
      When to use it
      High concurrency, long prompts, sustained traffic and predictable performance targets.
    3. 3. Data parallel

      Identical replicas

      What it is
      Several identical replicas, each running prefill and decode on its own; a load balancer spreads the requests. Easy horizontal scaling, request isolation, good fault isolation and no KV transfer between replicas. Every replica needs the full weights, and memory is wasted if traffic is uneven.
      When to use it
      Many independent users and enough GPUs to replicate the model.
    4. 4. Tensor parallel

      One model over GPUs

      What it is
      One model is split across GPUs: each computes part of every matrix operation and the results are synchronised with collective communication. Allows models larger than one GPU and can cut latency, but needs GPU-to-GPU traffic and usually NVLink or a similarly fast interconnect.
      When to use it
      A model that does not fit one GPU, inside one node.
    5. 5. Pipeline parallel

      Layers in stages

      What it is
      Each GPU owns a group of layers (for example 1-8, 9-16, 17-24, 25-32) and activations flow from stage to stage. It spreads weights across nodes and suits very large models, but leaves pipeline bubbles where GPUs idle and needs careful scheduling.
      When to use it
      A large model across several nodes when tensor parallelism over the network is too chatty.
    6. 6. Hybrid

      Combine several

      What it is
      Combines the others, for example a prefill pool and a decode pool that each use data plus tensor parallelism, linked by RDMA, with a KV-cache-aware scheduler placing sessions. Independent scaling, large models and good utilisation at scale, at the cost of complex infrastructure, scheduling and networking.
      When to use it
      Large inference providers with high concurrency and mixed workloads.
    7. Prefill vs decode

      Two different workloads

      What it is
      Prefill reads the whole prompt at once: compute-bound, sets time to first token (TTFT), produces the KV cache. Decode generates one token at a time: memory-bandwidth-bound, sets the time between tokens, and keeps growing the cache. Mixing them on one GPU lets a long prefill stall everybody's decode, which is the reason to separate them.
      When to use it
      The argument for disaggregation: tune each pool to its own bottleneck.
  9. Kubernetes and Helm setup

    Prefill and decode pools

    What it is
    A sensible layout for a Kubernetes cluster: one Deployment for the prefill pool, one for the decode pool, a router in front, GPU nodes labelled and tainted for inference, and an RDMA-capable network between the two pools. Helm packages the pools as two values blocks of one release so they scale and roll out independently.
    When to use it
    Open the diagram under the map for the full picture.
    1. Topology

      Router, two pools, fabric

      What it is
      Client, ingress and a router/gateway sit on CPU nodes. Prefill pods (few, large, compute-heavy) and decode pods (many, memory-heavy) sit on GPU nodes. The router sends each prompt to a prefill pod, the KV cache moves to a decode pod over the RDMA fabric, and the decode pod streams the tokens back.
      When to use it
      Drawing the architecture on a whiteboard in five boxes.
    2. GPU scheduling

      Device plugin and taints

      What it is
      The NVIDIA device plugin (or the GPU Operator that installs it) exposes GPUs as the schedulable resource nvidia.com/gpu. Label GPU nodes by role, taint them so only inference pods land there, and request whole GPUs in the pod limits. A tensor-parallel pod needs all its GPUs on the same node, on NVLink.
      When to use it
      Keeping decode pods off prefill nodes and CPU-only workloads off GPU nodes.
      In code
      kubectl label node <gpu-node> inference/role=prefill
      kubectl taint node <gpu-node> nvidia.com/gpu=present:NoSchedule
      resources:
        limits:
          nvidia.com/gpu: 4
    3. Helm values

      One release, two pools

      What it is
      One chart with two worker blocks in values.yaml: prefill and decode each get their own replicas, GPU count, parallelism flags, nodeSelector, tolerations and resource limits, so each pool can be changed and rolled out independently. This is an illustrative layout, not a published chart; real projects (llm-d, NVIDIA Dynamo) ship their own charts and operators.
      When to use it
      A starting point for a values file when you build your own chart.
      In code
      # values.yaml (illustrative)
      model: <model-id>
      prefill:
        replicas: 2
        gpusPerPod: 4
        nodeSelector: { inference/role: prefill }
        args: ["--tensor-parallel-size", "4"]
      decode:
        replicas: 6
        gpusPerPod: 2
        nodeSelector: { inference/role: decode }
        args: ["--tensor-parallel-size", "2"]
      router:
        replicas: 2
      # install
      helm upgrade --install llm ./chart -n inference -f values.yaml
    4. KV transfer

      NIXL between the pools

      What it is
      vLLM moves the KV cache between prefill and decode workers through a connector; the NIXL connector is configured with --kv-transfer-config. In the llm-d guide the decode instance pulls the KV blocks over RDMA with NIXL, which also works over TCP, but InfiniBand, RoCE or EFA is strongly recommended for production. In current vLLM versions the router decides which instance is the prefiller and which the decoder.
      When to use it
      Choosing the fabric: TCP for a lab, RDMA for anything with real traffic.
      In code
      vllm serve <model> --kv-transfer-config '{"kv_connector":"NixlConnector","kv_role":"kv_both"}'
      VLLM_NIXL_SIDE_CHANNEL_PORT=5600
      Key figures
      • llm-d P/D: two vLLM Deployments in one InferencePool, labelled by role; the decode instance pulls KV over RDMA with NIXL.Source: Documentation of llm-d, prefill/decode disaggregation path
    5. RDMA in pods

      Expose the NIC to pods

      What it is
      Pods only see the RDMA network if the cluster exposes it: a secondary network interface (for example through Multus), an RDMA or SR-IOV device plugin that advertises the NIC as a resource, and pod settings that allow locked memory. Without this NCCL and NIXL fall back to TCP sockets and the cluster looks mysteriously slow.
      When to use it
      Checking with NCCL_DEBUG=INFO that the transport is IB or RoCE, not sockets.
    6. Router

      KV-aware request routing

      What it is
      A plain round-robin Service throws away the cache. A KV-aware router sends a request to the pod that already holds its prefix, balances prefill against decode load and ties the two halves of one request together. llm-d does this through the Gateway API Inference Extension and an InferencePool; NVIDIA Dynamo has its own KV-aware router fed by cache events from the workers.
      When to use it
      Multi-turn chat and shared system prompts, where prefix reuse saves most prefill work.
    7. Autoscaling each pool

      Different signals

      What it is
      Scale the pools on different signals, which is the point of splitting them: prefill on request queue length and time to first token; decode on running sequences, KV cache usage and inter-token latency. Use HPA or KEDA on the engine metrics, and scale slowly: a new GPU pod needs minutes to pull the image and load the weights.
      When to use it
      Avoiding both idle decode GPUs and a prefill queue that makes first tokens slow.
    8. llm-d

      Kubernetes-native vLLM

      What it is
      An open-source Kubernetes-native distributed inference framework that coordinates a fleet of vLLM instances. Its "well-lit paths" are reference architectures, including prefill/decode disaggregation, intelligent routing and KV-cache-aware scheduling.
      When to use it
      The quickest route to a tested prefill/decode layout on Kubernetes with vLLM.
    9. NVIDIA Dynamo

      Operator, router, Grove

      What it is
      NVIDIA's inference framework for disaggregated serving. On Kubernetes it ships an operator with custom resources (DynamoGraphDeployment and others), a KV-aware router, NIXL for the KV transfer, Helm charts and Grove for gang scheduling and topology-aware placement of multi-node deployments.
      When to use it
      Large multi-node deployments on NVIDIA hardware where topology-aware placement matters.
  10. The bandwidth ladder

    Four levels, fast to slow

    What it is
    Each step out from the GPU core costs bandwidth and adds latency, so the design rule is to keep chatty traffic as close to the GPU as possible: HBM first, NVLink inside a server, InfiniBand or RoCE between servers, plain Ethernet and TCP for the rest.
    When to use it
    A one-slide summary of the whole map.
    1. Within one GPU

      GPU compute to HBM

      What it is
      GPU compute talks to HBM memory: terabytes per second.
      When to use it
      Weights and KV cache live here.
    2. Between GPUs in a server

      NVLink / NVSwitch

      What it is
      NVLink and NVSwitch provide high-speed GPU-to-GPU communication inside one machine.
      When to use it
      Tensor parallelism and expert parallelism inside a node.
    3. Between servers

      InfiniBand / RoCE + RDMA

      What it is
      InfiniBand or RoCE with RDMA gives fast inter-server communication with little CPU involvement.
      When to use it
      Multi-node inference and training, pipeline parallelism across nodes.
    4. General networking

      Ethernet + TCP/IP

      What it is
      Ethernet with TCP/IP carries standard communication: users, APIs, storage and monitoring.
      When to use it
      Everything that is not a tensor exchange.
    5. Interview: TCP vs RDMA

      A 30-second answer

      What it is
      TCP goes through the OS networking stack, which adds CPU overhead, kernel processing and extra memory copies. RDMA lets network adapters move data directly between registered memory regions on different machines with minimal CPU involvement, cutting latency and overhead. That matters for multi-node GPU training and inference, where GPUs constantly exchange tensors. RDMA does not replace TCP for everything.
      When to use it
      Inference-engineering interviews; the follow-up topic is NCCL.
    6. Which fabric for which job

      Match link to traffic

      What it is
      A 7B model on one GPU needs none of this. A 70B model on 4 to 8 GPUs of one server wants NVLink for tensor parallelism. A model larger than one server wants InfiniBand or RoCE and pipeline or expert parallelism across nodes. Always measure: link speed is a ceiling, not a result.
      When to use it
      Deciding hardware for a client deployment before quoting it.

KV cache growth and how to shrink it

The cache grows linearly with the number of tokens. For a model with 32 layers, 8 KV heads, head dimension 128 and FP16 it is 1.05 GB at 8,000 tokens and 4.19 GB at 32,000 tokens, per sequence. These are the main ways to make it smaller.

KV cache size against context length KV cache per sequence (GB) 0.52 4K tokens 1.05 8K tokens 2.10 16K tokens 4.19 32K tokens 8.39 64K tokens Linear growth: doubling the context doubles the cache. Orange bars are the worked example (1.05 GB and 4.19 GB).
KV cache size for one sequence against context length (FP16, 32 layers, 8 KV heads, head dimension 128).
TechniqueWhat it doesEffect
FP16Stores each value in 2 bytesThe baseline
INT8 / FP8Stores each value in about 1 byteAbout half the memory of FP16
INT4Stores each value in about 0.5 byteAbout a quarter of FP16, with some quality risk
GQASeveral query heads share one set of KV headsFewer KV heads, so a proportionally smaller cache
Sliding windowKeeps only a limited recent contextThe cache stops growing past the window
PagedAttentionManages the cache in blocks instead of one large contiguous allocationLess fragmentation and waste, more concurrent requests

The bandwidth ladder as a graph

Each step away from the GPU cores costs bandwidth. Peak vendor figures, GB/s, on a linear scale.

Bandwidth ladder: PCIe, NVLink, HBM Peak bandwidth, GB/s (vendor figures) PCIe 5.0 x16 128 GB/s NVLink 4 · H100 900 GB/s NVLink 5 · Blackwell 1,800 GB/s HBM3 · H100 SXM 3,350 GB/s PCIe is the general-purpose bus; NVLink links GPUs directly; HBM is memory on the GPU package. PCIe and NVLink are bidirectional totals; peaks, not measured speeds.
Peak bandwidth: PCIe 5.0 x16 (bidirectional), NVLink 4 per H100 GPU, NVLink 5 per Blackwell GPU, and H100 HBM3 memory.

Six inference architectures compared

Pick by prompt length, generation length, concurrency, and GPU memory, memory bandwidth and network bandwidth.

ArchitectureBest forAdvantagesDisadvantagesUse when
1. Combined prefill + decodeSimplicityNo KV transfer, simple scheduling, easy to debugPrefill and decode compete for the GPU; cannot scale each stage aloneSmall or medium load, low concurrency, short prompts
2. Disaggregated prefill / decodeIndependent scalingDedicated resources, control of TTFT and token latency, different GPUs per stageKV transfer overhead, harder scheduling, needs fast networkingHigh concurrency, long prompts, sustained traffic, predictable targets
3. Data parallelismHorizontal scalingEasy to scale, request and fault isolation, no KV transferFull weights in every replica, KV duplicated across sessions, waste when traffic is unevenMany independent users and enough GPUs to replicate the model
4. Tensor parallelismLarge modelsFits models larger than one GPU, spreads compute, can cut latencyNeeds GPU-to-GPU traffic, communication overhead, benefits from NVLinkThe model does not fit one GPU, or you want speed inside a node
5. Pipeline parallelismSpreading layersSpreads weights and activations, can span nodes, suits very large modelsPipeline bubbles leave GPUs idle, stage-to-stage traffic, harder schedulingLarge models across nodes when tensor parallelism over the network is too heavy
6. HybridLarge production clustersIndependent scaling, large models, flexible allocation, good use at scaleComplex infrastructure, sophisticated scheduling, higher network and operating costLarge providers, high concurrency, mixed workloads

Prefill and decode: the request flow

Prefill reads the prompt and builds the KV cache; decode generates the tokens one by one. They stress different resources, so they can be given different GPUs and scaled separately.

Prefill and decode request flow Client prompt Router KV-aware Prefill pool Reads the whole prompt Compute-bound Builds the KV cache Sets time to first token Decode pool Generates token by token Memory-bandwidth-bound Reads and grows the KV cache Sets time between tokens KV cache RDMA Tokens streamed back to the client
A request through a disaggregated cluster: router, prefill pool, KV transfer over RDMA, decode pool, tokens streamed back.
PrefillDecode
What it doesProcesses the whole prompt at once and builds the KV cacheGenerates one token at a time, reading and growing the KV cache
Main limitCompute (matrix multiplications)Memory bandwidth and KV cache capacity
Latency it setsTime to first token (TTFT)Time between tokens
Scale onRequest queue length, TTFTRunning sequences, KV cache usage, inter-token latency
GPU choiceStrong compute, tensor parallelism inside a nodeLarge and fast memory, many replicas

Kubernetes and Helm topology

One layout that makes sense for a cluster: CPU nodes for the gateway and router, labelled GPU nodes for each pool, an RDMA fabric between them, and one Helm release with a values block per pool.

Kubernetes prefill and decode topology CPU nodes Ingress / AI gateway Router (KV-aware) Autoscaler (HPA / KEDA) Prefill pool GPU nodes, label role=prefill Pod 1 4 GPU · TP=4 Pod 2 4 GPU · TP=4 Few, large pods, compute-heavy nvidia.com/gpu: 4 per pod Decode pool GPU nodes, label role=decode Pod 1 2 GPU · TP=2 Pod 2 2 GPU · TP=2 Pod 3 2 GPU · TP=2 6 pods in the example (3 shown), memory-heavy nvidia.com/gpu: 2 per pod KV RDMA One Helm release: values.yaml with a prefill block, a decode block and a router block InfiniBand or RoCE fabric between the GPU nodes
Illustrative Kubernetes layout for prefill/decode disaggregation. Pool sizes are examples, not recommendations.
PieceRoleNotes
Ingress / gatewayTerminates TLS, authenticates, applies limitsCPU nodes; an AI gateway fits here
RouterPicks the prefill and decode pod, KV-cache awarellm-d (Inference Gateway) or the Dynamo router
Prefill DeploymentBuilds the KV cache from the promptFewer, larger pods; tensor parallel inside a node
Decode DeploymentGenerates tokens from the transferred cacheMore pods; scale on KV cache usage and latency
GPU node poolsHold the pods; labelled and tainted per roleNVIDIA device plugin or GPU Operator
RDMA fabricCarries the KV cache between poolsInfiniBand or RoCE; TCP works but is slow
AutoscalerHPA or KEDA on engine metrics, per poolScale slowly: model loading takes minutes

Sources, read 2026-11-19: the author's own study notes on Q/K/V, the KV cache, TCP against RDMA and the transport ladder; the NVIDIA H100 datasheet; NVIDIA's NVLink and Blackwell pages; the NCCL user guide; PCI-SIG PCIe 5.0 figures; the FlashAttention and PagedAttention papers; "Attention Is All You Need"; the vLLM NixlConnector guide and the llm-d and NVIDIA Dynamo documentation. Bandwidth numbers are vendor peak figures and real workloads reach less. Products and generations change: check the datasheet of the GPU you deploy.