논문 해설
Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels
Gemma 4 K=V 캐시를 한 번만 저장하기: 어텐션 커널은 그대로 둔 채 paged 서빙 엔진에서 얻는 정확한 global-KV 메모리 절감
- 연구 문제 Gemma 4 global 층은 key와 value를 중복 저장해 KV 캐시가 커지며, 기존 서빙 엔진은 이 중복을 활용하지 못합니다.
- 연구 방법 key와 value를 640값 행 하나로 저장하고, 기존 paged attention 커널이 두 개의 겹치는 strided view로 읽게 합니다.
긴 문맥의 KV 캐시 비용
대형 언어 모델을 긴 문맥으로 서빙할 때 KV 캐시가 한 GPU가 동시에 처리할 수 있는 요청 수를 정합니다. Gemma 4 31B에서는 global attention 층 10개가 요청의 대부분의 캐시를 차지합니다. 이 global 층은 value projection이 없고 value가 key projection을 RMS 정규화한 값으로 정해지는 K=V 구조를 가집니다. 보고서는 이 설계로 global KV 캐시를 최대 37.5% 줄인다고 밝혔지만, 확인한 오픈 서빙 엔진들은 key와 value를 모두 저장해 1,024값을 씁니다. 이 논문은 그 중복을 실제 서빙 엔진에서 제거할 수 있는지를 묻습니다.
640값 행과 두 개의 view
저자들은 key와 value를 함께 담는 640값 행을 저장합니다. 행은 RoPE가 적용된 key 부분 128값, RoPE가 없는 value 부분 384값, 나머지 value 128값으로 구성됩니다. RoPE는 key 차원 중 4분의 1에만 적용되므로 나머지 384차원의 key는 value의 RMS 정규화 결과에 key-norm 가중치만 곱한 값이 됩니다. 따라서 query에 가중치를 미리 곱해 두면 unrotated 부분의 score를 value로 직접 계산할 수 있습니다. 이 과정을 식 (3)으로 설명하며, 저자들은 실수 산술에서 임의의 가중치에 대해 정확하다고 밝힙니다.
저장된 행은 두 개의 strided view로 읽힙니다. 앞의 512값은 key cache 역할을 하는 K view이고, 뒤의 512값은 value cache 역할을 하는 V view입니다. 두 view는 같은 메모리를 가리키므로 데이터를 복사하지 않습니다. 기존 Triton attention kernel은 key와 value를 별도 텐서로 받으므로 이 view들을 그대로 읽을 수 있습니다. attention 출력은 V view의 차원 순서로 나오므로 고정된 순열로 원래 모델 순서를 복원합니다.
vLLM 프로토타입의 구현 방식
프로토타입은 vLLM 0.33.0rc1 위에 세 부분을 패치로 추가해 구현했습니다. 첫째, global 층의 KV 명세를 640값 행과 48토큰 블록으로 바꿔 기존 할당기와 스케줄러가 그대로 동작하게 했습니다. 둘째, Triton 백엔드가 행을 head size에서 나누므로 래퍼를 두어 128값 value 캐시를 V view로 바꿨습니다. 셋째, 10개 global attention 모듈의 hook이 query 변환, 두 쓰기 피연산자, 출력 순열을 처리합니다. 블록 크기 48은 16의 배수 중 가장 큰 값으로, 245,760바이트 페이지를 262,144바이트로 패딩하는 비용이 따릅니다. 커널 소스는 바꾸지 않았고, 실행 시 변환이 decode step당 약 110개의 작은 커널을 추가합니다.
정확성과 최종 답 정확도
정확성 검증은 COMPACT와 EMULV를 비교합니다. EMULV는 같은 query와 출력 변환을 쓰되 기존 stock 캐시에서 계산하므로 차이는 캐시 배치에서만 나옵니다. 432개 prompt와 1,264개 log-probability 배열에서 두 arm의 출력은 모두 bit-identical이었습니다. 정확도 실험은 GSM8K 테스트 문제 400개와 7.7K 토큰 needle-retrieval 프롬프트 32개로 구성했고, greedy decoding과 eager mode에서 측정했습니다. 빌드 실행에서 COMPACT는 0.9769, STOCK은 0.9722의 정확도를 기록했습니다. 정답 변화는 +0.46포인트였고 Agresti–Min 95% 구간은 [−0.32, +1.24]였습니다.
저자들은 이 구간이 미리 정한 ±3포인트 margin 안에 있어 손실이 없다고 판단했습니다.
다만 base 정확도가 천장에 가깝고 긴 문맥 샘플은 needle 32개뿐이므로, 결과는 깨짐이 발견되지 않았다는 뜻이며 품질 동등성의 증명은 아닙니다. 정확도 실험의 긴 문맥 한계는 별도 절에서 다룹니다.
메모리와 decode 용량
KV 메모리 측정에서 한 요청의 steady decode footprint는 32K 토큰에서 1,349블록에서 1,008블록으로, 64K 토큰에서 2,373블록에서 1,690블록으로 줄었습니다. 이는 전체 층 기준 1.338배와 1.404배입니다. 이 절감은 global 층 값의 1.6배 절감이 페이지 패딩 뒤 1.5배로 줄고, sliding 층은 변하지 않는 구조에서 나옵니다.

