KV Cache Sizing and Prefill-Decode Disaggregation for LLM Inference

Medium · Machine Learning · Machine Learning Engineer · Technical Screen

Prompt

In an ML infrastructure discussion on large language model (LLM) inference, walk through both the mechanics and quantitative systems trade-offs of KV caching and prefill-decode (PD) disaggregation for a decoder-only transformer. State concrete assumptions up front—model dimensions (layer count, query heads vs. key-value heads under multi-head or grouped-query attention, head size, numeric precision), prompt and output lengths, concurrency, latency objectives, and GPU/network hardware—and address two parts:

  1. KV cache mechanics and memory footprint: Explain exactly what tensors are stored per layer and head during autoregressive token generation, what intermediate quantities are intentionally discarded, and why caching accelerates decoding without changing outputs. Derive the byte formula per token and per request for your stated model configuration, compute concrete numbers, and discuss how KV capacity constrains decode batch size, long-context concurrency, and dynamic GPU memory allocation.
  2. Prefill-decode disaggregation: Contrast the prefill and decode stages in terms of hardware bottlenecks (compute-bound vs. memory-bandwidth-bound) and user-visible latency metrics (time to first token vs. time per output token). Explain how running both phases on shared GPUs creates latency interference, quantify the cross-GPU state transfer required when splitting prefill and decode into separate GPU pools (along with ways to overlap or shrink that transfer), and identify when a unified colocated pool remains the better engineering choice.

Scope & Expectations

  • Connect causal self-attention math to what the KV cache saves vs. discards, and compute exact per-token and per-request memory footprints from explicit transformer dimensions.
  • Show how HBM capacity left after model weights caps active token concurrency and motivates paged, non-contiguous cache management.
  • Contrast prefill and decode using arithmetic intensity (FLOPs/byte), linking each phase to TTFT or TPOT and explaining why colocated continuous batching causes latency spikes.
  • Evaluate PD disaggregation quantitatively—weighing phase isolation and independent pool tuning against KV-cache network transfer overhead, cluster scale, and workload shape.

