Manuscript Offprint
arXiv:2611.23035Storing the Gemma 4 K=V Cache Once: Exact Global-KV Memory Savings in a Paged Serving Engine with Unchanged Attention Kernels
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
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.
1 Introduction
The KV cache sets the number of long requests that one GPU can serve. Paged serving engines such as vLLM [1] keep the cache in fixed-size blocks and admit a request only when its blocks fit in the pool. A smaller cache per request therefore allows a larger batch and more decode tokens per second, until the GPU becomes compute bound.
Gemma 4 [2] uses two layer types. In the 31B model, 50 sliding-window layers attend to the last 1,024 tokens with 16 KV heads of 256 dimensions, and 10 global layers attend to the whole context with 4 KV heads of 512 dimensions. At long context the global layers hold most of the cache of a request. They also have a special structure, which the model configuration calls attention_k_eq_v: they have no value projection. The value is the RMS-normalized key projection, and the key is that value multiplied by the key-norm weight, with rotary position encoding (RoPE) [3] on 128 of the 512 dimensions. The Gemma 4 report states that this design reduces the global KV cache by up to 37.5% [2]. The 26B-A4B and 12B models use the same design; the E2B and E4B models do not.
The open serving engines that we checked do not realize this saving: they store 1,024 values per KV head and token in these layers (Section 7). This paper shows how to store 640 values that an unchanged paged attention kernel can read, and it measures what this gives in vLLM. The kernel reads the 640-value row through two views: a view is a window on the same memory with its own shape and strides, so no data is copied (Figure 1).
k_{\mathcal{R}}$$v_{\mathcal{U}} (384)row :K view: values 0 to 511 V view: values 128 to 639
Figure 1: The compact row of one global KV head and token (640 values instead of 1,024). A stock attention kernel reads the K view and the V view as its two caches. The query carries on its unrotated part (Eq. (3)), and the output is permuted back to the model order.
We do not claim the saving, the shape of the stored row or the exact cache reduction as new. The Gemma 4 report states the saving. Multi-head latent attention (MLA) [4] caches a shared part plus a separate RoPE part, and its decode kernels read the key and the value from one cached row [5]. Slim attention [6] caches only the keys of multi-head attention layers and computes the values from them with a matrix product. Our two-view read is the MLA decode layout specialized to equal key and value widths, so that kernels that require equal key and value head sizes read the shared buffer unchanged; our searches targeted Gemma 4 and its engines, not this layout in general. Our contributions are:
- A compact row and a two-view read. One row of 640 values per KV head and token holds the rotated part of the key and the whole value. A stock paged attention kernel reads it through two overlapping strided views; the key-norm weight folds into the query, and a fixed permutation restores the output order. The method is exact in real arithmetic (Section 3).
- A checked vLLM prototype. Its outputs are bit-identical to an emulation of the same arithmetic on the stock cache, and its final answers stay within noise of the stock engine (Sections 4 and 5.1).
- Measurements and a speed bound. We measure the memory per request, the batch that a fixed pool holds and the step cost of the prototype. A byte count shows why the smaller cache gives little speed per step at these batch sizes: the weights are about 85% of the bytes that a decode step reads (Sections 5.2 to 5.4).
- A test in a serving decode node. The compact cache works with the vLLM CPU offload connector and, with a small patch for the pinned build, with NIXL transfer from a prefill engine. On a two-GPU prefill/decode pair whose decode pool stays full, the compact decode engine ran 1.38 and 1.24 times the stock decode tokens per step at two operating points. A model of the block pool, frozen before each run, 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 the compact engine gave the same output tokens as the emulation for 8 prompts at batch 1 (Section 6).
An 8-bit (FP8) KV cache halves all KV bytes, but it is lossy. We tested the compact row with FP8 only at the kernel level (Appendix D), so we do not claim that the two savings stack.
Gemma 4 global attention.
Let be the input of a global layer and the key projection of one KV head (). The layer has no . It computes
where has no learned scale for . Here is the weight of the key norm as the model applies it (one vector per layer, shared by all KV heads), and rotates a fraction of the dimensions (p-RoPE [7]). RoPE pairs dimension with dimension , and only 64 of the 256 pairs have a nonzero frequency. So the rotated set is (), and the unrotated set holds the other 384 dimensions. In words: one quarter of the dimensions carry the token position, and three quarters do not. On , RoPE is the identity, so
The 31B model has 32 query heads, so 8 query heads share each global KV head. The query is , where qnorm is the RMS norm of the query. The global layers use an attention scale of 1.0 and no soft-cap on the attention logits.
Paged KV caches.
vLLM [1] keeps the KV cache in a fixed pool of GPU memory, which it splits into blocks of tokens; a block holds one page in each layer of a group. For a hybrid model, the vLLM version that we used [8] splits the layers into groups of equal size; for Gemma 4 31B these are 5 sliding groups and 1 global group, with 10 layers each. All groups must use one page size in bytes. The code that enforces this, which we call the page unifier, grows the block size of a group whose page divides the largest page, and otherwise pads the smaller page. The scheduler admits a waiting request, that is, starts its prefill, only if its blocks fit: at this commit the option scheduler_reserve_full_isl (ISL: input sequence length) is on by default, so the full prefill reservation must fit in the free blocks. If a running request needs a block and none is free, the engine preempts a request: it stops that request and computes it again later. The Triton [9] attention backend of vLLM takes the key cache and the value cache as two tensors with explicit strides, and it writes new keys and values with a separate cache-write kernel.
Eager mode and CUDA graphs.
In eager mode, the engine launches each GPU kernel of a decode step from Python, so many small kernels cost CPU time. With CUDA graphs, it records the kernels of a decode step once and replays them with one launch.
3 Method
What to store.
By Eq. (2), the pair of a head and token is a function of : is , and is a fixed model weight. So 512 + 128 = 640 values hold what the stock cache stores in 1,024 values, which is 37.5% fewer values.
Why not 512 values.
Since , the value and the token position determine the whole key, so 512 values would be enough (50% instead of 37.5%). But the rotation angle differs for each cached token, so it cannot be applied once to the query; a 512-value row needs a new kernel that rotates for each token while it reads the cache. We keep the 128 values of so that an unchanged kernel can read them.
Scores without .
For a query of a head that reads this KV head,
So with the folded query , the key can be read as . The fold is exact in real arithmetic for any , because RoPE does not touch .
The row and its two views.
We store, per KV head and token, the row
Its first 512 values, , are the key that Eq. (3) needs (the K view). Its last 512 values, , are the value in a permuted dimension order (the V view). Figure 1 shows the layout. Both views are strided tensors over the same buffer, with the same block, token and head strides and start offsets of 0 and 128 values, so a kernel that takes separate key and value caches with strides reads them unchanged. The attention output comes in the V-view order , and a fixed permutation restores the model order before the output projection.
Writing.
The stock cache-write operation stores a key and a value per token. One call fills the row: we give it as the key, for the K view, and as the value, for the V view. The key write and the value write put the same values into the shared region , so their order does not matter. With an FP8 cache, the two writes must use one scale for the shared region, so the key scale and the value scale of a layer must be tied (Appendix D).
Exactness.
In real arithmetic the scores and the outputs equal those of the stock cache. In 16-bit arithmetic the method is not bit-exact. Let be the normalized key projection in 32-bit arithmetic. The stock cache stores as one rounding of and as one rounding of ; the compact score uses the rounded with a rounded instead, so the roundings differ. The permuted order of the dimensions also changes the order of the floating-point sums. Neither layout is the real-arithmetic reference. Section 5.1 measures the effect on the answers of the model.
Page plan.
A sliding-layer page of the 31B model holds 16 tokens 16 heads 256 dimensions 2 (key and value) 2 bytes bytes, and a stock global page holds 32 tokens 4 heads 1,024 values 2 bytes, the same size. A compact global page of tokens needs bytes. The block size must be a multiple of 16 tokens, and the largest one that fits is (245,760 bytes). The engine pads this page to 262,144 bytes, so 6.25% of the padded page is unused, and the bytes per token of a global layer fall from 8,192 to 5,461, a factor of 1.5 against the ideal 1.6. The same plan gives a 48-token block for the 26B-A4B model and a 96-token block for the 12B model, with the same padding. An open vLLM proposal for a packed block stride with unequal page sizes [10] could remove the padding if it is adopted.
4 Implementation in vLLM
We built the prototype on vLLM 0.33.0rc1.dev229+g3966924d5 with its Triton attention backend. The vLLM log states that it forces this backend for Gemma 4 on the A100, because the two layer types have different head sizes and FlashAttention-4 is not available there. The prototype has three parts, installed as patches before the engine starts:
- The KV specification. The global layers report 640 values per head and token and a block of 48 tokens. The stock allocator, page unifier and scheduler then plan and manage the pool with no other change.
- The V view. The Triton backend splits a cache row at the head size, so a 640-value row gives a correct K view and a value cache of only 128 values. Small wrappers of the attention and cache-write entry points replace that value cache with the V view (a strided view, no copy).
- The transforms. Module hooks on the 10 global attention layers form the folded and permuted query of Eq. (3) after RoPE, form the two write operands and permute the output back.
The attention kernels are unchanged: we changed no kernel source code, and the wrappers and hooks change only Python calls. The run-time transforms launch about 110 small kernels per decode step of the 10 global layers. Because the weights are fixed, a production version could fold into the query-norm weight and the output permutation into the input columns of at load time, which removes most of these kernels. These folds change the rounding or the order of the sums, so they need their own output check, which we did not run. The query permutation must follow RoPE, because RoPE pairs dimension with dimension . So either the permutation stays a run-time gather, or the RoPE operation takes a permuted index map.
5 Evaluation
Setup.
The engine runs of this section used one A100 SXM 80GB (Section 6 uses two GPUs), vLLM 0.33.0rc1.dev229+g3966924d5, Triton 3.8.0 and the 16-bit google/gemma-4-31B-it checkpoint, with a 16-bit KV cache, no prefix caching and at most 2,048 batched tokens per step. The build, capacity and step-time runs used a fixed KV pool of 15 GiB (6,144 blocks) and at most 16 sequences; the 16-bit weights (62.6 GB) leave about this much of the GPU memory for the cache. The engine ran in eager mode unless we say otherwise. Appendix F gives all settings.
Compared configurations.
We call each configuration that we compare an arm. STOCK is the unmodified engine and cache. COMPACT is the prototype with the 640-value row. EMULV is the stock cache with the same query and output transforms as COMPACT: it computes the same arithmetic on the stock cache, so a difference between COMPACT and EMULV can come only from the cache layout. The accuracy study also has a noise arm, which adds one extra 16-bit rounding of the query to show how large a harmless rounding change looks, and a positive control, the stock 8-bit cache at a KV scale of 1.0, which we expected to change more answers.
Rules.
For each experiment we recorded the question and a pass-or-fail rule before the run, and we changed a rule only before the data of the run that it governs. We call a run invalid if a validity check that we set before the run failed. This does not mean that its numbers are wrong, but we use them only as exploratory results (Appendix A).
5.1 Exactness and accuracy
COMPACT and EMULV gave bit-identical outputs for all 432 prompts below and for all 1,264 recorded arrays of prompt log-probabilities. So, on these prompts and in eager mode, the two-view read and the page plan add no error to the arithmetic of the transforms.
The prototype.
We measured the accuracy on 432 items: 400 GSM8K test problems [11] and 32 needle-retrieval prompts of 7.7K tokens, in chat format with greedy decoding. Every arm answered all 32 needle prompts correctly, so every change came from the GSM8K items. In the build run, COMPACT had an accuracy of 0.9769 and STOCK 0.9722 (422 and 420 of 432): a change of points, with the 95% Agresti–Min interval for paired answers , inside our preset margin of points (we count a change inside this margin as no loss). Two final answers changed, both toward the correct answer, and the generated text differed in 88 of the 432 items (20.4%). The mean negative log-likelihood that the model gives to the GSM8K reference solutions changed by nats per token (interval ). The stock engine alone scored 0.9769 in an earlier run with other settings (the batch cap, the KV pool and the maximum model length), so a change of 2 items has no stable sign.
An earlier emulation.
That earlier run emulated the compact arithmetic on the stock cache in the natural dimension order. It gave points (), with 2 changed answers against 3 for a noise arm that adds one extra 16-bit rounding of the query. Appendix B gives its details, including a small shift of the reference log-likelihood whose sign we cannot explain.
Limits.
The result covers final answers, not text. The GSM8K sequences are short (about 240 tokens with the answer), and only the 32 needle prompts reach 7.7K tokens, so no accuracy test reaches the lengths at which the saving matters. The base accuracy is near the ceiling, and the positive control did not separate from the compact arm. So the result is “no break found”, not a proof of equal quality.
5.2 Memory and capacity
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.
The steady decode footprint, the steady decode KV memory of one request, is the number of blocks in use while that request decodes. The prefill peak is the largest number of blocks in use while the engine prefills one request; it sets the cost of admission. The steady decode footprint fell from 1,349 to 1,008 blocks at 32K tokens and from 2,373 to 1,690 blocks at 64K tokens (Figure 2, Table 1): factors of 1.338 and 1.404, or 0.83 and 1.67 GiB less KV per request. These ratios count all layers and match the page-plan arithmetic to within one block: the sliding blocks do not change, and the global blocks fall by a factor of 1.5. So the saving is a factor of 1.6 in the global-layer values, 1.5 after the page padding, and 1.34 to 1.40 over all layers.
The saving at admission is smaller, because the prefill reservation includes up to 321 blocks in each sliding group in both layouts: the prefill peaks fell by factors of 1.15 and 1.23. At 32K tokens, the 15 GiB pool decoded 4 compact requests where 3 stock requests fit, and the decode rate rose from 56.0 to 69.7 tokens per second (1.24 times). At 64K tokens both layouts held 2 requests, and the compact build was 4% slower; the third compact request lacked 181 blocks (about 0.44 GiB), so a slightly larger pool would probably hold 3. The gain is a decode-state saving that becomes throughput where one more request fits, and it depends on where the pool limit falls. By its preset rule (Appendix A), this run passed on outputs, accuracy and capacity, but not on throughput (a gain at one length only) or step cost (above the 5% limit).
| 32K tokens | 64K tokens | |
|---|---|---|
| stock / compact | stock / compact | |
| Steady decode footprint (blocks) | 1,349 / 1,008 (1.338) | 2,373 / 1,690 (1.404) |
| Steady decode footprint (GiB, all layers) | 3.29 / 2.46 | 5.79 / 4.13 |
| Prefill peak (blocks) | 2,602 / 2,262 (1.150) | 3,626 / 2,944 (1.232) |
| Largest batch with no preemption | 3 / 4 | 2 / 2 |
| Decode tokens/s at that batch | 56.0 / 69.7 (1.24) | 36.3 / 34.8 (0.96) |
| Step-time ratio at the same batch (mean) | 1.087 | 1.043 |
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.
5.3 Step time
In eager mode, the mean decode step of the prototype was 8.7% slower than the stock step at the same batch at 32K tokens and 4.3% slower at 64K. At 32K, the transforms cost 4.8% (EMULV against STOCK), and the compact cache cost another 3.7% (COMPACT against EMULV), measured in two engine processes. A benchmark of the global layers without weights found that the compact read was faster than the stock read, and that the transforms cost mostly CPU launch time; it explains about 40% of the engine cost. The cause of the remaining cost is not known.
In an exploratory run with full decode CUDA graphs (the FULL_DECODE_ONLY mode of vLLM, without torch.compile), the compact step took 50.52 ms against 50.73 ms for the stock step at 3 requests of 32K tokens (, inside our 2% noise band). A kernel profile agrees: the compact cache cut the attention kernel time by 0.49 ms per step, and the 110 transform kernels added 0.46 ms. The output check of this run failed for 1 of 3 prompts, probably because of a schedule difference outside the timing windows, so the run is invalid by its own rule. With full decode CUDA graphs we saw no step cost above about 2%; we do not claim zero cost. Appendix C gives the details.
5.4 A bound on the speed gain
A 37.5% smaller global cache moves fewer bytes per decode step, so one could expect a faster step. At 3 requests of 32K tokens, one decode step reads about 62 GB (decimal gigabytes) of 16-bit weights and about 10.6 GB of KV (per request: 2.68 GB in the global layers and 0.84 GB in the sliding layers). The compact cache removes about 2.7 GB of these 73 GB, or 3.7%. So even a step whose time followed its bytes would gain only about 4% here. The profile of the exploratory graph run agrees: the matrix products took 37.4 ms and attention 10.7 ms of the 50.7 ms graph step, and the compact cache cut the attention time by 0.49 ms. At larger batches the KV share of the bytes grows, but in our kernel tests the attention time followed the DRAM bytes only weakly: on an A100 the compact read saved 2.7% to 9.7% of the read time, and on an H100 the FP8 kernels had a time elasticity of 0.16 to 0.24 to the bytes (exploratory; Appendix D). So the speed of one step does not change much; a gain in throughput must come from more requests in each step, which the next section measures.
6 Capacity in a serving decode node
Section 5 measured fixed batches in one engine. Large deployments often split the work: a prefill engine computes the prompt, the KV cache moves to a decode engine, and the decode engine generates the output [12, 13, 14]. The decode engine of such a system holds many running requests, and its KV pool is full most of the time. When the pool is full, vLLM preempts a request; with a CPU offload connector, the request can later reload its blocks from host memory instead of computing them again. This section asks whether the compact cache works on this path, and whether its capacity gain matches a model of the block pool, with a decision rule that we froze before each run.
6.1 A model of the block pool
We wrote a discrete-step model of the vLLM block pool for a decode engine. It follows the rules of the engine that we read in the source: the admission of a request only when its blocks for the full input fit, a token budget of 2,048 per step with two batches in flight (asynchronous scheduling), the preemption of the most recently admitted request when the pool is full, and a CPU tier that stores the blocks of all running requests (Appendix E). The input is a stream of requests with lognormal prompt and output lengths (log-scale standard deviation 0.6). The engine keeps a backlog of requests that wait for blocks, so the pool is the limit. A work step is a step in which the scheduler schedules work; steps that only wait for a KV transfer do not count. The main statistic is
which counts how many more requests decode in each step and does not depend on the step time. The model gives for the exact request sequence that the engine runs (one random seed) and a range over seeds 0 to 4 and backlog depths 2, 3 and 8. As a report only, it also gives a throughput ratio with step times from attention read times that we measured on an A100 SXM (exploratory), for CUDA graphs and with the measured costs of eager mode added.
6.2 The connectors
With the stock vLLM offload connector set to store all blocks, forced preemptions of compact requests on the 31B model reloaded their generated tokens from the CPU tier, and 24 checked reloads matched byte for byte, except blocks that vLLM had computed again. The NIXL connector [15] of the pinned vLLM build could not register the compact cache, and a byte view of each padded page removes the problem. By our reading of the code, vLLM main later fixed this check in general [16], so our patch is likely only a back-port; we did not run vLLM main. With the 12B model, NIXL moved 8 long prompts to a decode engine with all blocks intact, and NIXL-fed compact requests also reloaded correctly. Appendix E gives the details.
6.3 Setup
One container had two A100-SXM4-80GB GPUs: the prefill engine on one GPU and the decode engine, with NIXL and a 64 GiB CPU tier, on the other. Both engines ran the 16-bit 31B model in eager mode with no prefix caching; the decode engine used the 15 GiB pool of Section 5 and at most 16 sequences (Appendix F). A driver kept two prefilled requests ready and three requests waiting on the decode engine, so the decode pool stayed full: the decode engine had a waiting request in at least 99.6% of the work steps of every run. The prompts were random token ids, each request decoded its drawn output length (ignore_eos), and decoding was greedy. Each arm measured the work steps 2,000 to 22,000. The stock arm ran the stock cache without the transforms; the compact arm ran the compact cache with them. We tested two operating points that differ in prompt length: D3H (median prompt 16,384 tokens) and D3Q (median prompt 8,192 tokens), both with a median output of 2,048 tokens. The model predicts a clearly smaller gain for the shorter prompts. We expected this: the sliding layers keep a fixed size, so the footprint ratio of Section 5.2 falls with the prompt length.
6.4 Results
| decode tokens per work step | model prediction of | ||||
|---|---|---|---|---|---|
| Run | stock | compact | seed 0 | seeds 0–4 (frozen band) | |
| D3H, first run | 5.458, 5.459 | 7.509 | 1.376 | 1.364 | 1.308–1.364 (1.295–1.378) |
| D3H, repeat run | 7.514 | 1.377 | |||
| D3Q | 8.192 | 10.133 | 1.237 | 1.229 | 1.169–1.229 (1.158–1.241) |
| Model, seed 0 | 5.454 / 8.246 | 7.438 / 10.130 |
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.
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%).
The capacity ratio.
Table 2 and Figure 3 give the results. At D3H the compact decode engine ran 1.376 times the stock decode tokens per work step; the model predicted 1.364 for the same request sequence. The two stock runs agreed to 0.03%, and a second compact run (the repeat run), in another session on another host, repeated the compact value to 0.06%. At D3Q the ratio was 1.237, against 1.229 in the model. Both values are inside their frozen bands, but only because the bands were widened by 1%. The engine was 0.9% (D3H) and 0.7% (D3Q) above the top of the model range. The engine ran the request sequence of seed 0, which is at the top of that range at both points. Other seeds give ratios up to 4% to 5% lower, so the frozen rule would also have passed a model that overstated the gain by that much.
The ratio fell by 0.139 from D3H to D3Q, and the model predicted a fall of 0.135. So the measured fall was 1.03 times the predicted one, inside the frozen limits of 0.75 to 1.25. This result does not depend on which D3H run we use: the limits hold for any D3H value from 1.338 to 1.406. The test confirms the direction and the size of the fall, not an accuracy of 1%.
The model does not predict each arm exactly: at D3H the compact engine was 0.95% above it, and at D3Q the stock engine was 0.6% below it, while the other arm matched (Table 2). So the error of the model is not a constant bias of one layout (Appendix E).
Throughput.
The eager decode throughput rose by a factor of 1.30 at D3H and 1.11 at D3Q. In these runs a compact step took 5.5% (D3H) and 11% (D3Q) longer than a stock step, but it also held more requests. Both values lie inside the range that the model gives with CUDA-graph step costs, and the D3Q value also inside the eager range. These are single runs: the two stock runs at D3H differed by 2.7% in throughput, so we do not resolve differences smaller than about 3%. Compared with Section 5.2, where a fixed batch gained only where one more request fitted, a stream of requests of mixed lengths turns the smaller footprint into a steady gain.
Exact output on this path.
In the session of the repeat run, we also compared the compact engine with EMULV (Section 5) on the same two-GPU path: the prefill engine prefilled 8 needle prompts of 7,666 tokens one at a time, NIXL moved their KV caches, and the decode engine decoded each alone, 64 tokens with ignore_eos. The 512 output tokens were identical, the log-probabilities of the sampled tokens were bit-equal, and both engines gave the correct answer for 8 of 8 prompts. Only the first 4 to 6 tokens of each output are the answer; the rest are forced text that still tests the numerical identity.
A harness defect in the first D3H run.
In the first D3H run, the NIXL lease of 35% to 42% of the requests expired before the decode engine read them, so these requests may have decoded with other KV values. This cannot change the count of decode tokens per step, and the repeat run, with a longer lease and no expired lease, repeated the compact value to 0.06% (Appendix E).
7 Related work
Smaller KV caches by architecture.
Multi-query [17] and grouped-query attention [18] share keys and values across query heads, and cross-layer schemes share them across layers [19, 20]. Multi-head latent attention [4] caches a compressed latent and a separate RoPE key, and its decode kernels [5] read the key and the value from one cached row. Grouped-tied attention [21] and grouped value attention [22] also keep one cached state with a separate RoPE part, but both are trained from scratch; MHA2MLA [23] and TransMLA [24] convert trained models to MLA with fine-tuning. The Gemma 4 report credits Kayyam et al. [25] for the reuse of keys as values in global layers. Our row has the shape of these designs, but it is an inference layout for released models that already tie the key to the value, with no training and no new kernel. The fold of into the query is the absorption technique of MLA [4].
KV compression at inference.
Quantization [26, 27] and token eviction [28, 29, 30] reduce the cache with some loss. LowRAM [31] predicts the values from the keys and stores residuals, which is near-lossless. Slim attention [6] stores only the keys and computes the values from them; it is exact in real arithmetic, but it needs an invertible key projection and extra compute. The Gemma 4 global layers are an elementwise case of such a relation, so the compact row needs no rebuild of the values. Kanwat [32] also folds a term into the keys so that unchanged vLLM kernels read a compacted cache.
Serving engines.
PagedAttention and vLLM [1] manage the cache in blocks, and Jenga [33] manages layers with different page sizes in vLLM; our page plan is a small case of that problem. Disaggregated serving moves the KV cache from prefill GPUs to decode GPUs [12, 13], and Mooncake [14] also keeps KV caches in CPU memory and SSDs. These systems change where the cache lives and when it moves; the compact row makes the cache of each request smaller, so it combines with them (Section 6). We read the KV-cache code of vLLM, SGLang [34], TensorRT-LLM, Hugging Face transformers [35] and other code bases, and we searched 15 repositories, arXiv and the web (Appendix F). In each code base, these layers write a full key and a full value, or the model conversion produces standard key and value heads. We found no code, issue or pull request that stores the Gemma 4 global KV cache once; a search cannot see private code.
8 Limitations
- One model family and one vLLM build. All measurements use the 31B model, except the NIXL connector tests of Section 6.2, which used the 12B model; the 26B-A4B model has none. The method needs this K=V structure, and such exact redundancy is rare. In 16 current model configurations that we read on 2026-11-10, every other exact redundancy of 10% or more that a model declares in its KV cache was already used by vLLM or by the serving image that the model supports.
- The decode-node tests (Section 6) cover two operating points on one axis (the prompt length) at one pool size, one request sequence per point, eager mode, one cloud host per run and random-token prompts with fixed output lengths. Both point checks pass only because the frozen bands were widened by 1%: the engine was 0.7% to 0.9% above the range of the model. The error of the model differs by point and by layout, so we do not claim a constant bias. The throughput ratios are single runs, with a stock A/A spread of 2.7%. The NIXL patch is likely only a back-port for the pinned vLLM build, and the exactness check on this path used 8 prompts of one length at batch 1.
- The engine tests used a 16-bit cache and only the Triton backend on an A100. The FP8 compact row and the FlashAttention-4 read have only kernel-level tests on an H100, and at the default FP8 KV scale of 1.0 the compact row fails our attention-error bound, so the saving by a factor of 1.34 to 1.40 applies only to a 16-bit cache.
- Each test of Section 5 used one GPU, and the A100 ran under its power cap. Its capacity and timing runs used synthetic random-token prompts of equal length. We did not test prefix caching (the 48-token block changes the alignment of cache hits), tensor parallelism, speculative decoding or more than 16 concurrent sequences; Section 6 used mixed-length traffic, but only on one decode node.
- The accuracy test covers final answers with greedy decoding; its longest prompt has 7.7K tokens, its margin of points is a project heuristic, and its positive control did not separate from the compact arm. In our vLLM path, the instruct model scored raw natural text poorly in both checkpoints that we used (up to 10.5 nats per token on books); we did not find the cause or run a reference check with Hugging Face transformers, and all our model-level results use this path. Because both arms use the same path, a shared defect would not create a difference between them, but it could hide one.
- For a fixed batch, the capacity gain is an integer effect of the pool size: at 64K tokens it gave no throughput gain in our pool. A stream of requests of mixed lengths gave a steady gain (Section 6).
- The prototype applies its transforms at run time. The load-time folds and the default graph mode of vLLM (piecewise graphs with torch.compile) were not tested, the CUDA-graph timing is exploratory, and we had no hardware counters for DRAM traffic.
9 Conclusion
The global KV cache of Gemma 4 can be stored once, exactly in real arithmetic, as one 640-value row per KV head and token that unchanged attention kernels read through two views. In vLLM this cuts the steady decode KV memory per request by a factor of 1.34 to 1.40 at 32K to 64K tokens, and the final answers did not change beyond noise in our tests at contexts up to 7.7K tokens. The method is a memory mechanism: it adds requests per GPU where the KV pool is the limit. On a prefill/decode pair with NIXL transfer and CPU offload, it gave a decode engine with a full pool 1.38 and 1.24 times the decode tokens per step at two operating points, as a model of the block pool predicted, and 1.30 and 1.11 times the eager decode throughput. On this path its output matched its stock emulation for 8 prompts at batch 1. The run-time prototype costs 4% to 9% of an eager step at equal batch, and in an exploratory run with full decode CUDA graphs we saw no step cost above about 2%. We hope that serving engines adopt the layout for Gemma 4 and for future models that tie keys to values.
Code and data.
We plan to release the prototype code and the experiment records.
References
[1] Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with PagedAttention. In Proceedings of the 29th Symposium on Operating Systems Principles (SOSP), 2023. doi: 10.1145/3600006.3613165. arXiv:2309.06180.
[2] Gemma Team. Gemma 4 technical report. arXiv preprint arXiv:2607.02770, 2026.
[3] Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. RoFormer: Enhanced transformer with rotary position embedding. arXiv preprint arXiv:2104.09864, 2021.
[4] DeepSeek-AI. DeepSeek-V2: A strong, economical, and efficient mixture-of-experts language model. arXiv preprint arXiv:2405.04434, 2024.
[5] DeepSeek-AI. FlashMLA: efficient MLA decoding kernels. https://github.com/deepseek-ai/FlashMLA, 2025.
[6] Nils Graef, Kayvan Zahiri, and Andrew Wasielewski. Slim attention: cut your context memory in half without loss – K-cache is all you need for MHA. arXiv preprint arXiv:2503.05840, 2025.
[7] Federico Barbero, Alex Vitvitskyi, Christos Perivolaropoulos, Razvan Pascanu, and Petar Veličković. Round and round we go! What makes rotary positional encodings useful? arXiv preprint arXiv:2410.06205, 2024.
[8] vLLM contributors. vLLM source code, version 0.33.0rc1.dev229+g3966924d5. https://github.com/vllm-project/vllm, 2026a.
[9] Philippe Tillet, H. T. Kung, and David Cox. Triton: An intermediate language and compiler for tiled neural network computations. In Proceedings of the 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages (MAPL), 2019. doi: 10.1145/3315508.3329973.
[10] vLLM contributors. Proposal: packed KV-cache block stride for unequal per-group page sizes. vLLM issue 64307 and pull request 64344, https://github.com/vllm-project/vllm/issues/64307, 2026b. Open on 2026-11-05.
[11] Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
[12] Yinmin Zhong, Shengyu Liu, Junda Chen, Jianbo Hu, Yibo Zhu, Xuanzhe Liu, Xin Jin, and Hao Zhang. DistServe: Disaggregating prefill and decoding for goodput-optimized large language model serving. In Proceedings of the 18th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2024. arXiv:2401.09670.
[13] Pratyush Patel, Esha Choukse, Chaojie Zhang, Aashaka Shah, Íñigo Goiri, Saeed Maleki, and Ricardo Bianchini. Splitwise: Efficient generative LLM inference using phase splitting. In Proceedings of the 51st Annual International Symposium on Computer Architecture (ISCA), 2024. arXiv:2311.18677.
[14] Ruoyu Qin, Zheming Li, Weiran He, Mingxing Zhang, Yongwei Wu, Weimin Zheng, and Xinran Xu. Mooncake: A KVCache-centric disaggregated architecture for LLM serving. arXiv preprint arXiv:2407.00079, 2024.
[15] NVIDIA. NIXL: NVIDIA inference xfer library. https://github.com/ai-dynamo/nixl, version 1.5.0, 2026.
[16] vLLM contributors. [Model] Kimi K3.1 Pro (split 5/6: ROCm DCP, P/D, indexer top-k). vLLM pull request 65685, https://github.com/vllm-project/vllm/pull/65685, 2026c. Merged on 2026-11-12.
[17] Noam Shazeer. Fast transformer decoding: One write-head is all you need. arXiv preprint arXiv:1911.02150, 2019.
[18] Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, and Sumit Sanghai. GQA: Training generalized multi-query transformer models from multi-head checkpoints. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2023. arXiv:2305.13245.
[19] William Brandon, Mayank Mishra, Aniruddha Nrusimha, Rameswar Panda, and Jonathan Ragan-Kelley. Reducing transformer key-value cache size with cross-layer attention. In Advances in Neural Information Processing Systems (NeurIPS), 2024. arXiv:2405.12981.
[20] Yutao Sun, Li Dong, Yi Zhu, Shaohan Huang, Wenhui Wang, Shuming Ma, Quanlu Zhang, Jianyong Wang, and Furu Wei. You only cache once: Decoder-decoder architectures for language models. In Advances in Neural Information Processing Systems (NeurIPS), 2024. arXiv:2405.05254.
[21] Ted Zadouri, Hubert Strauss, and Tri Dao. Hardware-efficient attention for fast decoding. arXiv preprint arXiv:2505.21487, 2025.
[22] Vishesh Tripathi, Abhay Kumar, and Ramsha Khan. Grouped value attention: Efficient KV caching via on-demand key reconstruction. arXiv preprint arXiv:2609.13285, 2026.
[23] Tao Ji, Bin Guo, Yuanbin Wu, Qipeng Guo, Lixing Shen, Zhan Chen, Xipeng Qiu, Qi Zhang, and Tao Gui. Towards economical inference: Enabling DeepSeek’s multi-head latent attention in any transformer-based LLMs. arXiv preprint arXiv:2502.14837, 2025.
[24] Fanxu Meng, Pingzhi Tang, Xiaojuan Tang, Zengwei Yao, Xing Sun, and Muhan Zhang. TransMLA: Multi-head latent attention is all you need. arXiv preprint arXiv:2502.07864, 2025.
[25] Ali Kayyam, Anusha Madan Gopal, and M. Anthony Lewis. Do transformers need three projections? Systematic study of QKV variants. arXiv preprint arXiv:2606.04032, 2026.
[26] Zirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi Chen, and Xia Hu. KIVI: A tuning-free asymmetric 2bit quantization for KV cache. In Proceedings of the 41st International Conference on Machine Learning (ICML), 2024. arXiv:2402.02750.
[27] Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W. Mahoney, Yakun Sophia Shao, Kurt Keutzer, and Amir Gholami. KVQuant: Towards 10 million context length LLM inference with KV cache quantization. In Advances in Neural Information Processing Systems (NeurIPS), 2024. arXiv:2401.18079.
[28] Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, Zhangyang Wang, and Beidi Chen. H2O: Heavy-hitter oracle for efficient generative inference of large language models. In Advances in Neural Information Processing Systems (NeurIPS), 2023. arXiv:2306.14048.
[29] Yuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh, Acyr Locatelli, Hanchen Ye, Tianle Cai, Patrick Lewis, and Deming Chen. SnapKV: LLM knows what you are looking for before generation. In Advances in Neural Information Processing Systems (NeurIPS), 2024. arXiv:2404.14469.
[30] Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In International Conference on Learning Representations (ICLR), 2024. arXiv:2309.17453.
[31] Teresa Delgado, Hugo Hazard, Martin Benfeghoul, Jun Wang, and Zafeirios Fountas. LowRAM: Low-rank keys and amortised values for composable KV cache compression at test-time. arXiv preprint arXiv:2611.07025, 2026.
[32] Utkarsh Kanwat. Folding attention biases into keys makes compacted KV caches run on standard kernels. arXiv preprint arXiv:2610.36520, 2026.
[33] Chen Zhang, Kuntai Du, Shu Liu, Woosuk Kwon, Xiangxi Mo, Yufeng Wang, Xiaoxuan Liu, Kaichao You, Zhuohan Li, Mingsheng Long, Jidong Zhai, Joseph Gonzalez, and Ion Stoica. Jenga: Effective memory management for serving LLM with heterogeneity. arXiv preprint arXiv:2503.18292, 2025.
[34] Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody Hao Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Joseph E. Gonzalez, Clark Barrett, and Ying Sheng. SGLang: Efficient execution of structured language model programs. In Advances in Neural Information Processing Systems (NeurIPS), 2024. arXiv:2312.07104.
[35] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, 2020.
[36] Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. In Advances in Neural Information Processing Systems (NeurIPS), 2022. arXiv:2205.14135.
Appendix A The experiments
Each experiment had a written question and a decision rule that we froze in the project repository before the run. The design was reviewed before the run, and amendments came before the data of the run that they govern. For the GPU runs, a rehearsal with a smaller model or on a cheaper GPU ran first, and a review after the run recomputed the results. E-70 itself used the 12B model; E-72 and E-73 had no separate rehearsal, because they reused the code of E-71. Table 3 lists the experiments with the outcome that the frozen rule gave. The outcome words are those of each frozen rule. GO and PASS mean that the conditions of the rule held. PIVOT means that they held only in part, so the next step changed. BUILD-PIVOT (E-57) means that the outputs, the accuracy and the capacity passed, but the throughput gain held at one length only and the step cost was above its 5% limit. FAIL means that the result missed its bound. INVALID means that a validity check of the design failed; this does not mean that the data are wrong. We use numbers from INVALID runs only as exploratory results. The words of the decode-node tests (Section 6): CONNECTOR-WORKS, PATCH-WORKS and RELOAD-WORKS mean that the transfer and reload checks passed, and GAP-CONFIRMED that the unpatched connector failed as predicted; STEP-CONFIRMS means that was inside the frozen band (CLEAN: with no expired NIXL lease); REPEATS means that a second run was within 0.5% of the first; SHIFT-MATCHES means that the change of between two operating points was 0.75 to 1.25 times the predicted change; EXACT means identical output tokens. E-63, E-64 and E-67 are models that ran on a CPU. The main text names the decode-node runs by their role: the first D3H run is E-71, the repeat run is E-72, and the D3Q run is E-73. The main text writes “invalid” for the outcome INVALID.
In E-59 the output check required identical tokens from COMPACT and EMULV for 3 prompts. For one prompt the tokens differed from position 3, both with CUDA graphs and in eager mode. The compact cache leaves more blocks free, so the compact engine admitted that request one step earlier than the engine with the stock cache, and its prompt was split into other prefill chunks. The prompt is a random-token prompt, and STOCK and EMULV also differ on it (from position 4). A review of the run found the schedule difference sufficient to explain the failure; we did not show that it is the only cause. The two stock processes of E-59 differed by 1.1% in eager windows that we chose after the run; its frozen analysis, which included windows after a profiler pass, recorded 6.7%.
| Run | GPU | Outcome | Used in this paper as | What it measured |
|---|---|---|---|---|
| E-49 | H100 | PIVOT | context (App. D) | Ceiling of the decode-step saving, 16-bit KV (6.65% and 11.33%) |
| E-50 | H100 | GO | context (App. D) | The same on an FP8 KV cache near the pool limit (12.1% and 15.0%) |
| E-51 | H100 | INVALID | exploratory (App. D) | A compact FP8 Triton kernel against its standard twin |
| E-52 | H100 | INVALID | exploratory (App. D) | The two-view read in Triton and stock FP8 kernels |
| E-53 | H100 | FAIL | result (App. D) | The FP8 compact row at KV scale 1.0, real activations |
| E-54 | H100 | PASS | result (App. D) | The FP8 compact row with tied, calibrated scales |
| E-55 | H100 | INVALID | not used | A first model-level test (the baseline could not resolve the margin) |
| E-56 | A100 | GO | result (Sec. 5.1, App. B) | Accuracy of the emulated compact cache |
| E-57 | A100 | BUILD-PIVOT | main result (Sec. 5.1 to 5.3) | The vLLM prototype: exactness, accuracy, capacity, eager step time |
| E-58 | A100 | GO | result (Sec. 5.3, App. C) | Benchmark of the global layers without weights |
| E-59 | A100 | INVALID | exploratory (Sec. 5.3, App. C) | The prototype with full decode CUDA graphs |
| E-63 | CPU | PIVOT-V2 | context (Sec. 6.1) | The block-pool model: decoding requests per step |
| E-64 | CPU | no GO | context (Sec. 6.1) | The model on request streams, unified and decode nodes |
| E-67 | CPU | OFFLOAD-CONFIG-GO | context (Sec. 6.1) | The model with the CPU offload connector |
| E-68 | A100 | INVALID | exploratory (Sec. 6.1) | Attention read times for the model’s step times |
| E-69 | A100 | CONNECTOR-WORKS | result (App. E) | The offload connector with the compact cache |
| E-70 | 2L40S | PATCH-WORKS, GAP-CONFIRMED; RELOAD-WORKS | result (App. E) | NIXL transfer of the compact cache (12B); reload of NIXL-fed requests |
| E-71 | 2A100 | STEP-CONFIRMS | main result (Sec. 6) | The decode node at D3H |
| E-72 | 2A100 | REPEATS, STEP-CONFIRMS-CLEAN, EXACT | result (Sec. 6) | The repeat with a long lease; exact output on the path |
| E-73 | 2A100 | STEP-CONFIRMS, SHIFT-MATCHES | main result (Sec. 6) | The decode node at D3Q |
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 28.
Appendix B Accuracy details
The earlier accuracy run (E-56) emulated the compact arithmetic on the stock cache in the natural dimension order, so its sums run in a different order from the build. It used an automatic pool (92% of the GPU memory), at most 64 sequences and a maximum model length of 10,240 tokens; the build run used the 15 GiB pool, at most 16 sequences and 66,048 tokens. It had a noise arm, which adds one extra 16-bit rounding of the query, and a positive control, the stock 8-bit cache at a KV scale of 1.0. The accuracy change was points (). Two of 432 final answers changed, against 3 for the noise arm; one item loops in the stock run and counts once in each compared arm, and without it the counts are 1 and 2. The mean negative log-likelihood of the reference solutions changed by nats per token (interval ); the noise arm moved it by , outside our margin of 0.002, and the sign of the compact shift is unexplained. The generated text differed in 21.5% of the items (noise arm: 17.4%). Over the needle-prompt tokens after position 1,024, the mean negative log-likelihood rose by nats per token (interval ) under the emulated compact cache, by under the noise arm and by under the 8-bit control. But the baseline there is 11.04 nats per token, the poorly scored raw-text regime of Section 8, so these numbers support no conclusion about the accuracy at long context.
Appendix C Step-time details
Eager mode.
The median slowdowns of the eager build run are 7.9% (32K) and 2.1% (64K): the step times are bimodal (20% to 32% of the steps are about 5 ms slower than the median), and the compact arm has a slightly heavier slow tail.
The attention layer.
A benchmark of the 10 global layers with synthetic caches and no model weights timed each part on its own, at the shapes of the engine runs. Read by the stock Triton kernel, the compact cache as built was 0.49 ms (32K) and 0.23 ms (64K) faster per 10-layer step than the stock cache, so the compact read does not explain the 3.7%. The transforms took 3.14 ms of CPU launch time per 10-layer step, but only 0.40 ms of GPU time inside a CUDA graph. In wall time they added 1.04 ms per 10-layer step, against 2.55 ms in the engine, so the benchmark explains about 40% of the engine cost. This agrees with a launch-time cost, but we did not test whether the eager engine step is bound by the CPU.
The engine with CUDA graphs.
We then ran the 31B engine with full decode CUDA graphs (the FULL_DECODE_ONLY mode of vLLM, without torch.compile), with the transforms attached before the graph capture (Figure 4). At 3 requests of 32K tokens, the compact step took 50.52 ms against 50.73 ms for the stock step (medians of 128-step windows; ), and the transforms alone added 0.65%. The noise was 0.09% within a process and 0.13% between processes, so is inside our 2% band and is not a speedup. A kernel profile agrees: the compact cache cut the attention kernel time by 0.49 ms per step, and the 110 transform kernels added 0.46 ms. The A100 lowers its clock when it reaches its power cap; the compact engines drew less power and ran at a 15 MHz higher clock. We count this as part of the effect of the method, not as a kernel gain. In the eager 128-step windows of the same run that the profiler did not touch (we chose them after the run), the transforms cost 4.8% again and the whole compact step 4.95%, against 8.7% in the first measurement. The cache-path cost did not appear there (; two stock processes differed by 1.1%), so the cause of the 3.7% is not known.
We label this run exploratory: its frozen output check failed for 1 of 3 prompts. A review of the run found that the compact engine, with more free blocks, admitted that request one step earlier and split its prompt into other prefill chunks; this is sufficient to explain the failure, but we did not show that it is the only cause. The check assumed equal schedules, so the run is INVALID by its own rule. The timing windows contain only full decode steps of all 3 requests, in every arm (Appendix A). With full decode CUDA graphs we saw no step cost above about 2%; we do not claim zero cost.
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 . 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%.
Appendix D Kernel studies (exploratory)
Ceilings.
The H100 studies used one H100 80GB and the FP8 checkpoint of Appendix F, a different operating point from the A100 engine runs. The ceiling estimate of the decode-step saving (at the lower 95% bound of the time slope) was 6.65% at 32K and 11.33% at 64K tokens with a 16-bit KV cache at batch 4 (E-49), and 12.1% and 15.0% with an FP8 KV cache near the pool limit (E-50). These estimates assume that the attention time follows the bytes.
Kernel time.
The attention time does not follow the bytes: in three families of FP8 attention kernels for head size 512, the time elasticity to DRAM bytes was 0.16 to 0.24, so removing a fraction of the bytes removed only about of the time that grows with the context. The stock FlashAttention-4 [36] FP8 kernel of vLLM read the two views of an FP8 compact cache with no code change and with the same error as its normal input. It was 7% to 10% faster in the context-dependent time, which is about 3% of a decode step near the pool limit, and its measurements also ran at a 5.7% higher clock. These two kernel runs (E-51 and E-52) are INVALID by their frozen rules, so their numbers are exploratory. On the A100 (E-58), the compact row read in a 32-token block saved 6.6% (32K) and 3.5% (64K) of the read time, and the 48-token cache as built saved 9.7% and 2.7%. In rehearsal runs on GPUs with less bandwidth per unit of compute, the saving was larger: 28% to 37% of the read time on an A40 (the same benchmark) and 35% to 36% of the context-dependent kernel time on an RTX 4090. This suggests that the speed effect grows on such GPUs, but each value comes from one rehearsal, and these GPUs also differ in other ways.
An FP8 compact row.
We tested the compact row with an FP8 cache on real activations of the global layers, captured in vLLM on one H100. At the default KV scale of 1.0, the compact row failed our attention-error bound in one layer. With tied, calibrated per-layer scales, it had 0.67 times the attention error of the stock FP8 cache and 1.13 times the error of the best-calibrated standard FP8 cache, on 7 prompts. It needs scales with an error of at most 0.1% to 0.25%, and the stock FlashAttention-4 FP8 kernel read it in decode calls. The tied row has no model-level test, so we do not know whether it stacks with FP8 quantization.
Appendix E Decode-node details
CPU offload (E-69).
We used the stock vLLM offload connector set to store all blocks (offload_prompt_only off and prefix_cache_retention_interval unset; with the default retention of 0, a reload stopped at the end of the prompt in a 12B control). We forced preemptions of compact requests on the 31B model on one A100. The reloads restored the generated tokens (a median decode coverage of 0.977; stock 0.984), and 24 checked reloads (11,676 blocks) matched byte for byte, except blocks that vLLM had computed again after an earlier reload: the tier keeps the first stored copy of a block and does not store it again, so these came back as the first version. Loads ran at about 24 GB/s.
NIXL transfer (E-70).
The padded compact page does not divide the shared KV buffer into NIXL regions, so the connector of the pinned build refused the cache. Our patch registers a byte view of each padded page (a two-dimensional uint8 view at the same address). With the 12B model on two L40S, NIXL moved 8 prompts of 7,666 tokens from a prefill engine to a decode engine; all 3,192 full blocks matched, and the decode engine answered 8 of 8 correctly. With both connectors on one decode engine, forced preemptions reloaded NIXL-fed compact requests with their generated tokens (a median coverage of 0.953, 24 checked reloads of 9,192 blocks, with no mismatch other than the first-version effect).
The CPU tier of the model.
When the tier is full, the model evicts the request with the oldest rank, which is set at its first store and renewed when the request finishes. The model tier holds 200 GB and the engine tier 64 GiB; a check with a 64 GiB and a 10 GB tier gave the same predictions.
The model error for each arm.
At D3H the stock engine matched the model (5.458 against 5.454 decode tokens per work step), and the compact engine was 0.95% above it. At D3Q the compact engine matched (10.133 against 10.130), and the stock engine was 0.6% below. The engine also preempted more than the model (6 against 3 per arm at D3H; 12 and 16 against 8 and 9 at D3Q); we did not test whether this explains the difference.
The NIXL lease in E-71.
In E-71 the driver held prefilled requests outside the decode scheduler for up to a few minutes. The prefill engine keeps the blocks of a prefilled request for a lease of 30 s by default, and the decode engine extends the lease only for requests in its own scheduler. So 35% to 42% of the requests were read after the prefill engine had freed their blocks. The count of decode tokens per step does not depend on the KV values (the output lengths are fixed and prefix caching is off), and both layouts were affected alike. E-72 used a 600 s lease, and no lease expired. In E-72 the decode-engine logs also showed that the 8 exactness prompts came through NIXL and were not computed again.
Appendix F Model dimensions and reproducibility
Dimensions of Gemma 4 31B.
Hidden size 5,376; 60 layers (50 sliding-window layers with window 1,024, head size 256 and 16 KV heads; 10 global layers with head size 512 and 4 KV heads); 32 query heads; RoPE on the global layers with and base . At 32K tokens, the global KV of one request takes 10 layers 32,768 tokens 8,192 bytes GiB in the stock cache, and 1.67 GiB in the compact cache with the 48-token page plan.
Software and data versions.
The runs used these versions.
| vLLM, Triton | 0.33.0rc1.dev229+g3966924d5; 3.8.0 |
|---|---|
| Image | vllm/vllm-openai@sha256:f255c4fad2f30ff5ee80db14d3a03afe9ae0f10d3470339864ff04745fe44cb3 |
| Checkpoint | google/gemma-4-31B-it, revision 842da3794eaa0b77d5f08bae87a17459d91ff475 |
| H100 checkpoint | RedHatAI/gemma-4-31B-it-FP8-dynamic (FP8) |
| GSM8K | openai/gsm8k, revision 740312add88f781978c0658806c59bc2815b9866 |
| 12B checkpoint | google/gemma-4-12B-it, revision 43c9d014b231474fa7212dbb48a762566c2b255d |
| NIXL | 1.5.0 (in the same image) |
Engine settings.
One A100 SXM 80GB, eager mode unless stated, a 16-bit KV cache, no prefix caching, seed 0 and at most 2,048 batched tokens per step. The build, capacity and step-time runs (E-57 to E-59): a fixed KV pool of 15 GiB (6,144 blocks), at most 16 sequences and a maximum model length of 66,048 tokens. The emulation run (E-56): an automatic pool (92% of the GPU memory), at most 64 sequences and a maximum model length of 10,240 tokens.
Decode-node settings (E-69 to E-73).
Modal containers (gVisor) with one A100-SXM4-80GB (E-69), two L40S (E-70) or two A100-SXM4-80GB (E-71 to E-73); the prefill and decode engines run in two processes on separate GPUs of one container. NIXL uses UCX with ucx_error_handling_mode set to none (the container has no TCP network devices, and the default mode refused the intra-node transports). The decode engine uses a MultiConnector of the NIXL connector and the offload connector (cpu_bytes_to_use 64 GiB in E-71 to E-73, offload_prompt_only off, prefix_cache_retention_interval unset). E-71 to E-73: decode pool 15 GiB, at most 16 sequences and 2,048 batched tokens; prefill engine at most 4 sequences and 1,024 batched tokens; maximum model length 144,000 tokens on both; NIXL lease 30 s (the default) in E-71 and 600 s in E-72 and E-73. The request streams: prompt lengths lognormal with median 16,384 (D3H) or 8,192 (D3Q) tokens, clipped to 256 to 131,072; output lengths lognormal with median 2,048, clipped to 16 to 16,384; log-scale standard deviation 0.6; random number seed string 64-D3H-0 or 64-D3Q-0; requests whose stock reservation does not fit the empty pool, or whose prompt and output exceed the maximum model length, are skipped, in the model and in the engine alike.
Accuracy data.
We drew 400 problems from the GSM8K test split with seed 56. The user turn is “Solve the math problem. Show brief steps, then write the final answer as a number after ‘####’.” and the problem. The 32 needle prompts have 7,666 to 7,668 tokens: 7,600 tokens from one of 4 PG-19 test books, with the sentence “The secret passphrase for the archive is <word>-<4 digits>.” at 8 depths (5% to 89%), and the question “What is the secret passphrase for the archive? Answer with the passphrase only.” The prompts use the chat template of the checkpoint with thinking off. Decoding is greedy, with at most 640 tokens for GSM8K and 128 for the needles, and it stops at the end-of-turn token (id 106).
Patch points.
(1) The KV-cache specification of each global layer: 640 values (1,280 bytes) per head and token, and a block of 48 tokens. (2) Wrappers of the Triton attention entry point and of the Triton cache-write entry point, which replace that 128-value cache with the V view. (3) Hooks on the 10 global attention modules. They form the query after RoPE (the product is rounded to 16 bits), the write operands and , and the output permutation back to the model order. In the row, is dimensions 0 to 63 and 256 to 319 in this order, and is dimensions 64 to 255 and 320 to 511. For weights that are quantized in blocks of columns, an output fold must keep the blocks intact; the segments of the permutation start at multiples of 64 dimensions.
Search record.
On 2026-11-17 we repeated web searches for the method (the web, arXiv, and the vLLM and SGLang issues and pull requests) and found no new work that stores the Gemma 4 global KV cache once. Between 2026-10-25 and 2026-11-05, we read code in, or searched the issues and pull requests of, these 15 GitHub repositories, with fixed queries such as attention_k_eq_v, k_eq_v, gemma4 kv cache, gemma4 compact kv, head_size_v and kv cache keys values once (buun-llama-cpp is a llama.cpp fork with a coupled key-value cache for latent attention):
| vllm-project/vllm | vllm-project/tpu-inference | vllm-project/flash-attention |
|---|---|---|
| sgl-project/sglang | NVIDIA/TensorRT-LLM | ggml-org/llama.cpp |
| spiritbuun/buun-llama-cpp | huggingface/transformers | google/gemma.cpp |
| google-deepmind/gemma | google-ai-edge/LiteRT-LM | google-ai-edge/litert-torch |
| flashinfer-ai/flashinfer | LMCache/LMCache | ml-explore/mlx-lm |
Between 2026-10-28 and 2026-11-05, we read the attention and KV-cache code of vLLM, its TPU backend, SGLang, TensorRT-LLM, Hugging Face transformers and gemma.cpp, and we checked llama.cpp, the buun-llama-cpp fork, Google DeepMind’s JAX Gemma library and LiteRT-Torch. We found work that removes the duplicated value weights and work that adds FP8 caches for head size 512, but no code, issue or pull request that stores the Gemma 4 global KV cache once.