정의

DeepSeek-V4에 도입된 Sparse Attention은 전체 컨텍스트 중 일부 토큰만 선택적으로 참조하여 long-context에서의 연산량과 KV cache 메모리를 획기적으로 줄이는 attention 메커니즘이다. 기존 dense attention의 제곱 복잡도를 극복하기 위해 압축(compression), top‑k 선택, sliding window를 결합한 세 가지 구성 요소로 설계되었다.

핵심 속성

  • 압축률: KV cache를 4분의 1로 압축한 후 top‑k만 attention 수행 (Heavily Compressed Attention)
  • 연산량 감소: Pro 기준 dense attention 대비 연산량 27% 수준, 메모리 소비량 10% 수준
  • 구성 요소: Sliding Window Attention + Compressed Global Attention (100:1 압축) + Heavily Compressed Sparse Attention (압축 후 top‑k)
  • 학습 방식: 초기 1T 토큰은 dense attention으로 warm‑up, 이후 30T+ 토큰은 sparse attention으로 pre‑training
  • Lightning Indexer: 압축된 KV cache에서 top‑k를 경량 연산으로 찾아내는 모듈

관계

인용

“attention은 기본적으로 하나의 토큰에서 그 이전의 모든 토큰을 참조해야 되는 거죠. 그렇기 때문에 sequence의 길이가 길어지면 연산 요구량이 계속 크게 증가합니다. 이 증가 속도를 굉장히 크게 감소시킨 거죠.”

출처

클리핑 · youtu.be