Paper commentary
Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels
- Problem Not stated in the paper.
- Method Stores one 640-value row per global KV head and token, reads it through two strided views in an unchanged paged attention kernel, and folds the key-norm weight into the query.

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.
Original paper · 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 · Original paper figure · Extracted the figure area from page 6 of the original PDF.Why the global cache is the lever
In the 31B model the 50 sliding-window layers keep only the last 1,024 tokens, while the 10 global layers see the whole context with 4 KV heads of 512 dimensions. At long context the global layers therefore hold most of a request's cache, which makes them the place to look for savings.
The global layers have one more unusual property: they have no value projection. Their value is the RMS-normalized key projection, and their key is that value multiplied by a key-norm weight, with RoPE applied to 128 of the 512 dimensions.
One 640-value row read two ways
The construction starts from the relation that ties the value to the key projection: the value is \(v = \mathrm{RMSNorm}(y)\), and the key is \(k = \mathrm{RoPE}_p(w \odot v)\), where \(w\) is the key-norm weight and \(p = 0.25\). RoPE pairs dimension i with i + 256 and only 64 of the 256 pairs rotate, so 128 dimensions form the rotated set and the other 384 form the unrotated set.
On the unrotated set RoPE is the identity, so the stored key there is just \(w_U \odot v_U\), which needs no separate storage. What must be stored is therefore 512 values plus the 128 rotated key values, 640 values in place of 1,024, which is 37.5% fewer values.
The row is \(r = [k_R \mid v_U \mid v_R]\), with 128, 384 and 128 values in its three parts. Its first 512 values form the K view, \([k_R \mid v_U]\), which is the key that the query identity needs. Its last 512 values, starting at value 128, form the V view \([v_U \mid v_R]\), which holds the value in a permuted dimension order.
For a query \(q\), the dot product splits into a rotated term and an unrotated term, \(q \cdot k = q_R \cdot k_R + (q_U \odot w_U) \cdot v_U\), so the key-norm weight moves onto the query. The folded query \(q' = [q_R \mid q_U \odot w_U]\) then reads the key as \([k_R \mid v_U]\), which is exact in real arithmetic for any \(w\) because RoPE does not touch the unrotated part.
The method is exact in real arithmetic only: with 16-bit numbers the stock cache rounds the unrotated key and the value separately, while the compact score uses a rounded value and a rounded folded query.
Fitting the row into vLLM
A stock global page of 32 tokens with 4 heads of 1,024 values has the same byte size as a sliding-layer page of 16 tokens, but a compact global page needs 640 values per token. The largest block size that fits the rule of 16-token multiples is 48 tokens, which takes 245,760 bytes and is padded by the engine to 262,144 bytes, leaving 6.25% of the padded page unused.
The padding comes from the page unifier, which makes all layer groups use one page size in bytes.
The prototype was built on vLLM 0.33.0rc1.dev229+g3966924d5 with its Triton attention backend, and it has three parts installed before the engine starts. The KV specification reports 640 values per head and token with a 48-token block, so the stock allocator, page unifier and scheduler plan the pool without other change.
No kernel source code was changed; the wrappers and hooks change only Python calls, and the transforms launch about 110 small kernels per decode step. Folding the fixed weights into the query-norm weight and into the input columns of the output projection at load time would remove most of these kernels, but the folds change rounding and need their own output check, which was not run.
Exactness and accuracy against the stock engine
The accuracy set has 432 items: 400 GSM8K test problems and 32 needle-retrieval prompts of 7.7K tokens, decoded greedily in chat format.
COMPACT and EMULV gave bit-identical outputs on all 432 prompts and on all 1,264 recorded arrays of prompt log-probabilities. Because EMULV differs from COMPACT only in the cache layout, this identity isolates the layout from the arithmetic of the transforms.
On the build run COMPACT scored 0.9769 and STOCK 0.9722, which is 422 and 420 of 432 answers, a change of +0.46 points.
Only the 32 needle prompts reach 7.7K tokens, so the accuracy test does not reach the context lengths where the saving matters most.
Memory and capacity at 32K and 64K tokens
At 64K tokens it fell from 2,373 to 1,690 blocks, a factor of 1.404. In GiB across all layers, that is 3.29 against 2.46 at 32K and 5.79 against 4.13 at 64K.
The sliding blocks do not change, while the global blocks fall by the factor 1.5 after page padding, which is why the all-layer saving is 1.34 to 1.40 rather than the ideal 1.6 of the global values.
Step cost of the run-time transforms
At 32K the transforms cost 4.8% and the compact cache another 3.7%, measured in two engine processes. The cause of the rest is not known.
The output check of that run failed for 1 of 3 prompts, so the run is invalid under its own rule and is used only as exploratory evidence. The profile shows that the compact cache cut attention kernel time by 0.49 ms per step while the 110 transform kernels added 0.46 ms.
At 3 requests of 32K tokens one decode step reads about 62 GB of 16-bit weights and about 10.6 GB of KV, so the weights carry about 85% of the bytes read.
Capacity on a decode node with NIXL and CPU offload
Two operating points differ in prompt length: D3H with a median prompt of 16,384 tokens and D3Q with 8,192, both with a median output of 2,048 tokens.
The block pool model is a discrete-step simulator that follows the engine's rules for admission, a token budget of 2,048 per step, preemption of the most recently admitted request, and a CPU tier. The model gives this ratio for the exact request sequence of the engine and over seeds 0 to 4 with backlog depths 2, 3 and 8.
The two stock runs agreed to 0.03%, and a repeat compact run, in another session on another host, gave 1.377. At D3Q the ratio was 1.237, against 1.229 in the model. Both values lie inside their frozen bands only because those bands were widened by 1%, and the engine sits 0.9% (D3H) and 0.7% (D3Q) above the top of the model range.
Under a stream of mixed request lengths the smaller footprint turns into a steady gain, unlike the fixed-batch test of the memory section.
In the repeat run the compact engine was compared with EMULV on the same two-GPU path: eight needle prompts of 7,666 tokens were prefilled one at a time and each decoded 64 tokens with ignore_eos.
The repeat run used a 600 s lease, and with no expired lease it repeated the compact value to 0.06%.
Limits of the evidence
Prefix caching, tensor parallelism, speculative decoding and more than 16 concurrent sequences were not tested. The load-time folds and the default piecewise graph mode with torch.compile were not tested, and no hardware counters for DRAM traffic were available.
Paper info
- Authors
- Bainsla, Kushagra
- Venue
- arXiv · Preprint
- First published
- 2026-11-17
- Added
- 2026-11-19
- Updated
- 2026-11-17
- Version
- v1
- arXiv
- 2611.23035
- Category
- cs.LG · cs.CL · cs.DC
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
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.
Quote from the paper
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}
}