AttentionPredictor: Temporal Patterns Matter for KV Cache Compression

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Yang, Qingyue, Wang, Jie, Li, Xing, Wang, Zhihai, Chen, Chen, Chen, Lei, Yu, Xianzhi, Liu, Wulong, Hao, Jianye, Yuan, Mingxuan, Li, Bin
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866911230402232320
author Yang, Qingyue
Wang, Jie
Li, Xing
Wang, Zhihai
Chen, Chen
Chen, Lei
Yu, Xianzhi
Liu, Wulong
Hao, Jianye
Yuan, Mingxuan
Li, Bin
author_facet Yang, Qingyue
Wang, Jie
Li, Xing
Wang, Zhihai
Chen, Chen
Chen, Lei
Yu, Xianzhi
Liu, Wulong
Hao, Jianye
Yuan, Mingxuan
Li, Bin
contents With the development of large language models (LLMs), efficient inference through Key-Value (KV) cache compression has attracted considerable attention, especially for long-context generation. To compress the KV cache, recent methods identify critical KV tokens through static modeling of attention scores. However, these methods often struggle to accurately determine critical tokens as they neglect the temporal patterns in attention scores, resulting in a noticeable degradation in LLM performance. To address this challenge, we propose AttentionPredictor, which is the first learning-based method to directly predict attention patterns for KV cache compression and critical token identification. Specifically, AttentionPredictor learns a lightweight, unified convolution model to dynamically capture spatiotemporal patterns and predict the next-token attention scores. An appealing feature of AttentionPredictor is that it accurately predicts the attention score and shares the unified prediction model, which consumes negligible memory, among all transformer layers. Moreover, we propose a cross-token critical cache prefetching framework that hides the token estimation time overhead to accelerate the decoding stage. By retaining most of the attention information, AttentionPredictor achieves 13$\times$ KV cache compression and 5.6$\times$ speedup in a cache offloading scenario with comparable LLM performance, significantly outperforming the state-of-the-arts. The code is available at https://github.com/MIRALab-USTC/LLM-AttentionPredictor.
format Preprint
id arxiv_https___arxiv_org_abs_2502_04077
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle AttentionPredictor: Temporal Patterns Matter for KV Cache Compression
Yang, Qingyue
Wang, Jie
Li, Xing
Wang, Zhihai
Chen, Chen
Chen, Lei
Yu, Xianzhi
Liu, Wulong
Hao, Jianye
Yuan, Mingxuan
Li, Bin
Computation and Language
Machine Learning
With the development of large language models (LLMs), efficient inference through Key-Value (KV) cache compression has attracted considerable attention, especially for long-context generation. To compress the KV cache, recent methods identify critical KV tokens through static modeling of attention scores. However, these methods often struggle to accurately determine critical tokens as they neglect the temporal patterns in attention scores, resulting in a noticeable degradation in LLM performance. To address this challenge, we propose AttentionPredictor, which is the first learning-based method to directly predict attention patterns for KV cache compression and critical token identification. Specifically, AttentionPredictor learns a lightweight, unified convolution model to dynamically capture spatiotemporal patterns and predict the next-token attention scores. An appealing feature of AttentionPredictor is that it accurately predicts the attention score and shares the unified prediction model, which consumes negligible memory, among all transformer layers. Moreover, we propose a cross-token critical cache prefetching framework that hides the token estimation time overhead to accelerate the decoding stage. By retaining most of the attention information, AttentionPredictor achieves 13$\times$ KV cache compression and 5.6$\times$ speedup in a cache offloading scenario with comparable LLM performance, significantly outperforming the state-of-the-arts. The code is available at https://github.com/MIRALab-USTC/LLM-AttentionPredictor.
title AttentionPredictor: Temporal Patterns Matter for KV Cache Compression
topic Computation and Language
Machine Learning
url https://arxiv.org/abs/2502.04077