RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Behnam, Payman, Fu, Yaosheng, Zhao, Ritchie, Tsai, Po-An, Yu, Zhiding, Tumanov, Alexey
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866909735921385472
author Behnam, Payman
Fu, Yaosheng
Zhao, Ritchie
Tsai, Po-An
Yu, Zhiding
Tumanov, Alexey
author_facet Behnam, Payman
Fu, Yaosheng
Zhao, Ritchie
Tsai, Po-An
Yu, Zhiding
Tumanov, Alexey
contents Transformer-based Large Language Models rely critically on the KV cache to efficiently handle extended contexts during the decode phase. Yet, the size of the KV cache grows proportionally with the input length, burdening both memory bandwidth and capacity as decoding progresses. To address this challenge, we present RocketKV, a training-free KV cache compression strategy containing two consecutive stages. In the first stage, it performs coarse-grain permanent KV cache eviction on the input sequence tokens. In the second stage, it adopts a hybrid sparse attention method to conduct fine-grain top-k sparse attention, approximating the attention scores by leveraging both head and sequence dimensionality reductions. We show that RocketKV provides a compression ratio of up to 400$\times$, end-to-end speedup of up to 3.7$\times$ as well as peak memory reduction of up to 32.6% in the decode phase on an NVIDIA A100 GPU compared to the full KV cache baseline, while achieving negligible accuracy loss on a variety of long-context tasks. We also propose a variant of RocketKV for multi-turn scenarios, which consistently outperforms other existing methods and achieves accuracy nearly on par with an oracle top-k attention scheme. The source code is available here: https://github.com/NVlabs/RocketKV.
format Preprint
id arxiv_https___arxiv_org_abs_2502_14051
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression
Behnam, Payman
Fu, Yaosheng
Zhao, Ritchie
Tsai, Po-An
Yu, Zhiding
Tumanov, Alexey
Computation and Language
Machine Learning
Transformer-based Large Language Models rely critically on the KV cache to efficiently handle extended contexts during the decode phase. Yet, the size of the KV cache grows proportionally with the input length, burdening both memory bandwidth and capacity as decoding progresses. To address this challenge, we present RocketKV, a training-free KV cache compression strategy containing two consecutive stages. In the first stage, it performs coarse-grain permanent KV cache eviction on the input sequence tokens. In the second stage, it adopts a hybrid sparse attention method to conduct fine-grain top-k sparse attention, approximating the attention scores by leveraging both head and sequence dimensionality reductions. We show that RocketKV provides a compression ratio of up to 400$\times$, end-to-end speedup of up to 3.7$\times$ as well as peak memory reduction of up to 32.6% in the decode phase on an NVIDIA A100 GPU compared to the full KV cache baseline, while achieving negligible accuracy loss on a variety of long-context tasks. We also propose a variant of RocketKV for multi-turn scenarios, which consistently outperforms other existing methods and achieves accuracy nearly on par with an oracle top-k attention scheme. The source code is available here: https://github.com/NVlabs/RocketKV.
title RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache Compression
topic Computation and Language
Machine Learning
url https://arxiv.org/abs/2502.14051