Step-by-step walkthrough

  1. Pin down a concrete model, GPU, and latency metrics

    Every capacity and latency calculation in LLM serving depends on the model's exact tensor dimensions and the GPU running it. State a concrete reference configuration and workload out loud before writing any math:

    Model (Llama-3-8B shape, decoder-only transformer):
      n_layers = 32, d_model = 4096, head_dim = 128
      n_q_heads = 32 query heads, n_kv_heads = 8 key-value heads (GQA, 4 queries per KV head)
      ~8.0B parameters in bf16 (2 bytes/param)  ->  ~16.0 GB (~14.9 GiB) of model weights
    
    GPU (one 80 GB H100 SXM5):
      ~80 GiB usable HBM3 memory, ~3.35 TB/s HBM bandwidth, ~989 TFLOPS peak bf16 tensor compute
    
    Workload:
      2,000-token prompt  ->  500 generated output tokens
    

    (Grouped-query attention, or GQA, shares one key head and one value head across a small group of query heads—here 4 query heads per KV head—whereas classic multi-head attention, or MHA, uses 32 KV heads.)

    Tie every design choice to the two user-facing latency metrics:

    • TTFT (time to first token): elapsed time from request arrival until the first generated token appears. Driven by prefill (processing the input prompt).
    • TPOT (time per output token), also called inter-token latency: time gap between consecutive streamed output tokens. Driven by decode (generating one token at a time).
  2. How the KV cache works and what it leaves out

    During autoregressive generation (producing text one token at a time, feeding each chosen token back in to predict the next), a decoder-only transformer applies a causal mask—a rule ensuring token i can only look at tokens 1..i and never at future tokens i+1..t.

    At generation step t, self-attention at each layer only needs to compute the output for the single newest token at position t:

    Past tokens (1 .. t-1)          New token (position t)
    ----------------------          ----------------------
    k_1 .. k_{t-1}  (cached!)       q_t, k_t, v_t  (computed fresh for this 1 token)
    v_1 .. v_{t-1}  (cached!)             |
           \                              v
            +----> Append k_t, v_t ----> [k_1 .. k_t], [v_1 .. k_t]
                                          |
                                          v
                   out_t = softmax((q_t . K^T) / sqrt(head_dim)) . V
    

    Because of the causal mask, adding token t never alters the hidden states—or the key and value vectors k_i, v_i—of any earlier token i < t. Recomputing k_1..k_{t-1} and v_1..v_{t-1} on every step would repeat identical matrix multiplications hundreds of times. The KV cache saves (k_i, v_i) (with rotary position embeddings already applied to k_i) for every layer, every KV head, and every past token. Caching is mathematically exact, not an approximation.

    Notice what is deliberately not cached:

    • Past queries (q_1..q_{t-1}): step t only computes attention from q_t; earlier queries are never read again.
    • Past attention score rows: attention weights at step t depend on the brand-new q_t, so they are computed fresh in O(t) work instead of O(t^2).
    • Intermediate MLP / residual activations: their sole job for past tokens was producing k_i, v_i across the 32 layers, which are already stored in the cache.

    Count the saved matrix-multiply work in "token-forwards" (running 1 token through all 8B weights costs ~2 × 8.0B = 16 GFLOPs) for a 2,000-token prompt + 500 generated tokens:

    Without KV cache: step s (s = 0..499) re-runs all (2,000 + s) tokens from scratch
                      sum_{s=0}^{499} (2,000 + s) = 1,000,000 + 124,750 = 1,124,750 token-forwards
    
    With KV cache:    2,000 (prefill produces token 1) + 499 (1 token per later step)
                      = 2,499 token-forwards   -->  ~450x less matrix-multiply compute!
    
  3. Derive the KV cache memory formula per token and per request

    For every token in context, each of the n_layers layers stores 2 vectors (Key and Value) across n_kv_heads heads, each of length head_dim:

    bytes_per_token = 2 (K and V) * n_layers * n_kv_heads * head_dim * bytes_per_element
    
    def kv_bytes_per_token(n_layers, n_kv_heads, head_dim, bytes_per_element=2):
        # 2 tensors (Key + Value) stored at every transformer layer for each KV head.
        return 2 * n_layers * n_kv_heads * head_dim * bytes_per_element
    
    
    gqa_per_tok = kv_bytes_per_token(32, 8, 128, 2)    # 131,072 B = 128 KiB / token
    mha_per_tok = kv_bytes_per_token(32, 32, 128, 2)   # 524,288 B = 512 KiB / token
    req_2500_tok = gqa_per_tok * (2_000 + 500)         # 327,680,000 B = 312.5 MiB / request
    

    Compare how model architecture choices change cache footprint (128K = 131,072 tokens):

    Model KV configuration                  Per token    4,096 tokens    128K (131,072) tokens
    ------------------------------------------------------------------------------------------
    32 layers,  8 KV heads (GQA), bf16       128 KiB        0.5 GiB             16.0 GiB
    32 layers, 32 KV heads (MHA), bf16       512 KiB        2.0 GiB             64.0 GiB
    80 layers,  8 KV heads (70B GQA), bf16   320 KiB       1.25 GiB             40.0 GiB
    

    Notice two crucial details: neither n_q_heads nor MLP width enters this formula, and switching from 32 KV heads (MHA) to 8 KV heads (GQA) shrinks the KV cache by 4x (512 KiB -> 128 KiB per token).

  4. How KV cache size governs batch size and GPU memory

    Let us budget our single 80 GB H100 (note on units: JEDEC GPU HBM "80 GB" is binary 80 GiB, roughly 79.6 GiB usable after ECC/firmware, whereas parameter counts like 8B × 2 B = 16.0 GB ≈ 14.9 GiB, HBM bandwidth 3.35 TB/s, and NIC speeds are decimal):

    Usable HBM (~80 GiB) - weights (~15 GiB) - activations/CUDA/workspace (~10 GiB) = ~55 GiB for KV cache
    
    GQA (128 KiB/token):  55 GiB / 128 KiB = 450,560 tokens  ->  110 sequences of 4,096 tokens (or ~3 of 128K)
    MHA (512 KiB/token):  55 GiB / 512 KiB = 112,640 tokens  ->   27 sequences of 4,096 tokens
    

    That token budget creates four operational rules for LLM serving:

    • KV cache memory—not FLOPS—caps the decode batch size. Because higher decode batch sizes unlock higher GPU throughput (next step), shrinking bytes per token directly multiplies tokens/second per dollar.
    • Long contexts consume massive concurrency. One 128K-token conversation occupies the exact same 16 GiB of KV cache as 32 concurrent 4K-token chats.
    • Output lengths are unknown ahead of time. Pre-reserving a contiguous 4,096-token slab for a request that finishes after 600 tokens wastes 85% of reserved RAM; allocating variable-sized contiguous chunks fragments GPU memory. Modern engines (PagedAttention in vLLM) instead allocate fixed-size non-contiguous blocks (such as 16 tokens per block) on demand, admit new requests only while free blocks remain, and preempt (swap blocks to CPU RAM or evict and recompute later) if active sequences simultaneously grow past 55 GiB.
    • Every cached byte is re-read on every decode step, so longer contexts slow down step time linearly.
  5. Compare prefill and decode: compute-bound vs bandwidth-bound

    Why do prefill and decode behave like two completely different workloads on the same GPU? Use arithmetic intensity—the ratio of floating-point operations performed per byte read from GPU HBM memory (FLOPs / byte).

    On our H100 (989 TFLOPS compute divided by 3.35 TB/s HBM bandwidth), the hardware balance point is 989 / 3.35 ≈ 295 FLOPs/byte:

    • Above ~295 FLOPs/byte, a kernel is compute-bound (tensor cores are saturated; faster memory would not help).
    • Below ~295 FLOPs/byte, a kernel is memory-bandwidth-bound (tensor cores sit idle waiting for bytes to stream in from HBM).

    Compare a single 2,000-token prefill against a batch-64 decode step (with 2,000 cached tokens per request):

    Phase 1 — Prefill (1 prompt of 2,000 tokens processed in parallel):
      Compute:  2 * 8.0e9 params * 2,000 tokens = 3.2e13 FLOPs
                At realistic ~50% MFU (~495 TFLOPS)  ->  ~65 ms
      HBM read: 16.0 GB of weights read once  ->  16.0 GB / 3.35 TB/s = ~4.8 ms
      Result:   ~2,000 FLOPs/byte  -->  COMPUTE-BOUND (~65 ms sets the floor on TTFT)
    
    Phase 2 — Decode (batch B = 64 active requests, 1 new token each, 2,000 cached tokens each):
      Compute:  2 * 8.0e9 params * 64 tokens = 1.02e12 FLOPs  ->  ~1-2 ms on tensor cores
      HBM read: 16.0 GB weights + (64 * 2,000 * 128 KiB = 16.8 GB decimal KV cache) = 32.8 GB
                32.8 GB / 3.35 TB/s = ~9.8 ms
      Result:   ~31 FLOPs/byte     -->  MEMORY-BANDWIDTH-BOUND (~9.8 ms sets the floor on TPOT)
    

    Notice why decode stays bandwidth-bound: reading each 2-byte weight performs 2 * B FLOPs (B FLOPs/byte, needing B ≈ 295 just for weights), and KV cache reads never amortize across requests—Request 1's cache is useless to Request 2! At batch = 1, streaming 16 GB of weights alone takes 4.8 ms/token (~208 tokens/s ceiling), leaving over 99% of the H100's compute idle.

  6. Why mixing prefill and decode on the same GPU spikes latency

    Production servers use continuous batching (adding newly arrived requests and retiring finished ones at every single token iteration rather than waiting for a whole batch to finish). When prefill and decode share one GPU pool, scheduling creates a tug-of-war between TTFT and TPOT:

    Normal decode iteration (64 active streams):      ~10 ms   -> smooth ~10 ms TPOT
    Next iteration Piggybacks an 8,000-token prefill: 2 * 8.0e9 * 8,000 = 1.28e14 FLOPs -> ~260 ms
                                                      (+ ~13% extra FLOPs from causal attention)
    Impact: ALL 64 streaming users suddenly freeze for ~260 ms (a 26x TPOT stutter!)
    

    Flipping the priority—refusing to run prefills while decodes are active—keeps TPOT smooth at 10 ms while forcing new arrivals to sit in a queue, blowing up TTFT.

    Chunked prefill softens this trade-off on a single GPU pool by slicing an 8,000-token prompt into 16 chunks of 512 tokens (~17 ms of compute each) and attaching one chunk per decode step. That caps the TPOT stutter around ~20-25 ms instead of 260 ms, though the 8,000-token prompt now spans 16 steps (~320+ ms TTFT), and decode steps still compete with prefill chunks for compute and HBM bandwidth.

  7. Prefill-decode disaggregation and the cost of shipping the cache

    Prefill-decode (PD) disaggregation (explored in systems such as DistServe and Splitwise) physically separates your GPUs into a Prefill Pool and a Decode Pool:

                        +--------------------+   Ship prompt KV cache   +--------------------+
    Incoming prompt --->|   Prefill Pool     |=========================>|    Decode Pool     |---> Streamed
    (2,000 tokens)      | (Compute-tuned,    |   (250 MiB over NVLink   | (Bandwidth-tuned,  |     tokens 2..500
         |              |  high tensor par.) |    or RDMA NIC, ~1-5 ms) |  large batch B)    |     (~10 ms TPOT)
         +------------->|  Emits Token 1     |                          +--------------------+
                        +--------------------+
    

    What disaggregation unlocks:

    • Zero cross-phase interference: an 8,000-token prefill never stalls active decode streams, and heavy decode batches never block incoming TTFT.
    • Phase-specific parallelism and hardware: prefill GPUs can use wider tensor parallelism (or compute-dense chips) to slash TTFT, while decode GPUs use minimal tensor parallelism and large batches (or high-HBM-capacity chips) to maximize tokens/sec/dollar.

    The price is network transfer of the prompt's KV cache from the prefill GPU to the chosen decode GPU:

    2,000-token prompt on our 8B GQA shape:  2,000 * 128 KiB = 250 MiB (262.1 MB decimal)
      - Intra-node NVLink (~450 GB/s one-way):       ~0.6 ms
      - Cross-node 400 Gb/s RDMA NIC (~50 GB/s):     ~5.2 ms   (~8% of the ~65 ms prefill)
      - Cross-node 200 Gb/s NIC (~25 GB/s):         ~10.5 ms
    Compare 2,000 tokens in MHA (512 KiB/tok):       1.0 GiB   -> ~21 ms at 50 GB/s
    Compare 8,000 tokens in 80-layer 70B GQA:       2.44 GiB   -> ~52 ms at 50 GB/s
    

    Three engineering techniques hide or shrink that transfer cost:

    1. Layer-by-layer pipelined streaming: transmit Layer l's KV slice (~7.8 MiB, ~0.16 ms at 50 GB/s) the instant Layer l finishes computing (~2 ms/layer), overlapping ~97% of the transfer behind Layers l+1..32.
    2. GPUDirect RDMA (Remote Direct Memory Access directly between GPU HBM and the network card, bypassing CPU RAM copies).
    3. FP8 KV quantization and prefix caching: quantizing cached K/V from bf16 to fp8 halves wire bytes (250 MiB -> 125 MiB), and skipping transfer of cached system-prompt blocks already resident on the decode pool cuts it further.
  8. Decide when to disaggregate and when to keep one shared pool

    Disaggregation adds real distributed-systems complexity: two pools to autoscale, transient double-buffering of KV memory during hand-off, decode-node memory routing, and re-prefill recovery if a decode node crashes. Keep colocated serving (with chunked prefill) when:

    • Cluster size or traffic is small: splitting 2 GPUs into 1 prefill + 1 decode wastes idle capacity whenever bursts skew toward one phase.
    • Prompts are short: a 200-token prompt prefills in ~6.5 ms—already shorter than one decode step—so interference barely registers.
    • Interconnects are slow relative to KV size: MHA models or long prompts across commodity Ethernet (10–25 Gb/s, 1.25–3 GB/s) spend 80–200+ ms shipping the cache, wiping out the TTFT win.
    • Workload is offline batch processing: when total nightly throughput is the sole metric and nobody watches interactive TPOT jitter, a single saturated pool with chunked prefill is simpler and avoids network traffic.
    • Prompt-to-output ratios swing wildly or prefix-cache hit rates are huge: if most prompt tokens already hit cached KV blocks, little prefill compute remains to isolate, and keeping cache blocks on one pool avoids cross-pool movement.

    Rule of thumb: disaggregate when you run multi-GPU production clusters with strict simultaneous TTFT and TPOT SLOs, medium-to-long prompts, and fast NVLink or RDMA networking.

