Prefix Sharing
-
Last Updated 20 May, 2026
-
by David Spuler, Ph.D.
What is Prefix Sharing?
Prefix sharing is an LLM inference optimization that shares a common prefix across multiple queries. This is a generalization of KV prefix caching to the case where concurrent queries in a batch API have the same prefix. A common prefix can arise in a multi-query batch in common ways:
- Common document used with multiple queries
- Global instructions prepended to every query
There are two main ways to implement prefix sharing:
- Batched prefix sharing — detecting a common prefix in a group of batch queries for reuse of the prefix computations.
- Prefix caching — storing the computed KV data in a "prefix cache" datastore, which is used later by any number of queries, whether batched or interactive.
Batched prefix sharing is where a group of LLM queries submitted in a batch have the same prefix. For example, they could all be queries about a particular large document. The common prefix can be used to optimize this group of inference queries. This method has the advantage of not needing a datastore for KV cache data, but has a scope limited to a single multi-query batch job.
The optimization of prefix sharing is similar to KV caching, but it does not need storage for the long-term. Multiple queries with a common prefix can share the prefill computations for that prefix, in particular the KV values computed for that prefix of tokens.
Prefix Sharing: Book Excerpts and Blog Articles
Free online book excerpts with full text chapters online and free PDF downloads, and the Aussie AI blog, including related articles:
- David Spuler, 25th August, 2024, Hot Inference Optimization Techniques, https://www.aussieai.com/blog/hot-inference-research
- David Spuler, , September 26, 2024, RAG Optimization via Caching, https://www.aussieai.com/blog/rag-optimization-caching
- David Spuler, October 24, 2024, Generalizing Prefix KV Caching to RAG Chunks, Aussie AI Blog, https://www.aussieai.com/blog/prefix-kv-rag
- David Spuler, Michael Sharpe, June 2025, RAG Caching, Chapter 11, "RAG Optimization: Accurate and Efficient LLM Applications", https://www.aussieai.com/book/rag-book-11-rag-caching
- David Spuler, Michael Sharpe, June 2025, Advanced RAG Architectures, Chapter 14, "RAG Optimization: Accurate and Efficient LLM Applications", https://www.aussieai.com/book/rag-book-14-advanced-rag-architectures
- David Spuler, Michael Sharpe, 2025, RAG Architectures, Chapter 15, in "Generative AI Applications", https://www.aussieai.com/book/ai-apps-book-15-rag-architectures
- David Spuler, Michael Sharpe, 2025, Prompt Engineering, Chapter 17, in "Generative AI Applications", https://www.aussieai.com/book/ai-apps-book-17-prompt-engineering
Research on Prefix Sharing
Research papers on prefix sharing in a multi-query batch inference job:
- Zhen Zheng, Xin Ji, Taosong Fang, Fanghao Zhou, Chuanjie Liu, Gang Peng, 29 Nov 2024, BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batching, https://arxiv.org/abs/2412.03594
- Vikranth Srivatsa∗, Zijian He∗, Reyna Abhyankar, Dongming Li, Yiying Zhang, 2024, Preble: Efficient Distributed Prompt Scheduling for LLM Serving, University of California, San Diego, https://escholarship.org/content/qt1bm0k1w0/qt1bm0k1w0.pdf (Evalulates prompt sharing including full inference cache or a partial prefix-based computation of a global KV cache for the prefill phase. Also schedules GPUs based on prefill versus decoding phase requirements.)
- Bingli Liao, Danilo Vasconcellos Vargas, 13 Jul 2024, Beyond KV Caching: Shared Attention for Efficient LLMs, https://arxiv.org/abs/2407.12866 (Layerwise weight sharing in attention.)
What is Prefix Caching?
Prefix caching is the LLM optimization of storing the KV data values from a prefix token sequence for use in a later query. The storage of a prefix KV cache to optimize LLM inference is a special case of prefix sharing. The computed KV data from prefill of a common prefix can be stored on disk or in memory to be later used by LLM inference queries with a common prefix.
Implementing a prefix cache of KV data is more complicated than a simple batched query prefix sharing method. Extra infrastructure is needed:
- Datastore of KV data mapped to token prefixes.
- Network transmission of KV data between multiple GPUs if there is a cache hit.
- Each query needs to lookup its token sequence in the index of prefix token sequences.
Nevertheless, prefix caching is a powerful optimization being used in several industry inference platforms. When they're talking about "cached tokens" then it's almost certainly doing prefix caching behind the scenes. Prefixes arise naturally in several AI use cases:
- Conversational history in every chatbot session is a prefix from a prior query.
- Prepended global instructions or "hidden prompts" of any LLM engine.
- Same document used repeatedly across multiple queries (e.g., same RAG chunk or internet document search).
The main limitation of a prefix cache is in RAG architectures. Because a retriever may return multiple RAG chunks, in any order, there is not necessarily a common prefix for each RAG chunk in a query. There are various ways to address this, but prefix caching is less effective with RAG.
Research on Prefix Caching
Research papers on KV prefix caching:
- Liu, Y., Li, H., Du, K., Yao, J., Cheng, Y., Huang, Y., Lu, S., Maire, M., Hoffmann, H., Holtzman, A., Ananthanarayanan, G., and Jiang, J., August 2024, Cachegen: Fast context loading for language model applications, Microsoft Research, https://arxiv.org/abs/2310.07240 https://www.microsoft.com/en-us/research/publication/cachegen-fast-context-loading-for-language-model-applications-via-kv-cache-streaming/
- X Wu, L Zhang, Y Wang, Y Ren, M Hack, 2016, zExpander: a Key-Value Cache with both High Performance and Fewer Misses, EuroSys ’16 April 18–21, 2016, London, United Kingdom, https://ranger.uta.edu/~sjiang/pubs/papers/wu16_zExpander.pdf (General theory paper about prefix key-value caching in a trie or binary tree, not specific to neural networks.)
- Jordan Juravsky, Bradley Brown, Ryan Ehrlich, Daniel Y. Fu, Christopher Ré, Azalia Mirhoseini, 13 May 2024 (v2), Hydragen: High-Throughput LLM Inference with Shared Prefixes, https://arxiv.org/abs/2402.05099 Code: https://github.com/jordan-benjamin/hydragen
- Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, Ion Stoica, Oct 2023, Efficient Memory Management for Large Language Model Serving with PagedAttention, SOSP ’23, October 23–26, 2023, Koblenz, Germany, https://dl.acm.org/doi/pdf/10.1145/3600006.3613165
- Lu Ye, Ze Tao, Yong Huang, Yang Li, 22 Mar 2024 (v2), ChunkAttention: Efficient Self-Attention with Prefix-Aware KV Cache and Two-Phase Partition, https://arxiv.org/abs/2402.15220 (Identify prefixes of prompts and caching the KV values of these portions of the prompt.)
- Vikranth Srivatsa∗, Zijian He∗, Reyna Abhyankar, Dongming Li, Yiying Zhang, 2024, Preble: Efficient Distributed Prompt Scheduling for LLM Serving, University of California, San Diego, https://escholarship.org/content/qt1bm0k1w0/qt1bm0k1w0.pdf (Evalulates prompt sharing including full inference cache or a partial prefix-based computation of a global KV cache for the prefill phase. Also schedules GPUs based on prefill versus decoding phase requirements.)
- Chao Jin, Zili Zhang, Xuanlin Jiang, Fangyue Liu, Xin Liu, Xuanzhe Liu, Xin Jin, 18 Apr 2024, RAGCache: Efficient Knowledge Caching for Retrieval-Augmented Generation, https://arxiv.org/abs/2404.12457
- L. Zheng, L. Yin, Z. Xie, J. Huang, C. Sun, C. H. Yu, S. Cao, C. Kozyrakis, I. Stoica, J. E. Gonzalez et al., Dec 2023, Efficiently programming large language models using SGLang, arXiv preprint arXiv:2312.07104, 2023, https://arxiv.org/abs/2312.07104 (Uses a radix attention method, a trie or prefix tree, for KV caching.)
- Bo-Ru Lu, Nikita Haduong, Chien-Yu Lin, Hao Cheng, Noah A. Smith, Mari Ostendorf, 19 Mar 2024, Encode Once and Decode in Parallel: Efficient Transformer Decoding, https://arxiv.org/abs/2403.13112
- Bin Gao, Zhuomin He, Puru Sharma, Qingxuan Kang, Djordje Jevdjic, Junbo Deng, Xingkun Yang, Zhou Yu, Pengfei Zuo, 23 Mar 2024, AttentionStore: Cost-effective Attention Reuse across Multi-turn Conversations in Large Language Model Serving, https://arxiv.org/abs/2403.19708 PDF: https://prongs1996.github.io/assets/pdf/CachedAttention.pdf (Memory management of KV caches using hierarchical cache layers.)
- Jiayi Yao, Hanchen Li, Yuhan Liu, Siddhant Ray, Yihua Cheng, Qizheng Zhang, Kuntai Du, Shan Lu, Junchen Jiang, 3 Jun 2024 (v2), CacheBlend: Fast Large Language Model Serving for RAG with Cached Knowledge Fusion, https://arxiv.org/abs/2405.16444 Code: https://github.com/YaoJiayi/CacheBlend.git (Generalizes prefix KV caching to KV cache fusion with selective recomputation of some KV cache data.)
- Shu Liu, Asim Biswal, Audrey Cheng, Xiangxi Mo, Shiyi Cao, Joseph E. Gonzalez, Ion Stoica, and Matei Zaharia. March 2024, Optimizing llm queries in relational workloads, https://arxiv.org/abs/2403.05821
- Yuan Feng, Hyeran Jeon, Filip Blagojevic, Cyril Guyot, Qing Li, Dong Li, 17 Apr 2023 (v2), AttMEMO : Accelerating Transformers with Memoization on Big Memory Systems, https://arxiv.org/abs/2301.09262
- Zihao Ye, Ruihang Lai, Bo-Ru Lu, Chien-Yu Lin, Size Zheng, Lequn Chen, Tianqi Chen, Luis Ceze, Feb 2, 2024, Cascade Inference: Memory Bandwidth Efficient Shared Prefix Batch Decoding, https://flashinfer.ai/2024/02/02/cascade-inference.html
- Reyna Abhyankar, Zijian He, Vikranth Srivatsa, Hao Zhang, Yiying Zhang, 2024, INFERCEPT: Efficient Intercept Support for Augmented Large Language Model Inference, https://openreview.net/pdf?id=wDDGQabYPQ
- Nikhil Jha, Kevin Wang, 2023, https://people.eecs.berkeley.edu/~kubitron/courses/cs262a-F23/projects/reports/project1010_paper_64287652274076362722.pdf (Extends Paged Attention to a global multi-query KV cache and also implements prefix KV caching.)
- Chaofan Lin, Zhenhua Han, Chengruidong Zhang, Yuqing Yang, Fan Yang, Chen Chen, Lili Qiu, 30 May 2024, Parrot: Efficient Serving of LLM-based Applications with Semantic Variable, https://arxiv.org/abs/2405.19888 (Uses prefix KV caching and a combined flash attention and paged attention module.)
- 8 Jun 2024 (v2), A Survey on Efficient Inference for Large Language Models, Zixuan Zhou, Xuefei Ning, Ke Hong, Tianyu Fu, Jiaming Xu, Shiyao Li, Yuming Lou, Luning Wang, Zhihang Yuan, Xiuhong Li, Shengen Yan, Guohao Dai, Xiao-Ping Zhang, Yuhan Dong, Yu Wang, https://arxiv.org/abs/2404.14294
- VLLM, 2024, What is Automatic Prefix Caching, https://docs.vllm.ai/en/stable/automatic_prefix_caching/apc.html
- Character.AI, June 20, 2024, Optimizing AI Inference at Character.AI, https://research.character.ai/optimizing-inference/
- Cunchen Hu, Heyang Huang, Junhao Hu, Jiang Xu, Xusheng Chen, Tao Xie, Chenxi Wang, Sa Wang, Yungang Bao, Ninghui Sun, Yizhou Shan, 26 Jun 2024 (v2), MemServe: Context Caching for Disaggregated LLM Serving with Elastic Memory Pool, https://arxiv.org/abs/2406.17565 (Combined session-based prefix KV caching with disaggregation of prefill and decoding phases.)
- Sean Welleck, Amanda Bertsch, Matthew Finlayson, Hailey Schoelkopf, Alex Xie, Graham Neubig, Ilia Kulikov, Zaid Harchaoui, 24 Jun 2024, From Decoding to Meta-Generation: Inference-time Algorithms for Large Language Models, https://arxiv.org/abs/2406.16838 (Survey and theoretical analysis of many different decoding algorithms, along with various ways to speed them up such as speculative decoding and KV caches.)
- Franklin Huang, May 17, 2024, Machine Learning Systems with Reduced Memory Requirements, Masters of Science, Electrical Engineering and Computer Sciences, University of California, Berkeley, Technical Report No. UCB/EECS-2024-120 http://www2.eecs.berkeley.edu/Pubs/TechRpts/2024/EECS-2024-120.html https://www2.eecs.berkeley.edu/Pubs/TechRpts/2024/EECS-2024-120.pdf Code: https://github.com/hongyihuang/spec-mcts/blob/main/triton (Broad paper that examines a lot of different optimizations that reduce memory costs, including quantization, kernel fusion, sparsity, MatMul optimizations, KV cache compression, and various other methods.)
- Ruoyu Qin, Zheming Li, Weiran He, Mingxing Zhang, Yongwei Wu, Weimin Zheng, Xinran Xu, 2 Jul 2024 (v2), Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving, https://arxiv.org/abs/2407.00079 Code: https://github.com/kvcache-ai/Mooncake (Disaggregates prefill and decoding phases for scheduling, with chunked prefill, while managing the KV cache.)
- Google, 2024, Context caching, https://ai.google.dev/gemini-api/docs/caching?lang=python (Pass in context tokens and reuse them without re-uploading, might be doing something like prefix KV caching underneath.)
- Tianyi Tang, Yiwen Hu, Bingqian Li, Wenyang Luo, Zijing Qin, Haoxiang Sun, Jiapeng Wang, Shiyi Xu, Xiaoxue Cheng, Geyang Guo, Han Peng, Bowen Zheng, Yiru Tang, Yingqian Min, Yushuo Chen, Jie Chen, Yuanqian Zhao, Luran Ding, Yuhao Wang, Zican Dong, Chunxuan Xia, Junyi Li, Kun Zhou, Wayne Xin Zhao, Ji-Rong Wen, 8 Jul 2024, LLMBox: A Comprehensive Library for Large Language Models, https://arxiv.org/abs/2407.05563 Code: https://github.com/RUCAIBox/LLMBox
- Youngsuk Park, Kailash Budhathoki, Liangfu Chen, Jonas Kübler, Jiaji Huang, Matthäus Kleindessner, Jun Huan, Volkan Cevher, Yida Wang, George Karypis, 12 Jul 2024, Inference Optimization of Foundation Models on AI Accelerators, KDD’24, August 25–29, 2024, Barcelona, Spain, https://arxiv.org/abs/2407.09111
- NVIDIA, July 2024 (accessed), KV cache reuse, https://github.com/NVIDIA/TensorRT-LLM/blob/main/docs/source/kv_cache_reuse.md (KV cache reuse in TensorRT is an implementation of prefix-based KV caching.)
- Kexin Chu, Tzechinh Liu, Yunding Li, Pengchao Yuan, Wei Zhang, 2024, CaR: An Efficient KV Cache Reuse System for Large Language Model Inference, University of Connecticut, https://llm-gnn.org/slides/CaR-Chu.pdf
- James Groeneveld, Aug 1, 2024, Prompt Design at Character.AI, Character.AI blog, https://research.character.ai/prompt-design-at-character-ai/
- DeepSeek, 02 August, 2024, DeepSeek API introduces Context Caching on Disk, cutting prices by an order of magnitude, https://platform.deepseek.com/api-docs/news/news0802/ (Announcement of commercial support for global KV caching with session-based and prefix KV caches.)
- Yibo Jin, Tao Wang, Huimin Lin, Mingyang Song, Peiyang Li, Yipeng Ma, Yicheng Shan, Zhengfan Yuan, Cailong Li, Yajing Sun, Tiandeng Wu, Xing Chu, Ruizhi Huan, Li Ma, Xiao You, Wenting Zhou, Yunpeng Ye, Wen Liu, Xiangkun Xu, Yongsheng Zhang, Tiantian Dong, Jiawei Zhu, Zhe Wang, Xijian Ju, Jianxun Song, Haoliang Cheng, Xiaojing Li, Jiandong Ding, Hefei Guo, Zhengyong Zhang, 15 Aug 2024, P/D-Serve: Serving Disaggregated Large Language Model at Scale, https://arxiv.org/abs/2408.08147 (Comprehensive serving system addressing disaggregated prefill and KV cache transfer with RDMA.)
- David Spuler, 25th August, 2024, Hot Inference Optimization Techniques, https://www.aussieai.com/blog/hot-inference-research
- Ahmed Tremo, Aug 6, 2024, How to Efficiently Serve an LLM? https://ahmedtremo.com/posts/How-to-Efficiently-serve-an-llm/
- Zihao Ye,, Lequn Chen, Ruihang Lai, Yilong Zhao, Size Zheng, Junru Shao, Bohan Hou, Hongyi Jin, Yifei Zuo, Liangsheng Yin, Tianqi Chen, Luis Ceze, Feb 2, 2024, Accelerating Self-Attentions for LLM Serving with FlashInfer, https://flashinfer.ai/2024/02/02/introduce-flashinfer.html
- David Spuler, , September 26, 2024, RAG Optimization via Caching, https://www.aussieai.com/blog/rag-optimization-caching
- Open AI, Oct 2024 (accessed), Prompt Caching, https://platform.openai.com/docs/guides/prompt-caching
- Shuowei Jin, Xueshen Liu, Qingzhao Zhang, Z. Morley Mao, 4 Oct 2024, Compute Or Load KV Cache? Why Not Both? https://arxiv.org/abs/2410.03065
- OpenVINO-toolkit, Oct 1, 2024, Introducing OpenVINO™ 2024.4, https://medium.com/openvino-toolkit/introducing-openvino-2024-4-28578870b264
- Junhao Hu, Wenrui Huang, Haoyi Wang, Weidong Wang, Tiancheng Hu, Qin Zhang, Hao Feng, Xusheng Chen, Yizhou Shan, Tao Xie, 20 Oct 2024, EPIC: Efficient Position-Independent Context Caching for Serving Large Language Models, https://arxiv.org/abs/2410.15332
- David Spuler, October 24, 2024, Generalizing Prefix KV Caching to RAG Chunks, Aussie AI Blog, https://www.aussieai.com/blog/prefix-kv-rag
- Yilong Zhao, Shuo Yang, Kan Zhu, Lianmin Zheng, Baris Kasikci, Yang Zhou, Jiarong Xing, Ion Stoica, 25 Nov 2024, BlendServe: Optimizing Offline Inference for Auto-regressive Large Models with Resource-aware Batching, https://arxiv.org/abs/2411.16102
- Rui Pan, Zhuang Wang, Zhen Jia, Can Karakus, Luca Zancato, Tri Dao, Ravi Netravali, Yida Wang, 28 Nov 2024, Marconi: Prefix Caching for the Era of Hybrid LLMs, https://arxiv.org/abs/2411.19379 (Prefix caching applied to hybrid SSM-Transformer LLMs.)
- Zhen Zheng, Xin Ji, Taosong Fang, Fanghao Zhou, Chuanjie Liu, Gang Peng, 29 Nov 2024, BatchLLM: Optimizing Large Batched LLM Inference with Global Prefix Sharing and Throughput-oriented Token Batching, https://arxiv.org/abs/2412.03594
- Ao Wang, Hui Chen, Jianchao Tan, Kefeng Zhang, Xunliang Cai, Zijia Lin, Jungong Han, Guiguang Ding, 4 Dec 2024, PrefixKV: Adaptive Prefix KV Cache is What Vision Instruction-Following Models Need for Efficient Generation, https://arxiv.org/abs/2412.03409 https://github.com/THU-MIG/PrefixKV
- PromptHub, December 6, 2024, Prompt Caching with OpenAI, Anthropic, and Google Models, https://www.prompthub.us/blog/prompt-caching-with-openai-anthropic-and-google-models
- Yucheng Li, Huiqiang Jiang, Qianhui Wu, Xufang Luo, Surin Ahn, Chengruidong Zhang, Amir H. Abdi, Dongsheng Li, Jianfeng Gao, Yuqing Yang, Lili Qiu, 13 Dec 2024, SCBench: A KV Cache-Centric Analysis of Long-Context Methods, https://arxiv.org/abs/2412.10319 https://aka.ms/SCBench
- Saurabh Agarwal, Anyong Mao, Aditya Akella, Shivaram Venkataraman, 21 Dec 2024, SYMPHONY: Improving Memory Management for LLM Inference Workloads, https://arxiv.org/abs/2412.16434 (Use "additional hints" to optimize KV cache processing in chatbot sessions, such as when the user starts typing.)
- Chenchen Gu, Xiang Lisa Li, Rohith Kuditipudi, Percy Liang, Tatsunori Hashimoto, Dec 2024, Timing Attacks on Prompt Caching in Language Model APIs, Stanford CS 191W Senior Project, https://cs191w.stanford.edu/projects/Gu,%20Chenchen_CS191W.pdf (Using timing attacks to detect prefix KV caching, thereby gaining information about other users' prompts.)
- Brian J Chan, Chao-Ting Chen, Jui-Hung Cheng, Hen-Hsen Huang, 20 Dec 2024, Don't Do RAG: When Cache-Augmented Generation is All You Need for Knowledge Tasks, https://arxiv.org/abs/2412.15605 (Mini-RAG architecture preloading the entire knowledge into the LLM context and then using KV caching.)
- HF, 2024, TGI v3 overview, https://huggingface.co/docs/text-generation-inference/conceptual/chunking
- Longze Chen, Jan 2025 (accessed), Awesome-KV-Cache-Compression: Must-read papers on KV Cache Compression (constantly updating), https://github.com/October2001/Awesome-KV-Cache-Compression (KV cache reuse across multiple prompts via SwiftKV, sounds similar to prefix KV caching or fused KV caching, and also SingleInputKV does KV cache layer fusion in a single prompt.)
- Shiyi Cao, Yichuan Wang, Ziming Mao, Pin-Lun Hsu, Liangsheng Yin, Tian Xia, Dacheng Li, Shu Liu, Yineng Zhang, Yang Zhou, Ying Sheng, Joseph Gonzalez, Ion Stoica, 24 Jan 2025, Locality-aware Fair Scheduling in LLM Serving, https://arxiv.org/abs/2501.14312 (Scheduling taking into account prefix cache availability based on locality.)
- Amr Elmeleegy, Ashraf Eassa, Mark Taylor, Nick Comly, Vijay Singh, Hao Wang and Pallab Bhattacharya, Oct 28, 2024, NVIDIA GH200 Superchip Accelerates Inference by 2x in Multiturn Interactions with Llama Models, https://developer.nvidia.com/blog/nvidia-gh200-superchip-accelerates-inference-by-2x-in-multiturn-interactions-with-llama-models/
- Shiju Zhao, Junhao Hu, Rongxiao Huang, Jiaqi Zheng, Guihai Chen, 4 Feb 2025, MPIC: Position-Independent Multimodal Context Caching System for Efficient MLLM Serving, https://arxiv.org/abs/2502.01960
- Gregory Dexter, Shao Tang, Ata Fatahi Baarzi, Qingquan Song, Tejas Dharamsi, Aman Gupta, 7 Feb 2025. LLM Query Scheduling with Prefix Reuse and Latency Constraints, https://arxiv.org/abs/2502.04677
- S Agarwal, S Sundaresan, S Mitra, D Mahapatra, Feb 2025, Cache-Craft: Managing Chunk-Caches for Efficient Retrieval-Augmented Generation, https://skejriwal44.github.io/docs/CacheCraft_SIGMOD_2025.pdf (Managing pre-computed KV caches for RAG chunks as a generalization of prefix KV caching, addressing limitations in their position and ordering.)
- Jingbo Yang, Bairu Hou, Wei Wei, Yujia Bao, Shiyu Chang, 21 Feb 2025, KVLink: Accelerating Large Language Models via Efficient KV Cache Reuse, https://arxiv.org/abs/2502.16002 https://github.com/UCSB-NLP-Chang/KVLink (Computing a KV cache for each RAG chunk, and using techniques to fuse/merge/concatenate these KV caches, i.e., fused KV caching as a generalization of prefix KV caching, while restoring cross-chunk attention accuracy via 3 techniques: positional re-encoding, "link tokens" between chunks processed during inference, and fine-tuning).
- Weijian Chen, Shuibing He, Haoyang Qu, Ruidong Zhang, Siling Yang, and Ping Chen, Yi Zheng and Baoxing Huai, Gang Chen, 2025, IMPRESS: An Importance-Informed Multi-Tier Prefix KV Storage System for Large Language Model Inference, https://www.usenix.org/system/files/fast25-chen-weijian-impress.pdf (Estimating the cost of loading prefix KV caches from disk, to decide whether to use them or not.)
- Zaifeng Pan, Ajjkumar Patel, Zhengding Hu, Yipeng Shen, Yue Guan, Wan-Lu Li, Lianhui Qin, Yida Wang, Yufei Ding, 10 Jul 2025, KVFlow: Efficient Prefix Caching for Accelerating LLM-Based Multi-Agent Workflows, https://arxiv.org/abs/2507.07400 (Efficient management of KV caches and eviction policies for prefix caching.)
- Bingyang Wu, Zili Zhang, Yinmin Zhong, Guanzhe Huang, Yibo Zhu, Xuanzhe Liu, Xin Jin, 24 Aug 2025, TokenLake: A Unified Segment-level Prefix Cache Pool for Fine-grained Elastic Long-Context LLM Serving, https://arxiv.org/abs/2508.17219
- Devansh, Sep 2025, The Chocolate Milk Cult’s Guide to Inference Scaling for AI Models: How to Reduce the costs of Running LLMs https://machine-learning-made-simple.medium.com/the-chocolate-milk-cults-guide-to-inference-scaling-for-ai-models-50aa2290eb50 (Deep analysis of using many progressive optimizations to real-life LLM inference.)
- Yuhang Li, Rong Gu, Chengying Huan, Zhibin Wang, Renjie Yao, Chen Tian, and Guihai Chen. 2025. HotPrefix: Hotness-Aware KV Cache Scheduling for Efficient Prefix Sharing in LLM Inference Systems. Proc. ACM Manag. Data 3, 4, Article 250 (September 2025), 27 pages. https://doi.org/10.1145/3749168 https://dl.acm.org/doi/abs/10.1145/3749168 (How to optimize storage of prefix KV caches for many queries.)
- Aleksa Gordić, August 29, 2025, Inside vLLM: Anatomy of a High-Throughput LLM Inference System: From paged attention, continuous batching, prefix caching, specdec, etc. to multi-GPU, multi-node dynamic serving at scale https://www.aleksagordic.com/blog/vllm
- Xingyu Xiang, Raj Joshi, Yuhan Liu, Jiayi Yao, Chenxingyu Zhao, Junchen Jiang, Yang Zhou, Eddie Kohler, Minlan Yu, 21 Sep 2025, ShadowServe: Interference-Free KV Cache Fetching for Distributed Prefix Caching, https://arxiv.org/abs/2509.16857
- Jiawei Xu, Chia Xin Liang, Ziqian Bi, Xiaoming Li, Danyang Zhang, Zhenyu Yu, Dec 2025, A Comprehensive Survey on Large Language Models: From Pre-training to Autonomous Agents, https://www.researchgate.net/profile/Ziqian_Bi/publication/399059225_A_Comprehensive_Survey_on_Large_Language_Models_From_Pre-training_to_Autonomous_Agents/links/694c94a07e61d05b5312836f/A-Comprehensive-Survey-on-Large-Language-Models-From-Pre-training-to-Autonomous-Agents.pdf
- Jiahao Wang, Weiyu Xie, Mingxing Zhang, Boxing Zhang, Jianwei Dong, Yuening Zhu, Chen Lin, Jinqi Tang, Yaochen Han, Zhiyuan Ai, Xianglin Chen, Yongwei Wu, Congfeng Jiang, 19 Jan 2026, From Prefix Cache to Fusion RAG Cache: Accelerating LLM Inference in Retrieval-Augmented Generation, https://arxiv.org/abs/2601.12904 (Improve accuracy of concatenating fused KV caches by re-computing some of the caches for tokens that appear in the main query.)
- Zylos, 15 Jan 2026, LLM Inference Optimization and Quantization 2026, https://zylos.ai/research/2026-01-15-llm-inference-optimization
- Dongsheng Yang, Austin Li, Kai Li , Wyatt Lloyd, Dec 2025, Learned Prefix Caching for Efficient LLM Inference https://neurips.cc/virtual/2025/loc/san-diego/poster/117662 https://openreview.net/pdf?id=Vj48eXaQDM
- BentoML, March 2026 (accessed), Prefix caching, https://bentoml.com/llm/inference-optimization/prefix-caching
- Anthropic, March 2026 (accessed), Prompt caching, https://platform.claude.com/docs/en/build-with-claude/prompt-caching
- Yichao 'Peak' Ji, July 2025, Context Engineering for AI Agents: Lessons from Building Manus, https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus
- vLLM, March 2026 (accessed), Automatic Prefix Caching, https://docs.vllm.ai/en/stable/design/prefix_caching/
- Allard de Winter, August 12, 2025, Beyond keys: The rise of semantic and prefix caching for LLMs, https://allarddewinter.net/blog/beyond-keys-the-rise-of-semantic-and-prefix-caching-for-llms/
- Erika Kettleson, Feb 18, 2026, Prompt Caching 201, https://developers.openai.com/cookbook/examples/prompt_caching_201
- Jen Agarwal, December 09, 2025, Prompt vs semantic caching: Complementary techniques for high-performance AI agents, https://redis.io/blog/prompt-caching-vs-semantic-caching/
- Wenfeng Wang, Xiaofeng Hou, Peng Tang, Hengyi Zhou, Jing Wang, Xinkai Wang, Chao Li, Minyi Guo, 24 Mar 2026, PCR: A Prefetch-Enhanced Cache Reuse System for Low-Latency RAG Serving, https://arxiv.org/abs/2603.23049
- Philip Kiely, Inference Engineering, March 2026, https://www.baseten.co/inference-engineering/
- David Spuler, Michael Sharpe, June 2025, RAG Caching, Chapter 11, "RAG Optimization: Accurate and Efficient LLM Applications", https://www.aussieai.com/book/rag-book-11-rag-caching
- David Spuler, Michael Sharpe, June 2025, Advanced RAG Architectures, Chapter 14, "RAG Optimization: Accurate and Efficient LLM Applications", https://www.aussieai.com/book/rag-book-14-advanced-rag-architectures
- S. H. Ahmadpanah, A. Sahafi and S. H. Erfani, "Context-Aware Autoscaling for Cost-Efficient Large Language Model Inference With Prefix Cache Integration," in IEEE Access, vol. 14, pp. 46024-46035, 2026, doi: 10.1109/ACCESS.2026.3677249, https://ieeexplore.ieee.org/document/11455169 https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=11455169
- David Spuler, Michael Sharpe, 2025, RAG Architectures, Chapter 15, in "Generative AI Applications", https://www.aussieai.com/book/ai-apps-book-15-rag-architectures
- David Spuler, Michael Sharpe, 2025, Prompt Engineering, Chapter 17, in "Generative AI Applications", https://www.aussieai.com/book/ai-apps-book-17-prompt-engineering
- Hancheng Ye, Zhengqi Gao, Mingyuan Ma, Qinsi Wang, Yuzhe Fu, Ming-Yu Chung, Yueqian Lin, Zhijian Liu, Jianyi Zhang, Danyang Zhuo, Yiran Chen, 1 Nov 2025 (v2), KVCOMM: Online Cross-context KV-cache Communication for Efficient LLM-based Multi-agent Systems, https://arxiv.org/abs/2510.12872
- Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Jeff Huang, Chuyue Sun, Cody Hao Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Jan Joseph E. Gonzalez, Clark Barrett, Ying Sheng, 17, 2024, Fast and Expressive LLM Inference with RadixAttention and SGLang, https://www.lmsys.org/blog/2024-01-17-sglang/
- Yuhan Liu, Yuyang Huang, Jiayi Yao, Shaoting Feng, Zhuohan Gu, Kuntai Du, Hanchen Li, Yihua Cheng, and Junchen Jiang, Shan Lu, Madan Musuvathi, and Esha Choukse, May 2026, DroidSpeak: KV Cache Sharing Across Fine-tuned Model Variants, Proceedings of the 23rd USENIX Symposium on Networked Systems Design and Implementation. May 4–6, 2026 • Renton, WA, USA, https://www.usenix.org/system/files/nsdi26-liu-yuhan.pdf https://www.usenix.org/conference/nsdi26/presentation/liu-yuhan (Sharing prefix KV caches from different fine-tuned LLMs, with partial layerwise recomputation.)
- Minds Aspire, Apr 30, 2026, KV Cache Locality: The Hidden Variable in Your LLM Serving Cost, https://ranvier.systems/2026/04/30/kv-cache-locality-the-hidden-variable-in-your-llm-serving-cost.html
KV Caching Optimizations
The main purpose of the prompt processing or prefill phase of inference is to generate the KV cache for use in the decoding phase. Hence, if you can pre-compute and cache the KV cache data, then the need for the prefill phase disappears!
Various types of caching in Transformers include:
- KV caching
- KV caching in early exit
- KV cache compression
- KV cache sparsity
- KV cache token pruning
- KV cache eviction policies
- KV cache quantization
- KV cache layer fusion
- KV cache layer pruning
- KV cache reuse
- KV cache global (multi-query KV caching)
- Prefix KV cache
- Session KV cache (multi-turn KV caching)
- Substring KV cache (Lengthwise-fused KV caching))
More AI Research
Read more about: