카테고리 없음

[2026-1] 정인아 - VL-Cache: Sparsity and Modality-Aware KV Cache Compression for Vision-Language Model Inference Acceleration

kino(키노) 2026. 9. 13. 03:02

논문 제목 : VL-Cache: Sparsity and Modality-Aware KV Cache Compression for Vision-Language Model Inference Acceleration (ICLR 2025)

논문 링크 : https://arxiv.org/abs/2410.23317

 

Summary

  • 기존 KV cache compression은 주로 LLM을 대상으로 설계되어 있는데, LLM용 방법을 VLM에 그대로 적용하기에 VLM에는 vision/text 서로 다른 modality의 token이 섞여 있기 때문에 문제가 된다.
  • 구체적으로 1) visual token과 language token의 attention pattern이 다르고, 2) layer마다 attention sparsity도 크게 다르다.
  • 따라서, VL-Cache는 1) Sparsity-aware cache budget allocation, 2) Modality-aware token scoring 방법을 제안한다.

 

Introduction

기존 LLM KV compression을 그대로 쓰면 안된다.

  • Transformer 기반 모델들은 autoregressive decoding을 하기 때문에, 매 decoding step마다 이전 context를 다시 계산하지 않기 위해 이전 token들의 Key와 Value를 KV cache에 저장한다.
  • VLM은 LLM과 달리 고해상도 이미지, 비디오처럼 긴 visual context를 처리하기 때문에 visual token 수가 급격히 증가한다.
  • 이는 단순히 memory만 많이 쓰는 게 아니라, HBM ↔ SRAM 간 데이터 이동량도 증가해서 inference latency까지 커지는 문제가 있다.
  • 따라서 VLM의 KV cache compression은 필수적이다. 그럼 기존 KV compression 분야 방법론은 어떻게 KV cache를 최적화하는가?
  • 주로 KV compression 분야는 LLM을 대상으로 발전되어 왔다. 그러나 VLM은 vision/text 서로 다른 modality의 token이 섞여 있기 때문에 기존 LLM KV compression 분야를 그대로 적용하기에 몇가지 문제가 발생한다.
    • 1) visual token과 language token의 attention pattern이 다르다.
    • 2) layer마다 attention sparsity(Attention matrix에서 실질적으로 무시해도 될 정도로 작은 attention이 얼마나 많은가)가 다르다.

 

 

Method

Q. 각 layer에 얼마나 많은 KV cache를 남길 것인가?

  • attention matrix를 sparsify를 하기 위해 threshold보다 작은 값을 0으로 만든다.

  • 이후 전체 entry에서 0이 된 비율을 r로 정의하고, 이 r이 각 레이어의 attention sparsity다. 예를 들어 r이 0.9라면 해당 레이어의 attention 중. 0%가 거의 의미 없는 attention을 가지고 있다는 뜻이다.

  • 이때 아래 그림을 보면 prefill 단계에서 layer별 sparsity pattern과 decoding 단계의 sparsity pattern이 상당히 비슷하다는 것을 직관적으로 알 수 있으며, 구체적으로 측정한 결과 평균 shape similarity가 약 0.695라고 한다.
    • 즉, decoding을 하기 전에 이미 prefill이 끝나있기 때문에, decoding attention을 직접 보지 않고도 어떤 레이어가 cache를 많이 필요로 하는지 미리 판단할 수 있다는 것이다.

 

Sparsity-Aware Cache Budget Allocation

  • KV cache budget을 α라고 할 때, 기존 LLM KV cache compression 일부는 모든 레이어에 α 만큼 cache를 사용해왔다.
  •  그러나 VL-cache는 레이어별 sparsity r를 사용한다.
    • 어떤 레이어에서 r이 작으면 중요한 attention이 작으므로 cache를 적게 사용하고, 다른 레이어에서 r이 크다면, dense attention이기 때문에 cache를 많이 보존할 수 있다.
    • 즉, 고정된 값이 아니라 prompt-dependent하게 레이어별로 서로 다른 budget을 사용할 수 있다.

β 는 해당 레이어에 실제로 할당되는 KV cache 비율

 

Q. 해당 layer 안에서 어떤 token을 남길 것인가?

  • 해당 레이어에 β 만큼 남긴다고 할 때 구체적으로 어떤 token을 남길 지 확인하기 위해 저자들은 CacheHitRate라는 metric을 사용한다.
    • CacheHitRate는 실제로 decoding할 때 중요한 token 중 몇 %를 잘 보존했는가를 측정하는 metric이다.
    • $S_{ψ^∗}$는 실제 decoding 첫 token의 attention을 알 수 있다면 가장 중요한 Top-K token의 ideal set
    • $S_{ψ}$는 compression algorithm이 선택한 token set

  • 기존 token scoring의 경우, 1) 전체 prompt query의 attention을 모두 누적하거나, 2) 최근 w개의 query token만 누적하는 방식이었다.
    • 그러나 전체 query를 합치면 중요한 visual signal들이 묻힐 수 있고,
    • 최근 w개만 사용한다고 해도 prompt마다 image뒤의 question 길이가 다르기 때문에 동일한 w 값을 쓰는 게 최적이기 어렵다.

 

Accumulated Post-Vision Attention

  • fixed window 대신에 image 이후에 나오는 language tokens 들만 사용하여 attention을 계산하여 future decoding이 필요한 token들을 추정한다.
  • post vision attention을 했을 때 기존 방법론들 보다 높은 CacheHitRate를 보였다.

(전체 pipeline)

VL-Cache Overview

 

Experiment

Setting

  • Models
    • LLaVA-v1.6-Mistral-7B
      • Vision encoder: CLIP ViT-L/14-336
      • Language model: Mistral-7B-Instruct
      • Attention: GQA
    • LLaVA-v1.6-34B
      • Vision encoder: CLIP ViT-L/14-336 (동일한 vision encoder)
      • Language model: Nous-Hermes-2-Yi-34B
      • Attention: MHA
  • Datasets
    • COCO-Caption
    • DocVQA
    • MathVista
  • Baselines
    • Full KV Cache
    • StreamingLLM
    • H2O
    • PyramidKV
    • VL-Cache
  • Results