The KV cache (key-value cache) is the stored result of the attention layers for tokens already processed in a sequence. During autoregressive decode, each new token only needs a forward pass that depends on prior context; recomputing keys and values for all earlier tokens every step would be wasteful. The cache therefore holds, per layer and per sequence, the K and V tensors produced when those tokens were first seen (during prefill for the prompt, then extended one token at a time during decode). The objective is lower time per output token and lower FLOPs; the cost is GPU memory: cache size grows with batch × layers × heads × sequence_length × head_dim, and is often the limit on concurrent sessions or context length before model weights fill VRAM.
Architecturally, the KV cache is why LLM inference is memory-bound on the decode path whereas prefill is often compute-bound. A CPU serving stack without a cache would repeat full-sequence attention for every token—unusable at scale. GPUs hold the cache in HBM next to compute units; layout matters: contiguous buffers fragment when sequences differ in length, which motivated PagedAttention in vLLM (page tables for KV blocks, analogous to OS virtual memory). Prefix caching and KV-aware routing (as in llm-d) reuse blocks across requests that share system prompts or RAG prefixes, so duplicate work is not duplicated on every replica. Disaggregated prefill/decode even transfers KV state between specialized workers over high-speed networks. None of this replaces the model weights; it is ephemeral per session (unless explicitly offloaded to CPU DRAM or disk tiers in advanced setups).
Red Hat does not implement a proprietary KV cache format; support is through the inference stacks customers run on RHEL and OpenShift AI. vLLM on OpenShift uses PagedAttention and related features in supported serving images; llm-d adds cluster-level policies that route traffic to replicas with warm prefix cache. Red Hat documentation and reference architectures explain sizing GPU memory for context length, batching, and multi-tenant serving, and how platform choices (MIG, time-slicing, network for KV transfer) affect SLOs. Understanding KV cache behavior is prerequisite to capacity planning and to tuning Red Hat–backed inference deployments with NVIDIA or other accelerators.
