Q-Filters: 효율적인 KV 캐시 압축을 위한 QK 기하학 활용
Q-Filters: Leveraging QK Geometry for Efficient KV Cache Compression
March 4, 2025
저자: Nathan Godey, Alessio Devoto, Yu Zhao, Simone Scardapane, Pasquale Minervini, Éric de la Clergerie, Benoît Sagot
cs.AI
초록
자기회귀 언어 모델은 생성 과정에서 과거 은닉 상태를 재계산하지 않아도 되도록 키-값(KV) 캐시를 사용하며, 이로 인해 더 빠른 생성이 가능합니다. 모델 크기와 컨텍스트 길이가 증가함에 따라 KV 캐시는 메모리 병목 현상의 주요 원인이 되며, 이는 생성 중에 크기를 제한하는 압축 방법의 필요성을 촉구합니다. 본 논문에서는 어텐션 맵을 계산하지 않고도 어텐션 점수를 효율적으로 근사할 수 있도록 하는 쿼리(Q)와 키(K) 벡터의 놀라운 특성을 발견했습니다. 우리는 단일 컨텍스트-불특정 투영을 기반으로 덜 중요한 키-값 쌍을 필터링하는 훈련이 필요 없는 KV 캐시 압축 방법인 Q-Filters를 제안합니다. 많은 대안과 달리, Q-Filters는 어텐션 가중치에 직접 접근할 필요가 없기 때문에 FlashAttention과 호환됩니다. 장문 컨텍스트 설정에서의 실험 결과는 Q-Filters가 검색 작업에서는 SnapKV와 같은 어텐션 기반 압축 방법과 경쟁력을 보이며, 생성 설정에서는 Streaming-LLM과 같은 효율적인 압축 방식을 꾸준히 능가함을 보여줍니다. 특히, Q-Filters는 x32 압축 수준에서 needle-in-a-haystack 작업에서 99%의 정확도를 달성하며, 텍스트 생성에서 Streaming-LLM 대비 생성 perplexity 하락을 최대 65%까지 감소시킵니다.
English
Autoregressive language models rely on a Key-Value (KV) Cache, which avoids
re-computing past hidden states during generation, making it faster. As model
sizes and context lengths grow, the KV Cache becomes a significant memory
bottleneck, which calls for compression methods that limit its size during
generation. In this paper, we discover surprising properties of Query (Q) and
Key (K) vectors that allow us to efficiently approximate attention scores
without computing the attention maps. We propose Q-Filters, a training-free KV
Cache compression method that filters out less crucial Key-Value pairs based on
a single context-agnostic projection. Contrarily to many alternatives,
Q-Filters is compatible with FlashAttention, as it does not require direct
access to attention weights. Experimental results in long-context settings
demonstrate that Q-Filters is competitive with attention-based compression
methods such as SnapKV in retrieval tasks while consistently outperforming
efficient compression schemes such as Streaming-LLM in generation setups.
Notably, Q-Filters achieves a 99% accuracy in the needle-in-a-haystack task
with a x32 compression level while reducing the generation perplexity drop by
up to 65% in text generation compared to Streaming-LLM.Summary
AI-Generated Summary