Intuition & how it works

Think of generating an answer with a transformer in two everyday metaphors. First, the KV cache works like keeping margin notes while reading a long book: when you write sentence 51, instead of re-reading pages 1–50 from scratch to extract every fact again, you glance back at the compact summary notes (Key and Value vectors) you already jotted down when reading each earlier word. Second, prefill-decode disaggregation works like separating a restaurant's bulk prep kitchen (prefill, which chops a 2,000-word prompt all at once on big cutting boards) from its plating line (decode, which garnishes 64 customers' dishes one spoonful at a time)—if someone dumps a 50-pound sack of potatoes onto the plating counter mid-service, every diner's next bite stalls.

Without a KV cache, generating 500 output tokens after a 2,000-token prompt forces the GPU to re-run all earlier tokens at every single step (2,000 + 2,001 + ... + 2,499 = 1,124,750 token-forwards instead of 2,499, a 450x waste of matrix-multiply compute). Yet even with a KV cache, running prefill and decode together on the same GPUs creates a bottleneck clash: prefill crunches thousands of tokens in parallel (compute-bound), whereas decode generates just 1 token per request while streaming gigabytes of model weights and KV cache out of memory (memory-bandwidth-bound), so one arriving 8,000-token prompt freezes 64 active users' token streams from ~10 ms to ~260 ms.

