ChunkAttention: Efficient Self-Attention with Prefix-Aware KV Cache and Two-Phase Partition

Authors: Lu Ye, Ze Tao, Yong Huang, Yang Li

Submitted to arXiv on 23 Feb. 2024
License: CC BY 4.0
Abstract

Self-attention is an essential component of large language models(LLMs) but a significant source of inference latency for long sequences. In multi-tenant LLMs serving scenarios, the compute and memory operation cost of self-attention can be optimized by using the probability that multiple LLM requests have shared system prompts in prefixes. In this paper, we introduce ChunkAttention, a prefix-aware self-attention module that can detect matching prompt prefixes across multiple requests and share their key/value tensors in memory at runtime to improve the memory utilization of KV cache. This is achieved by breaking monolithic key/value tensors into smaller chunks and structuring them into the auxiliary prefix tree. Consequently, on top of the prefix-tree based KV cache, we design an efficient self-attention kernel, where a two-phase partition algorithm is implemented to improve the data locality during self-attention computation in the presence of shared system prompts. Experiments show that ChunkAttention can speed up the self-attention kernel by 3.2-4.8$\times$ compared to the start-of-the-art implementation, with the length of the system prompt ranging from 1024 to 4096.

The papers around it, by date and closeness

Higher is closer to this paper; left is older. Lines join papers close to each other: groups of lines are sub-topics. Select a point to see why it is there. Back to the summary of this paper

How to read this map? Illustrated guide

Closest papers Prior work it builds on Papers that cite it

Papers around this one

Ranked by how close their title and abstract are to this paper’s. Select some to read them together.

