論文解説
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キャッシュを一度だけ保存する:attentionカーネルはそのままに、pagedサービングエンジンで得られる正確なglobal-KVメモリ削減
- 課題 Gemma 4のglobal層はkeyとvalueを重複して保存するため、KVキャッシュが大きくなります。既存のサービングエンジンはこの重複を活用できていません。
- 手法 keyとvalueを640値の1つの行に保存し、既存のpaged attentionカーネルがその行を重なり合う2つのstrided viewとして読み込めるようにします。
長い文脈におけるKVキャッシュのコスト
大規模言語モデルを長い文脈でサービングするとき、KVキャッシュによって1つのGPUが同時に処理できるリクエスト数が決まります。Gemma 4 31Bでは、global attention層10個がリクエストのキャッシュの大部分を占めます。このglobal層にはvalueの射影がなく、valueはkeyの射影をRMS正規化した値で決まるK=V構造をもちます。報告書では、この設計によってglobal KVキャッシュを最大37.5%減らせると述べられていますが、確認したオープンなサービングエンジンはkeyとvalueの両方を保存し、1,024値を使っています。この論文は、その重複を実際のサービングエンジンで取り除けるかを問うものです。
640値の行と2つの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)で説明されており、著者らは実数演算では任意の重みに対して正確だと述べています。
保存された行は、2つのstrided viewとして読み込まれます。前の512値はkeyキャッシュの役割をするK viewで、後ろの512値はvalueキャッシュの役割をするV viewです。2つのviewは同じメモリを指すため、データはコピーしません。既存のTriton attentionカーネルはkeyとvalueを別々のテンソルとして受け取るので、これらのviewをそのまま読み込めます。attentionの出力はV viewの次元順で出てくるため、固定の順列によって元のモデルの順序に戻します。
vLLMプロトタイプの実装方法
プロトタイプは、vLLM 0.33.0rc1の上に3つの部分をパッチとして追加して実装しました。1つ目は、global層のKV仕様を640値の行と48トークンのブロックに変え、既存のアロケータとスケジューラがそのまま動くようにしたことです。2つ目は、Tritonバックエンドが行をhead sizeで分割するため、ラッパーを置いて128値のvalueキャッシュをV viewに変えたことです。3つ目は、10個のglobal attentionモジュールのhookが、query変換、2つの書き込みオペランド、出力の順列を処理することです。ブロックサイズ48は16の倍数のうち最大の値で、245,760バイトのページを262,144バイトにパディングするコストが伴います。
カーネルのソースは変更せず、実行時の変換によってdecodeステップあたり約110個の小さなカーネルが追加されます。
正確性と最終的な答えの精度
正確性の検証では、COMPACTとEMULVを比較しています。EMULVは同じqueryと出力変換を使いますが、既存のstockキャッシュから計算するため、違いはキャッシュの配置からのみ生じます。432個のpromptと1,264個のlog-probability配列で、2つの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ポイントのマージン内に収まるため、損失はないと判断しています。
ただし、base精度は上限に近く、長い文脈のサンプルはneedleが32個しかないため、この結果は劣化が見つからなかったことを意味するものであり、品質の同等性を証明するものではありません。精度実験における長い文脈の限界は、別の節で扱います。
メモリとdecodeの容量
KVメモリの測定では、1つのリクエストの定常的なdecodeフットプリントが、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トークンでは、両アームとも2個のリクエストを格納し、compactの速度は0.96倍でした。著者らは、この利得は1つのリクエストが追加で入る地点に依存する容量の効果だと解釈しています。
step時間と速度の上限
eagerモードの平均decodeステップは、同じバッチで32Kトークンのとき8.7%、64Kトークンのとき4.3%遅くなりました。変換コストは4.8%で、compactキャッシュ自体が3.7%を加えました。著者らは原因を完全には説明できていないとしたうえで、global層のベンチマークではCPUの実行時間コストが大きな部分を占めると見ています。ただし、この実行は出力チェックが1つの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を分けた2基の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オフロード経路の出力が、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
- 掲載内容
- 論文情報・解説・論文の図
この解説は、Refivuの韓国語解説を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}
}