A few weeks ago I worked out how much GPU memory one long conversation takes. For Meta's Llama 3.1 8B on an NVIDIA H100, a full context window needs about 17 GB of KV cache. That is as much as the model itself.
On an 80 GB data center GPU, that is annoying. You fit three long chats and then you're out of room.
Now try it on a phone.
A phone has around 8 GB of memory for everything: the operating system, your apps, your photos, and the model. There is no spare 17 GB. There isn't even a spare 2.
Apple runs a language model of about 3 billion parameters on the device itself. I went through their 2025 tech report to see how they deal with the KV cache, and the answer surprised me. They didn't only squeeze it. They changed the model so that a big chunk of the cache never exists.
A quick recap of the KV cache
A language model writes one token at a time. To choose the next token, every layer needs to look back at all the tokens before it.
Redoing that from scratch for every new token would be far too slow. So each layer keeps notes: for every token it has seen, it stores a "key" and a "value". That is the KV cache.
The important detail is the word each. A model with 32 layers keeps 32 sets of notes. The memory cost is:
layers × tokens × (size of one key + one value)Everyone attacks the last two terms. Use fewer tokens. Use smaller numbers. Apple went after the first one.
diagram
Where the KV cache comes from
Every layer normally stores its own keys and values for every token in the conversation.
01
Each token
In the prompt or the reply
02
Every layer
Writes its own key and value
Select a branch to follow its path.
What Apple did
Apple split the model's layers into two blocks.
- Block 1 has 62.5% of the layers. These work normally and each one stores its own keys and values.
- Block 2 has the remaining 37.5%. These layers had their key and value projections removed. They don't produce a KV cache at all.
So what do the Block 2 layers look at when they need to look back? They reuse the keys and values that Block 1 already produced.
Think of a model with 8 layers. Layers 1 to 5 keep their own notes. Layers 6, 7 and 8 keep nothing and read from what Block 1 wrote.
Three out of eight layers store nothing. 3 ÷ 8 = 37.5%.
That is where Apple's number comes from, and it is exact. In the report's words, sharing this way reduces KV cache memory usage by 37.5%.
Apple credits the idea to Snowflake's research on a technique called SwiftKV. I did not expect to find Snowflake in the footnotes of an iPhone model.
diagram
Two blocks, one set of notes
Apple's on-device model splits its layers 5 to 3. Only the first block stores a KV cache.
01
Block 1
62.5% of the layers
02
KV cache
Written only by Block 1
Select a branch to follow its path.
The second win: a faster first token
There is a bonus that I find even more clever.
When you send a prompt, the model first has to read it. This is called prefill. During prefill, the model isn't producing any text yet. The whole point of running the prompt through the layers is to fill the KV cache so generation can start.
But Block 2 doesn't have a KV cache to fill.
So during prefill, there is no reason to run the prompt through Block 2 at all. Apple's report says the prefill stage can bypass all of Block 2's computation, which cuts time to first token by about 37.5%.
Same fraction, different benefit. Less memory, and you wait less before the first word appears.
diagram
What happens to your prompt
Reading the prompt only exists to fill the KV cache. Layers with no cache have nothing to fill.
01
Your prompt
Read once before the reply starts
02
Prefill
Fills the KV cache
Select a branch to follow its path.
Then they shrank what was left
Apple didn't stop at removing part of the cache. The same report says they also store the remaining KV cache in 8 bits per number instead of the usual 16.
Put the two together:
5/8 of the layers × 1/2 the bits = 5/16The cache ends up at about 31% of what a normal 16-bit model would need. Roughly 69% gone.
That last line is my own arithmetic from Apple's two published facts, not a figure from the report.
The weights get the same treatment, only more extreme: the on-device model is compressed to 2 bits per weight.
What it costs
None of this is free, and Apple's report is honest about it.
Their table compares the on-device model before and after all optimizations. On the MMLU benchmark, it goes from 67.8 to 64.4. On IFEval, from 85.1 to 82.3.
That drop covers everything together, including the 2-bit weights, so you can't pin it on KV sharing alone. But the direction is clear. You trade a few points of quality for a model that fits in your pocket.
Apple also trains small adapters afterwards specifically to win back some of the quality lost to compression.
Why this matters outside of phones
I mostly write about data center inference, so why care about a phone model?
Because the constraint is the same one, just tighter.
In my KV cache post, the takeaway was that context length decides how many users fit on a GPU. Every byte of cache you don't store is another user you can serve. Snowflake built the original technique for exactly that reason, on servers.
Most of us treat the KV cache as a fixed cost of the model we were given. We page it, we quantize it, we evict it. Apple's approach is a reminder that the cache is a design decision. If you control the model, you can decide that some layers simply don't get one.
What I built
I extended my KV cache calculator with two new knobs: the share of layers that keep their own cache, and the number of bits per value.
Then I gave it a phone-sized memory budget of 2 GB and asked how long a conversation fits. The model is Llama-shaped: 32 layers, 8 KV heads, 128 numbers per head.
| Setup | KV per 1,000 tokens | Max context in 2 GB | Prefill work |
|---|---|---|---|
| All layers, 16-bit | 131 MB | 15,258 tokens | 100% |
| 62.5% of layers, 16-bit | 82 MB | 24,414 tokens | 62.5% |
| 62.5% of layers, 8-bit | 41 MB | 48,828 tokens | 62.5% |
In the same 2 GB, the conversation goes from about 15,000 tokens to almost 49,000, a bit more than three times longer. Prefill only has to run 20 of the 32 layers, so the work before the first token drops to 62.5%.
The layer counts in my calculator are illustrative, since Apple doesn't publish the exact number of layers. The fractions are theirs. Try it yourself:
interactive · kv cache sharing
How long a conversation fits in a phone-sized budget?
Llama-shaped layers: 8 KV heads of 128 numbers. The layer count is illustrative, the fractions are Apple's.
20 layers write KV
12 layers reuse it
bits per value
white tick = all layers, 16-bit
48,828 tokens
KV / 1k tokens
41 MB
max context
48,828
vs baseline
3.2× longer
prefill work
62.5%
The takeaway
When memory is the limit, there are three levers on the KV cache: fewer tokens, smaller numbers, or fewer layers that need it.
Almost everyone pulls the first two. Apple pulled the third, and got the memory back for free on every single token.
Sources
- Apple, "Apple Intelligence Foundation Language Models: Tech Report 2025", arXiv 2507.13575, July 2025. Section 2.1 (KV cache sharing: 62.5% / 37.5% split, 37.5% KV memory reduction, about 37.5% lower time to first token), Section 6 (2 bits per weight, 8-bit KV cache), Table 3 (quality before and after optimization).
- Snowflake, "SwiftKV", the technique Apple's report cites for KV sharing.
- The 5/16 figure and the calculator results are my own calculations.