Closest papers

  1. Very close Broader context Cites this paper
    Multi-Segment Attention: Enabling Efficient KV-Cache Management for Faster Large Language Model Serving
    Chunan Shi, Yi-Lei Chen, Yilin Chen et al. · 2026 · arXiv.org · preprint, not peer reviewed · cited 3 times · Not summarized yet

    AsymCache manages KV-cache blocks according to attention-kernel latency, while ChunkAttention shares prefix KV tensors and optimizes attention computation.

    Abstract

    Large Language Model (LLM) inference relies on key-value (KV) caches to avoid redundant attention computation. While approximate KV cache retention techniques reduce memory usage by sacrificing model accuracy, lossless approaches instead evict KV cache blocks from GPU memory and reconstruct them on demand to preserve exact outputs. Existing lossless KV cache management systems primarily base eviction decisions on access frequency or positional heuristics, without considering how different KV cache blocks affect the execution efficiency of GPU attention kernels. In this paper, we propose AsymCache, a computation-latency-aware KV cache management system for LLM inference that explicitly aligns…

  2. Very close Broader context
    CompactAttention: Accelerating Chunked Prefill with Block-Union KV Selection
    Jiwon Song, Dongwon Jo, Beomseok Kang et al. · 2026 · arXiv.org · preprint, not peer reviewed · Not summarized yet

    CompactAttention selects KV blocks for chunked prefill, whereas ChunkAttention shares matching system-prompt prefixes across requests.

    Abstract

    Chunked prefill has become a widely adopted serving strategy for long-context large language models, but efficient attention computation in this regime remains challenging. Existing sparse attention methods are primarily designed for one-shot prefill and do not translate efficiently to chunked prefill: block-sparse kernels lose efficiency when the query length is limited by the chunk size, while fine-grained pattern search becomes costly when repeated over the accumulated KV cache at every chunk. QUOKA, a recent method that directly targets chunked prefill, avoids sparse-kernel overhead but relies on query-subsampled, token-level KV selection, which can miss query-specific KV entries and int…

  3. Very close Another approach to the problem Cites this paper
    Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention
    Bin Gao, Zhuo-Min He, Puru Sharma et al. · 2024 · USENIX Annual Technical Conference · cited 301 times · Not summarized yet

    CachedAttention reuses KV caches across turns in a conversation, while ChunkAttention shares KV tensors for common request prefixes.

    Abstract

    Interacting with humans through multi-turn conversations is a fundamental feature of large language models (LLMs). However, existing LLM serving engines executing multi-turn conversations are inefficient due to the need to repeatedly compute the key-value (KV) caches of historical tokens, incurring high serving costs. To address the problem, this paper proposes CachedAttention, a new attention mechanism that enables reuse of KV caches across multi-turn conversations, significantly reducing the repetitive computation overheads. CachedAttention maintains a hierarchical KV caching system that leverages cost-effective memory/storage mediums to save KV caches for all requests. To reduce KV cache …

  4. Very close Broader context
    Inference-Friendly Models With MixAttention
    Shashank Rajput, Ying Sheng, Sean Owen et al. · 2024 · ENLSP · cited 6 times · Not summarized yet

    MixAttention changes model attention to combine sliding windows with cross-layer KV sharing; ChunkAttention optimizes runtime prefix sharing.

    Abstract

    The size of the key-value (KV) cache plays a critical role in determining both the maximum context length and the number of concurrent requests supported during inference in modern language models. The KV cache size grows proportionally with the number of attention heads and the tokens processed, leading to increased memory consumption and slower inference for long inputs. In this work, we explore the use of MixAttention, a model architecture modification closely related to a blog published by Character.AI. MixAttention combines sliding window attention, where only a small subset of recent tokens is stored in the KV cache, with KV cache sharing across layers. Our experiments demonstrate that…

  5. Very close Broader context
    Dispenser: Hierarchical KV Cache Management for Efficient LLM Generative Inference
    Beiquan Cao, Kai-Gui Bian, Guo-Jie Luo et al. · 2025 · International Conference on Parallel and Distributed Systems · Not summarized yet

    Dispenser hierarchically manages KV-cache segments for generative inference, while ChunkAttention organizes shared-prefix KV tensors in a prefix tree.

    Abstract

    As context windows expands, Large Language Models (LLMs) are being more capable of handling long-context tasks. However, long-context inference is hindered by high latency and memory usage due to the linearly growing Key-Value (KV) cache. Prior work has shown that a dynamic subset of the KV cache dominates attention outcomes and selectively loads these subsets instead of the full cache. These methods partition the KV cache into segments (block-wise and token-wise) and identify critical ones for recall. However, for block-wise ones, their recall accuracy is often compromised by semantic inconsistencies among consecutive tokens, and for token-wise ones, they suffer from inefficiency in memory …

  6. Very close Another approach to the problem Cites this paper
    AttnCache: Accelerating Self-Attention Inference for LLM Prefill via Attention Cache
    Dinghong Song, Yuan Feng, Yiwei Wang et al. · 2025 · arXiv.org · preprint, not peer reviewed · cited 2 times · Not summarized yet

    AttnCache accelerates prefill using similarities between attention maps, while ChunkAttention improves attention through shared-prefix KV caching and partitioning.

    Abstract

    Large Language Models (LLMs) are widely used in generative applications such as chatting, code generation, and reasoning. However, many realworld workloads such as classification, question answering, recommendation, and text embedding rely solely on the prefill stage of inference, where the model encodes input sequences without performing autoregressive decoding. In these prefill only scenarios, the self-attention computation becomes the primary performance bottleneck due to its quadratic complexity with respect to sequence length. In this paper, we observe that semantically different sentences often produce similar attention maps across layers and heads. Building on this insight, we propose…

  7. Very close Broader context
    SqueezeAttention: 2D Management of KV-Cache in LLM Inference via Layer-wise Optimal Budget
    Zi-Hao Wang, Bin Cui, Shaoduo Gan · 2024 · International Conference on Learning Representations · cited 25 times · Not summarized yet

    SqueezeAttention allocates KV-cache budgets across tokens and layers, whereas ChunkAttention shares prefix KV tensors and improves their computation.

    Abstract

    Optimizing the Key-Value (KV) cache of the Large Language Model (LLM) has been considered critical to saving the cost of inference. Most of the existing KV-cache compression algorithms attempted to sparsify the sequence of tokens by taking advantage of the different importance of tokens. However, most of these methods treat all layers equally, allocating the same KV budget to each layer. This approach is suboptimal, as some layers may be less sensitive to input tokens yet still receive the same budget as others. In this work, we found that by identifying the importance of attention layers, we could optimize the KV-cache jointly from two dimensions, i.e., sequence-wise and layer-wise. Based o…

  8. Close Broader context
    Coverage-Driven KV Cache Eviction for Efficient and Improved Inference of LLM
    Shuvendu Roy, Meng-Yao Zhai, Hossein Hajimirsadeghi et al. · 2026 · arXiv.org · preprint, not peer reviewed · cited 2 times · Not summarized yet

    Coverage-driven eviction selects KV tokens to retain for long-context inference, while ChunkAttention shares matching system-prompt KV tensors.

    Abstract

    Large language models (LLMs) excel at complex tasks like question answering and summarization, thanks to their ability to handle long-context inputs. However, deploying LLMs is costly, not only due to the high computational demands of quadratic complexity of self-attention and auto-regressive generation, but also because of the significant memory overhead required for storing the key-value (KV) cache during inference. To reduce the memory cost, existing KV-cache eviction strategies leverage the sparsity in attention to selectively store a subset of tokens. While reducing the memory footprint, such approaches show a considerable drop in performance, especially in tasks that require long-conte…