Figure 2 : Measured in vLLM on one A100 with the 16-bit 31B model and a 15 GiB KV pool, in eager mode. (a) The steady decode KV memory of one request, all layers. (b) The decode tokens per second at the largest batch that the engine admits and decodes with no preemption; the batch size is in parentheses.
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.고정 배치 실험에서 32K 토큰일 때 15 GiB 풀은 stock 3개 대신 compact 4개를 담았고, decode 속도는 56.0에서 69.7 토큰/초로 1.24배 올랐습니다. 64K 토큰에서는 두 arm이 모두 2개 요청을 담았고 compact의 속도는 0.96배였습니다. 저자들은 이 이득이 한 요청이 더 들어가는 지점에 의존하는 용량 효과라고 해석합니다.
step 시간과 속도 상한
eager 모드의 평균 decode step은 같은 배치에서 32K 토큰일 때 8.7%, 64K에서 4.3% 느렸습니다. 변환 비용은 4.8%였고 compact 캐시 자체가 3.7%를 더했습니다. 저자들은 원인을 완전히 설명하지 못했으며, 전역 층 벤치마크는 CPU 실행 시간 비용이 큰 부분을 설명한다고 봅니다. 다만 이 실행은 출력 점검이 한 prompt에서 실패해 무효로 분류되었습니다.

Table 1 : Capacity in vLLM (one A100, 16-bit 31B, 15 GiB pool, eager mode). One block is one 262,144-byte page in each of the 10 layers of a group. The step-time ratio is compact over stock. Each throughput and step-time cell is one 128-step window of one engine process.
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 7쪽에서 그림 영역을 추출했습니다.
Table 3 : The experiments behind this paper and the outcomes of their frozen rules. The column “Used in this paper as” says how the paper uses each run: as the main result, as a result, as an exploratory result (the INVALID runs), as context or not at all. The GPU time of E-49 to E-59, with their rehearsals, cost about $21, and that of E-68 to E-73 about $28.
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 16쪽에서 그림 영역을 추출했습니다.
Figure 4 : Change of the median decode step time against the stock engine in the same mode, at 3 requests of 32K tokens (31B, one A100). The gray band is±2%. Exploratory: the output check of this run failed, for a reason that we think lies outside the timing windows. We chose the eager 128-step windows after the run, from windows that the profiler did not touch; the compact and stock eager windows come from different engine processes (two stock processes differed by 1.1%), and within one process the spread was 0.09%.
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 18쪽에서 그림 영역을 추출했습니다.따라서 바이트에 비례한 이득이라도 약 4% 수준이라고 계산됩니다. 이 절은 메모리 절감이 step 속도를 크게 올리지 않는다는 점을 보여 줍니다.
decode 노드에서의 용량 검증
이 절은 prefill과 decode를 나눈 두 A100 구성에서, 블록 풀 모델이 예측한 decode 토큰 비율 R_step을 실제 엔진이 얼마나 맞추는지 확인합니다. R_step은 compact의 작업 단계당 decode 토큰 수를 stock의 같은 값으로 나눈 비율입니다. D3H 실험(중앙값 prompt 16,384 토큰)에서 compact 엔진의 R_step은 1.376이었고, 같은 요청 순서에 대한 모델 예측은 1.364였습니다. D3Q 실험(중앙값 prompt 8,192 토큰)에서는 1.237이었고 모델 예측은 1.229였습니다. 두 값 모두 seed 0부터 4까지 넓힌 frozen band 안에 있었지만, band는 1%씩 넓힌 뒤에야 통과했습니다.

