Gemma 4: Five KV Cache Innovations, One Serving Catastrophe
Why This Matters Right Now
Google shipped Gemma 4 with a design choice more consequential than any benchmark: the edge and server models are architecturally divergent, not scaled versions of the same core. E2B exploits flash/DRAM asymmetry with Per-Layer Embeddings (46% of its 5.1B params are static flash lookups); server models skip PLE entirely because H100's 80GB HBM has no such asymmetry. This signals the end of the "one architecture, scale it up" paradigm.
The KV Cache Attack Stack
Gemma 4 stacks five independent compression techniques for an 83% KV cache reduction at 8K context:
- Interleaved sliding-window attention: 80% of layers pay O(n) instead of O(n²) — 5x attention speedup on edge
- Grouped-Query Attention: 8:1 on edge (most aggressive in family), differential 2:1/8:1 on server
- Cross-layer KV sharing: 20 of 35 E2B layers skip KV projection entirely, reusing from earlier layers — back-loaded and type-matched to prevent attention contamination
- K=V weight sharing (server only): Global layers compute key once, reuse as value with RMSNorm — halves global KV cache on top of GQA
- Wider MLPs on shared-KV layers: MLP width doubles from 6,144→12,288 where KV is shared — a compute-for-memory swap revealing quality loss from sharing is real
For comparison, DeepSeek's MLA achieves 93.3% within-layer compression vs. Gemma's 83% cross-layer sharing. These are complementary — cross-layer and within-layer — and could theoretically be combined.
Partial RoPE: The Long-Context Fix
Standard RoPE rotates all attention dimensions, but positional encoding overwhelms semantic content at long ranges. Gemma 4's 512-dim global heads split: 128 dims (25%) get theta=1M rotation; 384 dims (75%) are pure content channels with zero rotation. Result: the 31B model jumps from 6.6% to 86.4% on tau2-bench Retail — a 13x improvement. Google published no ablation isolating partial RoPE's contribution from training data changes.
The FA2 Crisis: Your GPU Generation Matters More Than Your Model Choice
This is the deployment fact that overrides everything else: 512-dimension global attention heads exceed FlashAttention-2's hard limit of 256. On every pre-Blackwell GPU, Gemma 4 falls back to unoptimized Triton kernels:
| Hardware | Throughput | Status |
|---|---|---|
| Blackwell | 124 tok/s | Optimized kernels available |
| H100 / A100 / RTX 4090 | ~9 tok/s | FA2 fallback — 14x penalty |
The fix — per-layer backend dispatch routing local layers to FA2 and global layers to alternative kernels — is an open vLLM issue as of April 2026. Until this ships, Gemma 4 is effectively a Blackwell-only model for production serving.
Gemma 4 arrived before its serving infrastructure — if you're on H100s, you're paying a 14x throughput tax until vLLM patches per-layer kernel dispatch.
What to do
Run `nvidia-smi` to confirm your GPU generation before any Gemma 4 evaluation — benchmark only on Blackwell or defer until vLLM per-layer dispatch lands
Profile KV cache cosine similarity across layers in your existing models — if adjacent layers show >0.9 similarity, implement type-matched cross-layer sharing
Implement partial RoPE (25% rotated, 75% content) in your next long-context training run if retrieval degrades beyond 32K tokens
Track vLLM per-layer dispatch issue and re-benchmark Gemma 4 when the patch ships