<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Llm on Hammer's Blog</title><link>https://lkic1625.github.io/blog/llm/</link><description>Recent content in Llm on Hammer's Blog</description><generator>Hugo</generator><language>ko-kr</language><copyright>© 조원빈 - All rights reserved</copyright><lastBuildDate>Wed, 18 Nov 2026 21:15:11 +0900</lastBuildDate><atom:link href="https://lkic1625.github.io/blog/llm/index.xml" rel="self" type="application/rss+xml"/><item><title>KVCache부터 PagedAttention까지</title><link>https://lkic1625.github.io/kv-cache-paged-attention/</link><pubDate>Wed, 18 Nov 2026 21:15:11 +0900</pubDate><guid>https://lkic1625.github.io/kv-cache-paged-attention/</guid><description>&lt;h2 id="개요">개요&lt;/h2>
&lt;p>LLM을 서빙할 때 응답이 몇 토큰까지 이어질지는 미리 알기 어렵다. 그럼 요청마다 최대 길이만큼 메모리를 잡아 두면 될까? 응답이 짧거나 아직 생성 중이라면 빈 공간이 남는데, 다른 요청은 그 공간을 쓰지 못한다. &lt;strong>PagedAttention&lt;/strong>은 운영체제의 페이징에서 아이디어를 가져와, KV cache를 고정 크기 블록에 나눠 담고 필요한 만큼 연결한다. &lt;a href="#ref-1">[1]&lt;/a>&lt;/p>
&lt;h2 id="kv-cache란">KV cache란&lt;/h2>
&lt;p>우선 일반적인 decoder-only Transformer에서 토큰 하나를 처리하는 과정을 생각해 보자. causal self-attention에서는 지금 처리하는 토큰의 Query를 자기 위치와 이전 위치의 Key에 각각 비교하고, 여기서 나온 가중치를 각 위치의 Value에 곱해 더한다. 이전 토큰은 뒤에 붙은 토큰을 볼 수 없으므로, 시퀀스 끝에 토큰을 추가해도 이미 계산해 둔 각 레이어의 K와 V는 그대로 쓸 수 있다. 이 &lt;strong>재사용 가능성&lt;/strong>에서 KVCache가 필요하다.&lt;/p></description></item></channel></rss>