Table 2 : The decode-node tests (two A100-SXM4-80GB, 31B, 15 GiB decode pool, eager mode). The first D3H run ran stock twice (before and after compact). The repeat run ran the compact arm again with a longer NIXL lease (no lease expired), and it is compared with the stock arms of the first run. The model row gives the running requests per step for D3H / D3Q. The frozen band is the seed range widened by at least 1% on each side.
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.
Figure 3 : The decode-node tests against the frozen model prediction. (a) The capacity ratio: the gray box is the frozen band, the bar the range of the model over 5 seeds and 3 backlog depths, the circle the model for the engine’s request sequence, and the diamonds the engine runs. (b) The decode throughput ratio in eager mode against the model ranges with CUDA-graph and eager step costs (a report, single runs; the stock A/A spread of the throughput was 2.7%).
원문 · CC BY 4.0 · Bainsla, Kushagra · Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels · 원문 그림 인용 · 원본 PDF 10쪽에서 그림 영역을 추출했습니다.같은 절에서 NIXL 전송과 CPU offload 경로의 출력이 8개 prompt에서 emulation과 같았다는 결과도 보고됩니다.
적용 범위와 한계
정확 동등성과 정확도는 16-bit 캐시에서만 확인했습니다. 정확도 실험은 최종 답과 greedy decoding에 한정되며 가장 긴 prompt가 7.7K 토큰이어서 긴 문맥 전체의 동등성은 확인하지 않았습니다. prefix caching, tensor parallelism, speculative decoding과 32개 이상 동시 요청은 시험하지 않았습니다. 저자들은 이 방식이 K=V 중복이 있는 모델에 한정되며 다른 구조에서 흔하지 않다고 봅니다.
논문 정보
- 저자
- Bainsla, Kushagra
- 학회·저널
- arXiv · 프리프린트
- 최초 공개일
- 2026년 11월 17일
- 등록일
- 2026년 11월 19일
- 수정일
- 2026년 11월 17일
- 버전
- v1
- arXiv
- 2611.23035
- 분류
- cs.LG · cs.CL · cs.DC
- 원문 이용 조건
- CC BY 4.0
- 제공 범위
- 논문 정보, 해설, 허용된 원문 그림
AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.
초록
In the global attention layers of Gemma 4 31B, the value is the normalized key projection, and the key is the value scaled by a fixed weight, with rotary position encoding on one quarter of its dimensions. The Gemma 4 report states that this design reduces the global KV cache by up to 37.5%, but the open serving engines that we checked still store a full key and a full value: 1,024 values per KV head and token. We store one 640-value row instead, exact in real arithmetic, and an unchanged paged attention kernel reads it through two overlapping strided views as its key cache and its value cache. In a vLLM prototype with the 16-bit 31B model, the outputs are bit-identical to an emulation of the same arithmetic on the stock cache, 2 of 432 final answers differ from the stock engine (within its run-to-run noise), and the steady decode KV memory per request falls by a factor of 1.34 to 1.40 at 32K to 64K tokens. On a prefill/decode pair of two A100 GPUs with NIXL transfer and CPU offload, a decode engine with a full 15 GiB pool ran 1.38 times the stock decode tokens per step for 16K-token prompts (repeated to 0.06%) and 1.24 times for 8K-token prompts; a model of the vLLM block pool predicted both ratios to within 1% (the engine was 0.7% to 0.9% higher) and matched the change between them. The eager decode throughput rose by 1.30 and 1.11 times, and on this path the compact engine gave the same output tokens as the emulation for 8 prompts at batch 1. The run-time prototype makes an eager step 4% to 9% slower at equal batch, and the method does not yet stack with an 8-bit KV cache at the default scale.
원문 인용
Bainsla, Kushagra (2026). Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels. arXiv:2611.23035v1. https://arxiv.org/abs/2611.23035v1
BibTeX
@misc{kushagra2026storing,
title = {{Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels}},
author = {Bainsla, Kushagra},
year = {2026},
eprint = {2611.23035},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.23035v1}
}