Walk through our Llama-3-8B-style GQA model (32 layers, 8 KV heads, head_dim = 128, bf16 = 2 bytes): each token stores 2 × 32 × 8 × 128 × 2 = 131,072 bytes (128 KiB), so a 2,000-token prompt produces 250 MiB of KV cache during a ~65 ms prefill on a Prefill GPU, streams those 250 MiB layer by layer over NVLink (~0.6 ms) or 400 Gb/s RDMA (~5.2 ms) to a Decode GPU, and then decodes 500 tokens smoothly at ~10 ms per token alongside 63 other requests without ever stalling.

Key points

  • Exact caching enabled by causal masking: because a causal mask stops token i from attending to future positions > i, its per-layer (k_i, v_i) vectors never change as new tokens are appended; queries (q_i), attention weights, and MLP hidden states of past tokens are never needed again and are not cached.
  • KV cache sizing formula: bytes_per_token = 2 × n_layers × n_kv_heads × head_dim × bytes_per_element. For 32 layers, 8 KV heads (GQA, grouped-query attention), head_dim = 128, and bf16, this equals 128 KiB/token (0.5 GiB per 4,096 tokens, 16.0 GiB per 131,072 tokens—4x smaller than 32-head MHA's 512 KiB/token).
  • KV cache capacity caps decode concurrency: on an 80 GiB H100 (~15 GiB weights + ~10 GiB activations/runtime leaves ~55 GiB for cache), 55 GiB / 128 KiB fits 450,560 cached tokens (~110 4K sequences), requiring block-paged allocation and request preemption when active sequences grow full.
  • Prefill is compute-bound (sets TTFT); decode is bandwidth-bound (sets TPOT): measured by arithmetic intensity (FLOPs / byte vs. H100's ~295 FLOPs/byte balance point), a 2,000-token prefill runs at ~2,000 FLOPs/byte (~65 ms compute vs. ~4.8 ms weight read), whereas a batch-64 decode step reads 16.0 GB weights + 16.8 GB KV cache for only 1.02e12 FLOPs (~31 FLOPs/byte, ~9.8 ms HBM read).
  • Colocated continuous batching trades off TTFT against TPOT: mixing an 8,000-token prefill (~260 ms) into a ~10 ms decode loop spikes every user's TPOT (time per output token) by 26x; chunked prefill (splitting prompts into ~512-token slices) dampens the spike to ~20–25 ms at the cost of higher TTFT (time to first token).
  • PD disaggregation isolates phases at the cost of KV transfer: running separate Prefill and Decode GPU pools eliminates cross-phase interference and lets each pool tune parallelism independently, while requiring 250 MiB of prompt KV cache (for 2,000 tokens) to cross NVLink/RDMA—largely hidden when streamed layer by layer.
  • Keep a single shared pool when transfer or splitting hurts more than interference: small clusters, short prompts (<= 200 tokens), slow Ethernet interconnects, offline batch jobs without latency SLOs, and workloads dominated by local prefix-cache hits all favor colocated chunked prefill.

Common mistakes

  • Forgetting the factor of 2 (Key + Value) or plugging in n_q_heads instead of n_kv_heads: using 32 query heads on an 8-KV-head GQA model overestimates cache size and network transfer by 4x.
  • Claiming the KV cache stores past Q vectors or attention score matrices, or calling it lossy: past queries are never reused, attention scores depend on the newest q_t, and standard KV caching produces identical outputs to full recomputation.
  • Assuming faster GPU FLOPS speed up single-stream decode: at batch = 1, reading 16 GB of weights at 3.35 TB/s already enforces a ~4.8 ms/token (~208 tok/s) memory-bandwidth wall regardless of extra tensor-core TFLOPS.
  • Treating decode latency per step as independent of context length: every decode step reads the entire cached K and V of every sequence in the batch (64 × 2,000 × 128 KiB ≈ 16.8 GB decimal, matching the weight read itself!).
  • Pre-allocating contiguous max-context buffers per request: reserving 4,096 tokens up front for a request that stops at 600 tokens strands ~437 MiB of idle HBM per stream.
  • Mixing binary and decimal units across HBM, weights, and links: GPU HBM capacity ("80 GB") is binary (~80 GiB), whereas parameter counts (8B × 2 B = 16.0 GB ≈ 14.9 GiB), HBM bandwidth (3.35 TB/s), and NIC speeds (400 Gb/s = 50 GB/s) are decimal.
  • Pitching PD disaggregation as unconditionally superior: ignoring slow cross-rack networks, pool load imbalance when prompt/output lengths shift, and failed-decode re-prefill overhead.

Follow-up questions

  • How should an inference engine manage KV cache allocation across variable-length sequences to avoid GPU memory fragmentation and over-reservation? Use virtual-memory-style paged allocation (PagedAttention, introduced by vLLM): divide the ~55 GiB KV pool into uniform fixed-size physical blocks (for instance, 16 tokens = 2 MiB per block in our GQA model) and maintain a per-request block table mapping logical sequence positions to any free physical blocks in HBM. Because blocks are allocated one at a time as tokens are generated and every block has the exact same size, external fragmentation drops to zero and internal waste is bounded below 16 tokens per active request (when blocks run out mid-generation, the scheduler preempts low-priority sequences by swapping blocks to CPU RAM over PCIe or evicting and recomputing them later).
  • When thousands of user queries begin with an identical system prompt, how can you reuse prefill work and cached KV blocks across requests? Enable prefix caching (such as SGLang's RadixAttention or vLLM automatic prefix caching): hash each full KV block together with the chain of all preceding tokens (since causal attention at position i depends on tokens 0..i in exact order) and store shared blocks in a reference-counted radix tree or hash table with LRU eviction. If 100 concurrent requests share a 2,000-token system prompt, HBM usage for that prefix drops from 100 × 250 MiB = 24.4 GiB to a single 250 MiB copy and every request after the first skips ~65 ms of prefill compute—provided dynamic per-user text (timestamps, user names) is placed after the static system prompt and cache-aware routing sends matching prefixes to the same GPU pool.
  • If KV cache capacity bottlenecks decode concurrency, what architectural and runtime methods compress it, and what trade-offs do they introduce? At the model-architecture level (requiring pretraining or uptraining), GQA (4x shrink here), multi-query attention (1 KV head, 32x shrink with larger accuracy risk), DeepSeek-style multi-head latent attention (MLA, projecting K/V into a low-rank latent vector at the cost of extra projection compute), and sliding-window attention (capping cache per layer at window W, losing exact lookup beyond W) cut token footprint dramatically. At serving time (no retraining needed), quantizing cached K/V from bf16 to fp8/int8 (2x shrink, negligible quality loss with per-head scaling) or int4 (4x shrink, requires careful outlier calibration), attention-sink / heavy-hitter token eviction (bounding memory while risking long-range needle-in-a-haystack loss), and CPU RAM offloading (trading HBM space for PCIe bandwidth latency) shrink GPU memory immediately.
  • How do you provision the GPU ratio between prefill and decode pools and rebalance capacity dynamically when workload patterns shift? Size each pool independently from arrival rate and SLOs: at 20 req/s with 2,000-token prompts and 500-token outputs, prefill must digest 40,000 prompt tok/s (one GPU does 2,000 tok / 0.065 s ≈ 30,800 tok/s, or ~21,500 tok/s at 70% queueing utilization -> 2 Prefill GPUs), while decode must emit 10,000 output tok/s across 20 req/s × (500 × 0.010 s) = 100 concurrent sequences by Little's law (~50 sequences per GPU at ~10 ms/step = 5,000 tok/s and 50 × 2,500 × 128 KiB = 15.3 GiB peak KV cache -> 2 Decode GPUs). In production, autoscale Prefill on queue depth / p90 TTFT and Decode on KV-block utilization / p90 TPOT with cooldown hysteresis; since both pools hold identical model weights, an idle GPU can drain active requests and flip roles in seconds without reloading weights from disk (re-sharding over NVLink only if the two pools run different tensor-parallel degrees).

Follow-up questions

Similar questions

More Tower interview questions

All 3 Tower questions →