[KongchangAI]
ConceptKV cache offload

KV Cache

KV Cache (Key-Value Cache) is an optimization mechanism used during Transformer model inference to store the key and value vectors corresponding to each token in the attention computation. During autoregressive generation, the model reuses cached key-value pairs from previous tokens rather than recomputing them at each new generation step, significantly reducing redundant computation and improving inference efficiency. The mechanism trades increased GPU memory usage for faster inference speed and is a core optimization technique in large language model deployment.

Core Facts

Timeline (last 90 days)

Oct 13

The context cache (KV Cache) is the memory area that stores the Key and Value vectors of previous tokens during inference of Transformer-type models, and its size grows linearly with context length, batch size, and the number of model layers.

Unverified50%
Oct 13

Evicting the KV entries of low-value tokens has become a key means of reducing the cost of long-context inference.

Unverified50%
Oct 13

In traditional KV cache research, rules and implementations are tightly bound, so when method A outperforms method B, it is impossible to tell whether the eviction logic is smarter or the kernel is more hardware-friendly.

Unverified50%
Oct 13

The longer the context, the more the KV cache grows linearly, making memory bandwidth and capacity the main bottleneck for inference throughput.

Unverified50%
Oct 13

The KV cache is a core data structure in Transformer autoregressive inference, and its size is approximately 2 × number of layers × number of attention heads × head dimension × sequence length × precision bytes.

Unverified70%
Oct 13

The hardware requirements of large model inference differ fundamentally from those of training: training requires extremely large VRAM, extremely high bandwidth, and strong interconnect, while inference's bottleneck lies more in weight loading and KV Cache storage.

Unverified50%
Oct 13

Streaming loading schemes can be used in combination with techniques such as quantization, distillation, and KV Cache optimization; quantization shrinks the size of a single expert, while streaming loading solves the total-volume problem.

Unverified50%
Oct 12

DeepSeek V4.1 Flash lets the read and write paths share the same KV state: the read phase establishes and updates this memory, and the generation phase directly reuses it, rather than starting another cache.

Unverified50%
Oct 12

Agentic serving workloads have three notable characteristics: high interdependence between requests, unpredictable output length for a single request, and the need for the KV Cache to be reused or quickly switched among multiple calls.

Unverified50%
Oct 12

Atomic Agent chose to attach a rejection message ('you are responsible for planning, the Worker is responsible for writing') to the tool call's returned result rather than dynamically removing the write tool, in order to protect the local planning model's KV cache and avoid cache invalidation caused by a change in the prompt prefix.

Unverified50%

40 more timeline events

All Facts (20)

Verified

KV Cache reduces the computational complexity of self-attention from O(N²) to O(N) by caching already-computed Key-Value pairs in GPU memory, but memory usage grows linearly with sequence length.

90%
Verified

The VRAM occupied by KV Cache grows linearly with sequence length.

90%
Verified

PagedAttention is the core technology of the vLLM framework, which draws on the idea of operating system virtual memory management to store KV Cache in pages.

90%
Verified

KV Cache reduces inference complexity from O(n²) to O(n) by caching the already-computed Key/Value matrices.

90%
Verified

PagedAttention divides the KV cache into fixed-size pages allocated on demand, and can improve VRAM utilization by 2–4×.

85%
Verified

PagedAttention improves KV Cache memory utilization from below 40% to close to 100%.

85%
Verified

KV Cache is the persistent storage of intermediate states in the Transformer attention mechanism, recording the key and value vectors for each attention head's processed tokens across all layers, thereby skipping redundant forward propagation computations.

80%
Verified

Paged Attention (PagedAttention) is the core technology of vLLM, managing KV cache in blocks, while Flash Attention optimizes the memory access pattern of attention computation.

80%
Verified

Grouped Query Attention (GQA) and Multi-Query Attention (MQA) reduce KV cache memory usage during inference by having multiple query heads share the same group of key/value heads, and are standard optimizations in models such as Llama 3 and Mistral.

80%
Verified

Taking LLaMA-2 70B as an example, when processing a 4096-token context with a batch size of 32, the KV Cache can consume over 80 GB of memory.

80%
Verified

LLaMA-2-70B's KV Cache for a single request at a context length of 128K can occupy more than 160 GB of VRAM.

80%
Verified

The VRAM usage of KV Cache grows linearly with sequence length; for a 70-billion-parameter model using GQA, the KV Cache usage can reach tens of GB when processing 100,000 tokens.

80%
Verified

大型语言模型处理长上下文时,注意力机制的计算复杂度与序列长度的平方成正比

80%
Verified

以LLaMA-3 70B(80层、64头、每头128维)为例,单个token的KV Cache约占2.6MB(FP16精度),32K上下文的KV Cache总量约达83GB

80%
Verified

Transformer架构的自注意力机制在处理长序列时面临二次方复杂度的计算开销,上下文长度翻倍则计算量增长四倍

80%
Verified

KV Cache是Transformer架构的核心推理优化机制,其显存占用量会随序列长度和并发批次线性增长

80%
Verified

PagedAttention技术借鉴操作系统虚拟内存的分页思想,将KV Cache切分为固定大小的物理块动态分配

80%
Verified

KV Cache avoids redundant computation by caching already-computed Key and Value matrices, and advanced techniques such as PagedAttention further optimize cache memory management efficiency.

80%
Verified

vLLM uses PagedAttention for KV Cache management

80%
Verified

The KV Cache mechanism can cache repeated prefix content, and the more concise the system prompt, the higher the cache hit rate.

80%

Source Articles