By the end of this post you will be able to work out, with pen and paper, how much memory a model needs before you download it. An 8 GB laptop is enough to start, and the same sum tells you when you need more.
Measured first: one 7B at three quantisations
On 2026-11-05 we loaded Qwen2.5-7B-Instruct (7.6B parameters) as three files on our DGX Spark (GB10, Ollama 0.30.10), one at a time, and read the size from /api/ps, the number ollama ps shows. Raw files: 32k context, 4k context.
| Quantisation | File | Weights by the sum below | Loaded, 4k | Loaded, 32k |
|---|---|---|---|---|
| Q4_K_M | 4.68 GB | 4.61 GB | 4.75 GB | 6.59 GB |
| Q8_0 | 8.10 GB | 8.08 GB | 7.89 GB | 9.74 GB |
| FP16 | 15.24 GB | 15.20 GB | 14.52 GB | 16.36 GB |
The weights sum (7.6 × bits ÷ 8) lands within 0.07 GB of each file. Going from 4k to 32k added 1.84 or 1.85 GB to all three: the context cache ignores quantisation. (At 4k, Ollama reported Q8 and FP16 below their file size; we print what it reported.) FP16 takes 2.5 times the memory of Q4_K_M; whether that buys anything is in Q4_K_M vs Q8_0 vs FP16, measured, and how the cache grows to 128k in Ollama num_ctx memory usage, measured.
What you need
- A calculator, and the model’s
config.jsonon Hugging Face (for the cache). - Optional: Ollama, to compare the sum with what your machine loads.
The calculator on each page of our product catalogue uses the same formula, so your numbers will match the site’s.
Step 1: work out what the weights weigh
A model is a list of numbers. The name tells you how many (8B is 8 billion). The quantisation tells you how much each one takes:
weights (GB) = parameters (billions) × bits per weight ÷ 8| Quantisation | Bits per weight | What it is |
|---|---|---|
| Q4_K_M | 4.85 | 4 bits with a few layers kept more precise. Ollama’s default |
| Q8_0 | 8.5 | 8 bits, practically the original |
| FP16 | 16 | the original weights |
The Q4_K_M and Q8_0 values are llama.cpp’s figures for those GGUF types. Why 4 bits is usually enough: how to pick the right GGUF file.
An 8B at Q4_K_M: 8.0 × 4.85 ÷ 8 = 4.85 GB. The same model at FP16 is 16 GB (what that extra memory buys you). Quantisation is the biggest lever you have.
Step 2: add the context cache
While you chat, the model stores two vectors (K and V) per token, in every layer. That is the context cache. It does not depend on the file’s quantisation. It depends on the architecture and on how many tokens you allow:
cache per token (bytes) = layers × KV heads × head dimension × 4
cache (GB) = cache per token × context tokens ÷ 1,000,000,000The 4 is 2 vectors (K and V) times 2 bytes at FP16. All three values are in the model’s config.json: num_hidden_layers, num_key_value_heads and head_dim. If head_dim is missing, divide hidden_size by num_attention_heads.
| Model | Layers | KV heads | Head dim | Cache per token | Source (read 2026-10-06) |
|---|---|---|---|---|---|
| Llama 3.1 8B | 32 | 8 | 128 | 0.131 MB | config.json |
| Qwen 2.5 32B | 64 | 8 | 5,120 ÷ 40 = 128 | 0.262 MB | config.json |
| Llama 3.3 70B | 80 | 8 | 128 | 0.328 MB | config.json |
We read both Llama configs from unsloth’s copy because Meta’s repository asks you to register. The architecture is identical.
KV heads are 8 in all three. Without that trick (grouped-query attention), a 70B with 64 heads would store eight times as much cache.
Step 3: add the runtime and compare with your usable memory
Add 1.5 GB of runtime (compute buffers and the engine itself). Then subtract what the system keeps:
- Dedicated VRAM (a graphics card): total memory minus 0.5 GB.
- Unified memory or system RAM: minus 3 GB up to 16 GB, minus 4 GB up to 32 GB, minus 6 GB above that.
That gives you usable memory. The calculator’s rule: it fits comfortably if the need is 85% of usable memory or less. Between 85% and 100% it is a tight fit. Above that, it does not fit.
Three worked examples
These are the site’s own functions (memoryNeededGb, usableMemoryGb and fitStatus in src/lib/hardware-math.ts), run with Node on 2026-10-06 and rounded.
| Example | Weights | Cache | Runtime | Total |
|---|---|---|---|---|
| Llama 3.1 8B, Q4_K_M, 8k | 8.0 × 4.85 ÷ 8 = 4.85 GB | 0.131 × 8,192 = 1.07 GB | 1.5 GB | 7.42 GB |
| Qwen 2.5 32B, Q4_K_M, 8k | 32.8 × 4.85 ÷ 8 = 19.88 GB | 0.262 × 8,192 = 2.15 GB | 1.5 GB | 23.53 GB |
| Llama 70B, Q4_K_M, 8k | 70.6 × 4.85 ÷ 8 = 42.80 GB | 0.328 × 8,192 = 2.69 GB | 1.5 GB | 46.99 GB |
A note on the 32B: the calculator uses 32.8 billion parameters and Qwen’s model card says 32.5. The difference is 0.2 GB. For the 70B we use 70.6, the Llama 3.1 70B figure, which shares its architecture with Llama 3.3.
Now against real machines:
| Memory | Usable | 85% line | 8B | 32B | 70B |
|---|---|---|---|---|---|
| 8 GB GPU | 7.5 GB | 6.38 GB | tight | no | no |
| 12 GB GPU | 11.5 GB | 9.78 GB | comfortable | no | no |
| 24 GB GPU | 23.5 GB | 19.98 GB | comfortable | no (by 0.03 GB) | no |
| 32 GB unified | 28 GB | 23.8 GB | comfortable | comfortable | no |
| 64 GB unified | 58 GB | 49.3 GB | comfortable | comfortable | comfortable |
The 32B on a 24 GB card is the case that teaches most. At 8k context it misses by 30 MB. Drop to 4k and the cache falls to 1.07 GB: total 22.46 GB, a tight fit. Context decides.
Why context weighs so much
The cache grows in a straight line with tokens. For the 8B above:
| Context | Cache | Total at Q4_K_M |
|---|---|---|
| 4k | 0.54 GB | 6.89 GB |
| 8k | 1.07 GB | 7.42 GB |
| 32k | 4.29 GB | 10.64 GB |
| 128k | 17.17 GB | 23.52 GB |
Accepting 128k tokens does not mean reserving them: ask for the context your task uses.
Unified memory versus dedicated VRAM
A graphics card has its own memory (VRAM); whatever does not fit there runs on the CPU, much more slowly.
Apple silicon Macs, the DGX Spark (GB10, 128 GB) and AMD Strix Halo machines use unified memory: CPU and GPU share one pool, so a 64 GB machine can give almost all of it to the model. The reserve is larger because the operating system lives there too.
What the spec sheet won’t tell you: fitting is not running fast. Speed depends on memory bandwidth, where a dedicated GPU usually wins; see the hardware catalogue by budget.
Check real usage
The sum is an estimate. Your machine has the last word:
ollama ps
# NAME SIZE PROCESSOR CONTEXT
# llama3.1:8b 9.2 GB 100% GPU 32768SIZE is the memory the loaded model takes. If PROCESSOR is not 100% GPU, part of it is on the CPU: lower the quantisation or the context.
On a dedicated NVIDIA card, nvidia-smi confirms it:
nvidia-smi --query-gpu=memory.used,memory.total --format=csvOn the GB10 it returns [N/A] (unified memory); use ollama ps there.
The sum against our GB10 with llama3.1:8b at Q4_K_M (PRIME, Ollama 0.30.10, one slot, 2026-11-02, raw file):
| Context | Site’s sum | Measured (ollama ps) |
|---|---|---|
| 4,096 | 6.89 GB | 5.27 GB |
| 32,768 | 10.64 GB | 9.21 GB |
| 131,072 | 23.52 GB | 22.79 GB |
The sum came out high every time, by 0.7 to 1.6 GB: we would rather you had memory to spare.
When not to trust the sum
- Mixture-of-experts (MoE) models. All parameters count for memory, even if only a few work on each token. Plan with the file size plus the slots: our
gemma4:26b(17.99 GB file) loaded at 17.47 GB with one 32k slot and 22.64 GB with 8 slots of 16k (2026-11-02, raw files for PRIME and spark2). - Quantised cache. Some engines store the cache in 8 bits. It then takes half, and the formula overestimates.
- Other services on the same machine. If another model is already loaded, subtract it from usable memory.
- Images and vision. Multimodal models add an encoder. Allow an extra margin.
Parallel slots multiply the cache
The sum above is for one conversation. Ollama reserves a separate context for every parallel slot (OLLAMA_NUM_PARALLEL), so the cache multiplies by the slots. On 2026-11-02 we loaded llama3.1:8b at Q4_K_M on our two GB10 boxes: at 32k, one slot took 9.21 GB, four took 22.38 GB and eight took 39.27 GB (raw file).
Set each model’s size with PARAMETER num_ctx in a Modelfile so the server default never decides for you. The full tables, and the day this broke our second box: Ollama num_ctx memory usage, measured.
Next steps
- Read a model’s weight per quantisation in the VRAM explorer, then add the cache and runtime.
- Before you buy, compare budgets in the local AI hardware catalogue.
- Which model fits that memory: Best local LLMs by hardware and task.
Let’s talk for 15 minutes
We run this sum with your team’s real documents and context, and measure it on hardware before recommending anything. If you want it for your company, ask for a 15-minute call or see how we work in consulting.