All tools
Context · free, no sign-up

How much memory does the KV cache use?

Weights are allocated once and never move. The KV cache grows with every token in the conversation, which is why it — not the model — is usually what runs you out of memory.

3 inputs5 questions answeredUpdated for 2026 hardware
KV Cache Calculator — How much memory does the KV cache use?
Answer first

The short answer

Computed from this tool’s default settings — model size and the rest as most people start. Change them below for your own case.

KV cache at this context1.39 GB

At 8,192 tokens the cache is 1.39 GB, which is 24% of what the model occupies. This is the term that grows while you work, so leave room for it rather than filling the card with weights.

The calculator

KV Cache Calculator

The part of your VRAM that grows with every token in the conversation.

Your setup
8,192
KV cache at this context1.39 GB

At 8,192 tokens the cache is 1.39 GB, which is 24% of what the model occupies. This is the term that grows while you work, so leave room for it rather than filling the card with weights.

Weights4.50 GBFixed at load
Cache1.39 GBGrows with the conversation
Cache share24%
Your memory22.1 GB
ContextCacheTotalOn your card
2,0480.35 GB5.85 GBFits
8,1921.39 GB6.89 GBFits
32,7685.56 GB11.1 GBFits
65,53611.1 GB16.6 GBFits
131,07222.2 GB27.7 GBToo big
Inputs

What each setting changes

Every input moves the result for a reason. This is what each one does and where to find the value for your own machine.

SettingDefaultWhat it changes
Model size8B6 options, from 3B to 405B.
Context length8192 tokensAnywhere from 1,024 to 131,072 tokens.
Your hardwareRTX 4090 · 24 GBThe machine the model runs on. Usable memory decides what fits and memory bandwidth decides how fast it runs, so this moves every figure below.
Worked examples

Real answers across model size

The same calculation run at a range of settings, with everything else left at its default. These are computed by the tool itself, not written by hand.

Model sizeKV cache at this contextWeightsCacheCache share
3B0.85 GB1.69 GB0.85 GB34%
8B1.39 GB4.50 GB1.39 GB24%
14B1.84 GB7.88 GB1.84 GB19%
32B2.78 GB18.0 GB2.78 GB13%
70B4.11 GB39.4 GB4.11 GB9%

At 8,192 tokens the cache is 0.85 GB, which is 34% of what the model occupies. This is the term that grows while you work, so leave room for it rather than filling the card with weights.

Method

How this is calculated

No lookup tables and no invented constants. Here is the arithmetic, so you can check it against your own numbers.

The KV cache stores one key and one value vector per token per layer, so it grows linearly with context length and does not shrink until the conversation is cleared. Weights are fixed; the cache is what actually moves as you use the model.

The estimate scales with the square root of parameter count, which tracks how transformer families widen as they get deeper, and is the same formula used across the rest of the site so the numbers agree.

These are well-founded engineering estimates, not benchmark results. Your quantisation, runtime and context length all move the real number, and usable memory is an assumption rather than a specification. See the full methodology for every assumption behind these figures.

Use cases

Who this is for

The three situations that bring people to this calculation.

Use case 01

Crashes mid-session

See the cache growth that caused it.

Use case 02

Long context

Budget the cache before setting a context length.

Use case 03

Serving

Cost a session so you can set a concurrency limit.

Walkthrough

How to use this calculator

Four steps, no account, nothing leaves your browser.

  1. Set model size

    Start at the top of the panel. Every figure recalculates as you change it — there is no submit button, because watching the number move is the point.

  2. Adjust the rest to match your setup

    2 further settings: context length, your hardware. Defaults are the common case, so change only what differs for you.

  3. Read the headline, then the table

    The large figure answers the question. The table underneath shows how the answer changes across nearby settings, which is usually where the decision actually gets made.

  4. Check it against the method

    The arithmetic is written out above. If a number looks wrong for your hardware, the assumptions are the first place to look — usable memory and quantisation are the two that vary most.

Questions

How much memory does the KV cache use: common questions

The questions people ask about this, answered without hedging.

Why did my model fit at first and then run out of memory?

Almost always the KV cache. Weights are allocated once at load; the cache grows with every token you add, so a long conversation can push a model that loaded cleanly into an out-of-memory error hours later.

What is the KV cache?

Stored key and value vectors for every token processed so far, one pair per layer. It lets the model attend to earlier tokens without recomputing them, at the cost of memory that grows linearly with the conversation.

How do I reduce the KV cache?

Shorten the context, enable flash attention, or quantise the cache — llama.cpp supports 8-bit and 4-bit KV cache, which halves or quarters it for a modest quality cost on long contexts.

Does clearing the chat free the memory?

Yes. Starting a new conversation releases the cache; the weights stay loaded. It is the quickest fix when a long session starts pressing against the limit.

Why is the cache bigger on some models than others?

It scales with layer count and hidden size, and with how many key/value heads the architecture uses. Grouped-query attention shares them across heads and shrinks the cache substantially, which is why modern models handle long context better.

The rest of the set

All 50 run on the same arithmetic, so answers across them agree.

Coverage

Searches this page answers

Different ways of asking the same question, all resolved above.

kv cache size calculatorkv cache memory llmwhat is kv cachereduce kv cache vramkv cache quantizationcontext memory growth llmwhy does vram increase during chathow much memory does the kv cache usekv cache calculatorkv cache calculator onlinefree kv cache calculator
Next step

Now find the models that fit

Sizing is only half the problem. Model Radar takes your hardware and shows which models actually run on it, ranked by what they are good at — the same arithmetic as this page, applied to every model worth running.