---
title: "Watch context turn into memory."
description: "Calculate KV cache memory from layers, KV heads, head size, context length, batch and precision, and see how many sequences fit on your GPU."
canonical_url: "https://fanout.sh/labs/kv-cache"
md_url: "https://fanout.sh/labs/kv-cache.md"
last_updated: "2026-10-31"
access: "public"
---

# Watch context turn into memory.

Calculate KV cache memory from layers, KV heads, head size, context length, batch and precision, and see how many sequences fit on your GPU.

## Public overview

The KV cache stores one key and one value for every transformer layer, cached token, and active sequence so autoregressive decoding can reuse earlier attention state.

The deterministic estimate is 2 × layers × KV heads × head dimension × cached tokens × active sequences × bytes per element.

Grouped-query attention lowers cache pressure by sharing key and value heads, while longer contexts and more active sequences multiply memory use.

The calculator isolates KV-cache memory. Model weights, activations, allocator fragmentation, CUDA graphs, and runtime overhead still need separate GPU headroom.

---
This representation contains public Fanout content only. Protected Pro lessons, account data, billing, checkout, and pricing are not included.

Browse the public content map: https://fanout.sh/sitemap.md