Prior work it builds on

  1. Close Groundwork for this paper Used in depth by this paper A method it uses
    FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
    Tri Dao · 2023 · Machine Learning · cited 3,584 times · Not summarized yet

    FlashAttention-2 improves exact attention through GPU parallelism and work partitioning, providing an attention-kernel approach that ChunkAttention builds on.

    Abstract

    Scaling Transformers to longer sequence lengths has been a major problem in the last several years, promising to improve performance in language modeling and high-resolution image understanding, as well as to unlock new applications in code, audio, and video generation. The attention layer is the main bottleneck in scaling to longer sequences, as its runtime and memory increase quadratically in the sequence length. FlashAttention exploits the asymmetric GPU memory hierarchy to bring significant memory saving (linear instead of quadratic) and runtime speedup (2-4$\times$ compared to optimized baselines), with no approximation. However, FlashAttention is still not nearly as fast as optimized m…

  2. Close Groundwork for this paper Used in depth by this paper A method it uses
    FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
    Tri Dao, Daniel Y. Fu, Stefano Ermon et al. · 2022 · Machine Learning · cited 5,749 times · AI summary available

    FlashAttention uses IO-aware tiling for exact attention, an earlier kernel-optimization approach related to ChunkAttention’s attention computation.

    Abstract

    Transformers are slow and memory-hungry on long sequences, since the time and memory complexity of self-attention are quadratic in sequence length. Approximate attention methods have attempted to address this problem by trading off model quality to reduce the compute complexity, but often do not achieve wall-clock speedup. We argue that a missing principle is making attention algorithms IO-aware -- accounting for reads and writes between levels of GPU memory. We propose FlashAttention, an IO-aware exact attention algorithm that uses tiling to reduce the number of memory reads/writes between GPU high bandwidth memory (HBM) and GPU on-chip SRAM. We analyze the IO complexity of FlashAttention, …

  3. Related Broader context
    S3: Increasing GPU Utilization during Generative Inference for Higher Throughput
    Yunho Jin, Chun-Feng Wu, D. Brooks et al. · 2023 · Neural Information Processing Systems · cited 154 times · Not summarized yet

    S3 increases GPU utilization during generative inference by addressing KV-cache memory reservation, while ChunkAttention targets shared-prefix attention.

    Abstract

    Generating texts with a large language model (LLM) consumes massive amounts of memory. Apart from the already-large model parameters, the key/value (KV) cache that holds information about previous tokens in a sequence can grow to be even larger than the model itself. This problem is exacerbated in one of the current LLM serving frameworks which reserves the maximum sequence length of memory for the KV cache to guarantee generating a complete sequence as they do not know the output sequence length. This restricts us to use a smaller batch size leading to lower GPU utilization and above all, lower throughput. We argue that designing a system with a priori knowledge of the output sequence can m…

  4. Related Broader context Used in depth by this paper
    DeepSpeed- Inference: Enabling Efficient Inference of Transformer Models at Unprecedented Scale
    Reza Yazdani Aminabadi, Samyam Rajbhandari, A. Awan et al. · 2022 · International Conference for High Performance Computing, Networking, Storage and Analysis · cited 739 times · Not summarized yet

    DeepSpeed-Inference optimizes large-scale transformer inference across GPUs and heterogeneous memory, while ChunkAttention specializes in prefix-aware attention.

    Abstract

    The landscape of transformer model inference is increasingly diverse in model size, model characteristics, latency and throughput requirements, hardware requirements, etc. With such diversity, designing a versatile inference system is challenging. DeepSpeed-Inference addresses these challenges by (1) a multi-GPU inference solution to minimize latency while maximizing throughput for both dense and sparse transformers when the model fits in aggregate GPU memory, and (2) a heterogeneous inference solution that leverages CPU/NVMe/GPU memory to enable high-throughput inference for models larger than aggregate GPU memory. DeepSpeed-Inference reduces latency by 6.4× and increases throughput by 1.5 …

  5. Related Broader context
    Lost in the Middle: How Language Models Use Long Contexts
    Nelson F. Liu, Kevin Lin, John Hewitt et al. · 2023 · Transactions of the Association for Computational Linguistics · cited 5,796 times · AI summary available

    Lost in the Middle evaluates how language models use long contexts, while ChunkAttention reduces attention costs for long shared prompts.

    Abstract

    While recent language models have the ability to take long contexts as input, relatively little is known about how well they use longer context. We analyze the performance of language models on two tasks that require identifying relevant information in their input contexts: multi-document question answering and key-value retrieval. We find that performance can degrade significantly when changing the position of relevant information, indicating that current language models do not robustly make use of information in long input contexts. In particular, we observe that performance is often highest when relevant information occurs at the beginning or end of the input context, and significantly de…

