Abstract
Vision-Language Large Models (VLLMs) face significant efficiency challenges when processing high-resolution inputs. The quadratic complexity in attention and autoregressive generation, as well as the constantly growing key value (KV) cache size, severely hinder the prefilling and decoding stages. Recent efforts have attempted to compress KV cache by identifying and pruning KV cache of less important tokens, but these methods typically rely on attention scores to estimate token importance, making them incompatible with efficient attention mechanisms such as FlashAttention and Sparse Attention, which do not explicitly compute attention matrices. Moreover, existing methods overlook how sparse attention, while accelerating the prefilling stage, alters the information structure of the KV cache, thereby compromising the effectiveness of downstream KV cache compression strategies. To address this issue, we propose PureKV, a plug-and-play framework for joint optimization of sparse attention and KV cache compression. We first introduce a KV cache compression strategy that is fully compatible with efficient attention accelerators. Our method utilizes lower layer attention scores to estimate the importance of high layers' KV cache, enabling active pruning without compromising accuracy. In addition, we have designed a Spatial-Temporal Sparse Attention (ST-SpAttn) module specifically tailored for video KV cache compression algorithms. This module combines spatial and temporal attention sparsity to improve the compression efficiency of KV cache optimization algorithms by purifying spatial noise and temporal redundancy in KV cache. At the same time, ST-SpAttn also accelerated the prefilling stage of VLLMs. Extensive experiments on VLLMs (VideoLLaMA2, Qwen2.5-VL) have shown that PureKV achieves 5.0 times KV cache compression and 3.16 times prefill acceleration, with negligible quality degradation.
Introduction
Vision-Language Large Models (VLLMs) like Qwen-VL or VideoLLaMA are powerful but computationally expensive. When processing high-resolution images or long videos, they generate a massive number of visual tokens, leading to two primary issues: memory bottlenecks from the Key-Value (KV) cache and quadratic computational complexity during the prefilling stage. While KV cache compression through pruning is a common solution, existing methods often require full attention matrix materialization to identify important tokens. This creates a conflict with high-performance kernels like FlashAttention, which achieve speed by avoiding the materialization of the full attention matrix. PureKV addresses this by decoupling importance estimation from the computation of higher layers.
Methodology
PureKV introduces two core innovations: Cross-Layer Importance Estimation (CLIE) and Spatial-Temporal Sparse Attention (ST-SpAttn).
Cross-Layer Importance Estimation (CLIE)
PureKV leverages the discovery that lower-layer attention scores are highly correlated with high-layer token importance. By calculating attention scores only in the initial "initiation" layers, PureKV can predict token importance and prune the KV cache in all subsequent layers. This allows higher layers to utilize highly optimized, "black-box" attention kernels like FlashAttention without losing the ability to compress the cache. To improve accuracy, these scores are weighted by the L2 norm of the Value (V) vectors, accounting for the actual magnitude of information each token contributes.
Spatial-Temporal Sparse Attention (ST-SpAttn)
Specifically designed for video data, ST-SpAttn employs structured sparsity to "purify" the KV cache. It utilizes:
- Spatial Sparsity: Tokens attend to the first frame (global context) and other tokens within their current frame.
- Temporal Sparsity: Tokens attend to the first frame and their direct "ancestor" token in the previous frame. This approach filters out background noise and temporal redundancy, ensuring that only the most salient information is preserved in the cache.
Experimental Results
The framework was evaluated on the MVBench and AVSD benchmarks using VideoLLaMA2 and Qwen2.5-VL-7B. PureKV achieved a 3.16× speedup in the prefilling stage, reducing latency from 0.1190 ms/token to 0.0355 ms/token. It maintained high accuracy even when the KV cache was compressed to just 10-20% of its original size.
Notably, on the MVBench benchmark with Qwen2.5-VL, PureKV with a 20% budget actually outperformed the full-cache baseline (0.5429 vs. 0.5136 average score). This suggests that the "purification" effect of ST-SpAttn and CLIE helps the model focus on critical information by removing noisy tokens that might otherwise degrade performance.
Conclusion
PureKV provides a robust, plug-and-play solution for VLLM efficiency. By utilizing cross-layer statistics and structured spatial-temporal sparsity, it overcomes the limitations of previous pruning methods that were incompatible with modern hardware accelerators. Future work may explore extending this cross-layer philosophy to other compression techniques, such as weight quantization or dynamic layer skipping.
Summary updated