Gemma 2 9B alternating sliding window at 128K: 177,408 B/token effective, 1.94x under the naive full cache
Fields
kv-efficiency/gemma2-9b-alternating-swa-128kNotes
Closes the alternating-window gap for a catalog model whose naive KV rate is the most expensive small-model figure in the collection. models/gemma-2-9b stores 344,064 B/token and warns that the real cache is about half because local layers keep only 4096 tokens. This row computes that half. REDUCTION VERSUS FULL GQA ON THE SAME SKELETON: 344,064 / 177,408 = 1.94x at a 128K comparison point. The global 21 layers dominate (172,032 B/token); the 21 local layers add 5,376 B/token once their 4096-token window is spread over 128K. AT 8K, which is the context Gemma 2 9B was actually trained for: the local window is half the context (4096/8192), so the local layers contribute 172,032 x 4096 / 8192 = 86,016 B/token and the total is 258,048 B/token, a 1.33x reduction against 344,064. Absolute cache at 8K is 2.01 GiB instead of 2.69 GiB. The interesting saving is at long context, where the local half stops growing: at 32K the effective rate is 172,032 + 172,032 x 4096/32768 = 193,536 B/token, 1.78x under the naive rate, and the cache is 6.19 GiB instead of 11.0 GiB. That is the difference between holding a long Gemma 2 context on a 24 GB card and the naive allocation using the card for cache alone. No quality cost: the window is trained, not a compression. CAVEAT: Gemma 2 was not trained past 8192, so the 128K column is a footprint comparison, not a usable context. An engine that ignores sliding_window still allocates 344,064 B/token, which is the overpay the model record already flags. The 21/21 split is the report's alternating pattern; the config confirms the window size but does not enumerate per-layer types.