SpeCache: Speculative Key-Value Caching for Efficient Generation of LLMs

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Jie, Shibo, Tang, Yehui, Han, Kai, Deng, Zhi-Hong, Han, Jing
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866912284133031936
author Jie, Shibo
Tang, Yehui
Han, Kai
Deng, Zhi-Hong
Han, Jing
author_facet Jie, Shibo
Tang, Yehui
Han, Kai
Deng, Zhi-Hong
Han, Jing
contents Transformer-based large language models (LLMs) have already achieved remarkable results on long-text tasks, but the limited GPU memory (VRAM) resources struggle to accommodate the linearly growing demand for key-value (KV) cache as the sequence length increases, which has become a bottleneck for the application of LLMs on long sequences. Existing KV cache compression methods include eviction, merging, or quantization of the KV cache to reduce its size. However, compression results in irreversible information forgetting, potentially affecting the accuracy of subsequent decoding. In this paper, we propose SpeCache, which takes full advantage of the large and easily expandable CPU memory to offload the complete KV cache, and dynamically fetches KV pairs back in each decoding step based on their importance measured by low-bit KV cache copy in VRAM. To avoid inference latency caused by CPU-GPU communication, SpeCache speculatively predicts the KV pairs that the next token might attend to, allowing us to prefetch them before the next decoding step which enables parallelization of prefetching and computation. Experiments on LongBench and Needle-in-a-Haystack benchmarks verify that SpeCache effectively reduces VRAM usage while avoiding information forgetting for long sequences without re-training, even with a 10x high KV cache compression ratio.
format Preprint
id arxiv_https___arxiv_org_abs_2503_16163
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle SpeCache: Speculative Key-Value Caching for Efficient Generation of LLMs
Jie, Shibo
Tang, Yehui
Han, Kai
Deng, Zhi-Hong
Han, Jing
Computation and Language
Transformer-based large language models (LLMs) have already achieved remarkable results on long-text tasks, but the limited GPU memory (VRAM) resources struggle to accommodate the linearly growing demand for key-value (KV) cache as the sequence length increases, which has become a bottleneck for the application of LLMs on long sequences. Existing KV cache compression methods include eviction, merging, or quantization of the KV cache to reduce its size. However, compression results in irreversible information forgetting, potentially affecting the accuracy of subsequent decoding. In this paper, we propose SpeCache, which takes full advantage of the large and easily expandable CPU memory to offload the complete KV cache, and dynamically fetches KV pairs back in each decoding step based on their importance measured by low-bit KV cache copy in VRAM. To avoid inference latency caused by CPU-GPU communication, SpeCache speculatively predicts the KV pairs that the next token might attend to, allowing us to prefetch them before the next decoding step which enables parallelization of prefetching and computation. Experiments on LongBench and Needle-in-a-Haystack benchmarks verify that SpeCache effectively reduces VRAM usage while avoiding information forgetting for long sequences without re-training, even with a 10x high KV cache compression ratio.
title SpeCache: Speculative Key-Value Caching for Efficient Generation of LLMs
topic Computation and Language
url https://arxiv.org/abs/2503.16163