Papers that cite it

  1. Close Same question Uses this paper in depth
    HotPrefix: Hotness-Aware KV Cache Scheduling for Efficient Prefix Sharing in LLM Inference Systems
    Yuhang Li, Rong Gu, Cheng-Ying Huan et al. · 2025 · Proc. ACM Manag. Data · cited 25 times · Not summarized yet

    HotPrefix and ChunkAttention both address efficient prefix sharing in LLM inference through reuse of prefix KV caches.

    Abstract

    Prompt engineering techniques are widely used to enhance the generation quality of large language models (LLMs). However, the long prompts significantly increase inference latency and reduce inference throughput. Since many prompts share common prefixes, prefix sharing has been proposed to reuse shared prefix KV caches during inference. Nevertheless, the large number of prefix KV caches and the limited GPU memory capacity make it impractical to store all prefix KV caches in GPU memory. This limitation necessitates the use of external memory storage strategies, which often suffer from high I/O overhead and frequent cache misses with traditional approaches. To address these challenges, this pa…

  2. Close Review Uses this paper in depth
    A Survey on Large Language Model Acceleration based on KV Cache Management
    Hao-Yang Li, Yiming Li, An-Xin Tian et al. · 2024 · Trans. Mach. Learn. Res. · cited 182 times · Not summarized yet

    The survey reviews KV-cache management strategies for LLM acceleration, including the area in which ChunkAttention optimizes prefix sharing.

    Abstract

    Large Language Models (LLMs) have revolutionized a wide range of domains such as natural language processing, computer vision, and multi-modal tasks due to their ability to comprehend context and perform logical reasoning. However, the computational and memory demands of LLMs, particularly during inference, pose significant challenges when scaling them to real-world, long-context, and real-time applications. Key-Value (KV) cache management has emerged as a critical optimization technique for accelerating LLM inference by reducing redundant computations and improving memory utilization. This survey provides a comprehensive overview of KV cache management strategies for LLM acceleration, categ…

  3. Close Review Uses this paper in depth
    Towards Efficient Large Language Model Serving: A Survey on System-Aware KV Cache Optimization
    Jiantong Jiang, Pei-Yu Yang, Rui Zhang et al. · 2026 · Annual Meeting of the Association for Computational Linguistics · cited 27 times · Not summarized yet

    The survey organizes system-aware KV-cache optimization for LLM serving, a broader topic that includes ChunkAttention’s cache and execution techniques.

    Abstract

    Despite the rapid advancements of large language models (LLMs), LLM serving systems remain memory-intensive and costly. The key-value (KV) cache, which stores KV tensors during autoregressive decoding, is crucial for enabling low-latency, high-throughput LLM inference serving. In this survey, we focus on system-aware KV infrastructure for serving LLMs (abbreviated as sKis). We revisit recent work from a system behavior perspective, organizing existing efforts into three dimensions: execution and scheduling (temporal), placement and migration (spatial), and representation and retention (structural). Furthermore, we analyze cross-behavior co-design affinity and behavior-objective links, highli…

  4. Close Broader context
    Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and Reasoning
    Yu Fu, Ze-Fan Cai, Abedelkadir Asi et al. · 2024 · International Conference on Learning Representations · cited 122 times · Not summarized yet

    HeadKV compresses KV caches by estimating head importance for retrieval and reasoning, whereas ChunkAttention shares cache tensors for common prefixes.

    Abstract

    Key-Value (KV) caching is a common technique to enhance the computational efficiency of Large Language Models (LLMs), but its memory overhead grows rapidly with input length. Prior work has shown that not all tokens are equally important for text generation, proposing layer-level KV cache compression to selectively retain key information. Recognizing the distinct roles of attention heads in generation, we propose HeadKV, a head-level KV cache compression method, and HeadKV-R2, which leverages a novel contextual reasoning ability estimation for compression. Our approach operates at the level of individual heads, estimating their importance for contextual QA tasks that require both retrieval a…

  5. Close Same method, another problem Uses this paper in depth
    DeFT: Decoding with Flash Tree-attention for Efficient Tree-structured LLM Inference
    Jinwei Yao, Kaiqi Chen, Kexun Zhang et al. · 2024 · International Conference on Learning Representations · cited 23 times · Not summarized yet

    DeFT and ChunkAttention both partition attention computation to reuse KV data for shared-prefix inputs, with DeFT targeting tree-structured generation.

    Abstract

    Large language models (LLMs) are increasingly employed for complex tasks that process multiple generation calls in a tree structure with shared prefixes of tokens, including few-shot prompting, multi-step reasoning, speculative decoding, etc. However, existing inference systems for tree-based applications are inefficient due to improper partitioning of queries and KV cache during attention calculation. This leads to two main issues: (1) a lack of memory access (IO) reuse for KV cache of shared prefixes, and (2) poor load balancing.As a result, there is redundant KV cache IO between GPU global memory and shared memory, along with low GPU utilization. To address these challenges, we propose De…

How are these papers found?

We compare the title and abstract of this paper with those of every paper summarized on this site, and with the papers Semantic Scholar recommends, those it cites and those citing it (for a much-cited paper, its most recent citations and, from OpenAlex, the most cited ones). Among the prior work and the follow-ups, the papers that use each other in depth, a method it uses and the much-cited follow-ups come a little higher. The levels (very close, close, related) come from the similarity of the texts, not from a judgment of quality; * marks a paper without an abstract, compared by its title. The sentence under a paper is written by an AI from the two abstracts: check it in the papers. A paper marked not relevant by three readers leaves the list.

Updated on 2 November 2026.

The illustrated guide to the papers around a paper