Skip to content

Context And Memory

A model needs memory for two things: the model itself, and the conversations it is working on. This page explains the second, which is the part most people do not expect. It ends with a calculator that puts the two together, and a guide to how fast a model will answer.

Tokens

Models read and write text in tokens — pieces of words. In English, a token is about three-quarters of a word, so:

Text Tokens (about)
A short question 20–50
A page of a document 500–700
A 20-page report 12,000
A 300-page book 130,000

Code, numbers, tables and most languages other than English use more tokens for the same amount of text.

The Context Window

The context window is how many tokens the model can work with at once, for one conversation. Everything the model reads has to fit in it:

  • the Assistant's instructions, and descriptions of its tools
  • the conversation so far
  • attached documents and Knowledge Base passages
  • the results of any tools it uses
  • its thinking, if it thinks, and its answer.

When a conversation outgrows the window, OnVeris Chat leaves its oldest messages out. See Context Window.

How Big A Window Do You Need?

A bigger window is not better in itself: it costs memory, and a model that has to read more answers more slowly. Choose one for the work people will actually do:

Use Context window
Everyday questions and short chats 8,000–16,000
Chats with a document attached, or a Knowledge Base 32,000
Assistants that use tools, and thinking models 32,000–64,000
Long documents, code, and long tool runs 64,000–128,000 or more

When OnVeris first finds a model, it chooses a window from the machine's system memory: from 4,096 tokens up to 32,768. You can change it in the model's settings, up to the model's own maximum. See Executor Settings.

Tip

If you are not sure, start at 32,000. OnVeris Chat shows each conversation's use of the window, so you can see whether people come close to it.

The KV Cache

While a model works on a conversation, it keeps what it has read in the KV cache, so that it does not have to read it all again for each new word. The KV cache is what the context window costs in memory.

The KV cache is reserved in full when the model starts, for the whole context window. So a model set to 128,000 tokens uses the memory for 128,000 tokens even when every conversation is short.

How much memory each token takes depends on how the model is built:

  • Most models need from about 0.05 MB to 0.4 MB per token. For example, an 8B model of a common design needs about 0.13 MB per token, so 32,000 tokens take about 4 GB — almost as much as the model itself at Q4_K_M.
  • Some newer models keep a full KV cache in only some of their layers. They use other kinds of layer — such as linear attention or a sliding window — that need little or no cache. These can hold a very long context in much less memory.

The memory estimate in each model's settings shows exactly how much its context takes, as Context. See Executor Settings.

Storing The KV Cache At Lower Precision

You can store the KV cache at lower precision, much as a model file is quantised. In the model's settings, set KV Cache to:

  • Q8_0 — about half the memory. The effect on answers is very small. This is a good way to double the context window in the same memory.
  • Q4_0 — about a quarter of the memory. Answers can suffer, especially in long conversations and in code.

Keep Flash Attention on when you do. See Executor Settings.

Requests At Once

Requests at Once sets how many conversations a model answers at the same time. With a number set, each conversation gets the full context window, and the model reserves a KV cache for each one. So the memory for context is:

memory per token × Context Window × Requests at Once

For example, 32,000 tokens with 4 requests at once needs the same memory as 128,000 tokens with one. Requests beyond the number will wait their turn.

With Automatic, the model answers up to four at once but they share one window, so two long conversations at the same moment can run out of room. See Hardware And GPU, and Serve More People At Once On Two GPUs for a worked example.

Adding It Up

A model's memory comes to:

Part What it is
Weights The model file. About the file's size on disk
Context The KV cache: memory per token × context window × requests at once
Working space Space llama.cpp needs while it works. Usually under 1–2 GB
Projector Only for image input. The projector file's size

How Much Memory You Have

Machine Memory the model can use
A GPU Its memory (VRAM), less about 2 GB that OnVeris leaves free by default — the GPU memory margin, in the Memory section of any model's settings
A Mac Its memory is shared between the CPU and GPU. macOS lets the GPU use about two-thirds of it on smaller Macs, and about three-quarters on Macs with 64 GB or more
No GPU System memory, less what the operating system and other programs need — leave at least 4–8 GB

A model that is too big for the GPU still runs: llama.cpp moves part of it to system memory, where the CPU works on it. It will be much slower. The memory estimate warns you when this would happen.

With several GPUs, one copy of a model can be split across them. See Sharing A Model Across GPUs.

Memory Calculator

The calculator below adds up the parts above for a few well-known models, or for any model from its size.

This is a guess

The calculator uses typical figures, not your model's exact design or your machine's backend. It can be out by a gigabyte or more, and further for models it does not list. Use it to narrow down what to download. Before you start a model, check the memory estimate in its settings: that comes from llama.cpp itself, on the Node, and is the one to trust.

How Fast Will It Be?

Two speeds matter:

  • Reading — how long the model takes to read the prompt before it starts to answer. This depends mostly on the GPU's processing power. It is what makes the first word slow after a long document is attached. A GPU reads many times faster than a CPU.
  • Writing — how fast the answer comes out once it starts. For each token it writes, the model reads all of its active weights from memory. So writing speed depends mostly on memory bandwidth: how fast the hardware can read its memory.

As a rough guide, the most tokens per second a model can write is:

memory bandwidth (GB/s) ÷ the model's size (GB)

Expect to see about 60–80% of that in practice. For a mixture-of-experts model, use the size of its active part. For example, a 17 GB model on a Mac with 120 GB/s of bandwidth can write at most about 7 tokens per second. In our testing, Qwen3.8-27B at Q4_K_M wrote 6.2 tokens per second on a Mac with a base M4.

Hardware Memory bandwidth (about) Most tokens per second for a 5 GB model For a 17 GB model
A desktop PC, no GPU (dual-channel DDR5) 60–90 GB/s 12–18 4–5
Mac with M4 120 GB/s 24 7
Mac with M4 Pro 273 GB/s 55 16
Mac with M4 Max 410–546 GB/s 80–110 24–32
Mid-range GPU (for example 16 GB) 250–450 GB/s 50–90 — (does not fit)
High-end GPU (24–32 GB) 640–1,800 GB/s 130–360 38–105

These are upper limits, worked out from published bandwidths. Your figures will be lower. OnVeris Chat shows each answer's real speed: point at the answer to see it.

People read at about 5–8 tokens per second, so anything above about 10 feels comfortable in a chat. Thinking models and tool use need more, because they write a lot that nobody reads.

Several conversations at once on one GPU share its speed: each is slower than one alone, but the GPU gets more done in total.