Cache-Craft: Managing Chunk-Caches for Efficient Retrieval-Augmented Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Agarwal, Shubham, Sundaresan, Sai, Mitra, Subrata, Mahapatra, Debabrata, Gupta, Archit, Sharma, Rounak, Kapu, Nirmal Joshua, Yu, Tong, Saini, Shiv
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929725917626368
author Agarwal, Shubham
Sundaresan, Sai
Mitra, Subrata
Mahapatra, Debabrata
Gupta, Archit
Sharma, Rounak
Kapu, Nirmal Joshua
Yu, Tong
Saini, Shiv
author_facet Agarwal, Shubham
Sundaresan, Sai
Mitra, Subrata
Mahapatra, Debabrata
Gupta, Archit
Sharma, Rounak
Kapu, Nirmal Joshua
Yu, Tong
Saini, Shiv
contents Retrieval-Augmented Generation (RAG) is often used with Large Language Models (LLMs) to infuse domain knowledge or user-specific information. In RAG, given a user query, a retriever extracts chunks of relevant text from a knowledge base. These chunks are sent to an LLM as part of the input prompt. Typically, any given chunk is repeatedly retrieved across user questions. However, currently, for every question, attention-layers in LLMs fully compute the key values (KVs) repeatedly for the input chunks, as state-of-the-art methods cannot reuse KV-caches when chunks appear at arbitrary locations with arbitrary contexts. Naive reuse leads to output quality degradation. This leads to potentially redundant computations on expensive GPUs and increases latency. In this work, we propose Cache-Craft, a system for managing and reusing precomputed KVs corresponding to the text chunks (we call chunk-caches) in RAG-based systems. We present how to identify chunk-caches that are reusable, how to efficiently perform a small fraction of recomputation to fix the cache to maintain output quality, and how to efficiently store and evict chunk-caches in the hardware for maximizing reuse while masking any overheads. With real production workloads as well as synthetic datasets, we show that Cache-Craft reduces redundant computation by 51% over SOTA prefix-caching and 75% over full recomputation. Additionally, with continuous batching on a real production workload, we get a 1.6X speed up in throughput and a 2X reduction in end-to-end response latency over prefix-caching while maintaining quality, for both the LLaMA-3-8B and LLaMA-3-70B models.
format Preprint
id arxiv_https___arxiv_org_abs_2502_15734
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Cache-Craft: Managing Chunk-Caches for Efficient Retrieval-Augmented Generation
Agarwal, Shubham
Sundaresan, Sai
Mitra, Subrata
Mahapatra, Debabrata
Gupta, Archit
Sharma, Rounak
Kapu, Nirmal Joshua
Yu, Tong
Saini, Shiv
Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Computation and Language
Machine Learning
Operating Systems
Retrieval-Augmented Generation (RAG) is often used with Large Language Models (LLMs) to infuse domain knowledge or user-specific information. In RAG, given a user query, a retriever extracts chunks of relevant text from a knowledge base. These chunks are sent to an LLM as part of the input prompt. Typically, any given chunk is repeatedly retrieved across user questions. However, currently, for every question, attention-layers in LLMs fully compute the key values (KVs) repeatedly for the input chunks, as state-of-the-art methods cannot reuse KV-caches when chunks appear at arbitrary locations with arbitrary contexts. Naive reuse leads to output quality degradation. This leads to potentially redundant computations on expensive GPUs and increases latency. In this work, we propose Cache-Craft, a system for managing and reusing precomputed KVs corresponding to the text chunks (we call chunk-caches) in RAG-based systems. We present how to identify chunk-caches that are reusable, how to efficiently perform a small fraction of recomputation to fix the cache to maintain output quality, and how to efficiently store and evict chunk-caches in the hardware for maximizing reuse while masking any overheads. With real production workloads as well as synthetic datasets, we show that Cache-Craft reduces redundant computation by 51% over SOTA prefix-caching and 75% over full recomputation. Additionally, with continuous batching on a real production workload, we get a 1.6X speed up in throughput and a 2X reduction in end-to-end response latency over prefix-caching while maintaining quality, for both the LLaMA-3-8B and LLaMA-3-70B models.
title Cache-Craft: Managing Chunk-Caches for Efficient Retrieval-Augmented Generation
topic Distributed, Parallel, and Cluster Computing
Artificial Intelligence
Computation and Language
Machine Learning
Operating Systems
url https://arxiv.org/abs/2502.15734