You have found an open-weight model you want to try, and a computer you already own. Two questions come first: will it fit, and will it be fast enough to be pleasant? Download pages give you a file size, not what happens in a long conversation.
Before this: How attention decides what matters explains the KV cache that this page sizes for your hardware.
Both answers come from a little arithmetic you can do by hand. Memory is weights, plus a cache that grows with every token of context, plus a little for the runtime. Speed, once the model is talking, is mostly memory bandwidth divided by the bytes it reads for each new token. The model’s maths hardly matters.
The calculator below does that arithmetic for real models and real hardware, and shows every formula next to its number. Everything it prints is an estimate. The efficiency factors are yours to change, so you can line it up with what you measure on your own machine. Memory is shown in GiB (230 bytes), the unit cards and Macs are actually sold in, even when the box says “GB”.
Will it fit, and how fast?
Fits on the GPU
6.3 GiB of 12.0 GiB, leaving 5.7 GiB free.
Assumptions
Derived: 28 SMs × 1.78 GHz boost × 1,024 FP16 FLOPs per SM per clock (the Ampere rate that gives the RTX 3090’s published 142 TFLOPS).
The model file loads into GPU memory, with its KV cache and runtime buffers. Widths are to scale; anything past the chip’s right edge does not fit there.
| Quantity | How it is worked out | Value |
|---|---|---|
| Weights | 8.03B params × 4.89 bits ÷ 8 | 4.58 GiB |
| KV cache | 2 × 32 layers × 8 KV heads × 128 head size × 2 B per value × 8,192 tokens | 1.00 GiB |
| Runtime | 0.5 GiB + 512 × 128,256 vocab × 4 B | 0.74 GiB |
| Read per token | 7.50B params × 4.89 ÷ 8 + KV at 8K | 5.28 GiB 5.67e9 B |
| Decode speed | 360 GB/s × 0.70 ÷ 5.67e9 B | 44 tok/s |
| Prefill time | 15.3 TFLOP ÷ (51 TFLOPS × 0.60) | 499 ms |
Bytes per token with an empty cache: 4.28 GiB. Input embeddings are a lookup, so 525M embedding params are not counted as read.
Check it on your machine. Run llama.cpp’s llama-bench -m model.gguf. By default it reports pp512 (reading a 512-token prompt) and tg128 (generating 128 tokens), both in tokens per second (llama-bench README). Compare tg128 with “Decode, empty context” and pp512 with the prefill rate under the first-token tile, then move the two efficiency sliders under “Assumptions” until they match.
Where the memory goes
Weights are the easy part. Every parameter is stored with some number of bits, so
Llama 3.1 8B has 8.03 billion parameters. In f16 that is 15.0 GiB; at Q4_K_M, which averages 4.89 bits per weight, it is 4.6 GiB. The bits-per-weight figures are llama.cpp’s own measurements, slightly above the name because each block of weights also stores a scale. What quantisation does to a model has the details.
The KV cache is the part people forget. Attention reuses every earlier token’s keys and values, so the runtime keeps them; How attention decides what matters shows why. Sizing it takes one formula:
For Llama 3.1 8B in f16 that is 2 × 32 × 8 × 128 × 2 bytes = 128 KiB per token. An 8,192-token context costs exactly 1 GiB, and the full 128K context costs 16 GiB, more than three times the quantised weights. Stored as q8_0 it is 68 KiB per token (34 bytes for every 32 values), and q4_0 is 36 KiB, at some cost in accuracy on long inputs.
Models with fewer KV heads than query heads, using grouped-query attention, keep this down. Phi-3 mini has no grouping, so its 4,096-token cache is 1.5 GiB for a 3.8B model. Gemma 2, Gemma 3 and gpt-oss use sliding-window attention on some layers, which caps those layers’ cache at a fixed window; the calculator accounts for this.
The runtime needs room too: the graphics driver’s context, scratch buffers, and a buffer of logits for the 512 tokens processed at once. We allow 0.5 GiB plus that buffer, and you can change it under “Assumptions”.
When the total is bigger than the card, llama.cpp and tools built on it can put some layers on the GPU and the rest in system RAM. The calculator splits the model by layer, the way the -ngl setting does, and reports how many fit.
Why decoding is limited by memory, not maths
Once the prompt has been read, the model produces one token at a time. For each token it multiplies the new token’s vector by every active weight: about 2 FLOPs (a multiply and an add) per parameter. To do that it streams every one of those weights from memory. At Q4_K_M each parameter is about 0.61 bytes, so the processor does roughly 3.3 FLOPs for every byte it reads. At f16, about 1.
A GPU can do far more maths per byte than that. An RTX 3060 can do about 142 FLOPs in the time it reads one byte; an RTX 4090 about 328. So during decoding the processor mostly waits for memory, and bandwidth sets the speed:
The roofline makes this visible. The horizontal axis is arithmetic intensity, the FLOPs done per byte read. Below the ridge point the hardware can only go as fast as memory feeds it, so the roof slopes up. Above it, the maths units are the limit and the roof is flat.
The roofline: is it memory or maths?
Prefill is different. Reading a prompt processes hundreds or thousands of tokens in one pass, so each weight read from memory is used hundreds of times. That pushes prefill well past the ridge, and compute sets its speed:
Quantisation: smaller, faster, slightly worse
Because decoding streams the weights, shrinking them helps twice: the model fits in less memory, and each token needs fewer bytes. Going from Q8_0 to Q4_K_M on an RTX 3060 takes Llama 3.1 8B from about 32 to about 55 tokens a second with an empty context (28 to 44 at the full 8K context the table below uses), and frees 3.4 GiB.
What each quantisation buys you
| Quant | Bits | Weights | Memory needed | Fit | tok/s | PPL + |
|---|---|---|---|---|---|---|
| 16.00 | 15.0 GiB | 22/32 on GPU | 8.1 | baseline | ||
| 8.50 | 7.9 GiB | fits | 28 | 0.0026 | ||
| 6.56 | 6.1 GiB | fits | 35 | 0.0217 | ||
| 5.70 | 5.3 GiB | fits | 39 | 0.0569 | ||
| 4.89 | 4.6 GiB | fits | 44 | 0.1754 | ||
| 4.67 | 4.4 GiB | fits | 46 | 0.2689 | ||
| 4.46 | 4.2 GiB | fits | 48 | – | ||
| 4.00 | 3.7 GiB | fits | 52 | 0.6569 | ||
| 3.76 | 3.5 GiB | fits | 55 | – | ||
| 3.16 | 3.0 GiB | fits | 62 | 3.5199 | ||
| 2.93 | 2.7 GiB | fits | 66 | – |
The cost is quality: llama.cpp’s published perplexity figures show little loss down to about 5 bits and a fast rise below 4, which What quantisation does to a model explains with the full table.
Mixture of experts: big in memory, small per token
A mixture-of-experts (MoE) model replaces each layer’s single feed-forward block with many smaller “experts” and a small router. For every token, in every layer, the router picks the top few experts and only those run. Qwen3 30B-A3B has 128 experts per layer and uses 8; Mixtral 8x7B has 8 and uses 2.
Mixture of experts: all in memory, few read
After 1 token, 8 of 128 experts have been used in this layer (if routing were uniform you would expect 8.0). This is why a long prompt, or many users at once, ends up touching every expert. On the RTX 3060 12 GB this model is partly offloaded: 30 of 48 layers fit on the GPU and the rest are read from system RAM, which sets the speed.
That changes the arithmetic. Memory has to hold every expert, because the next token might need any of them: 17.4 GiB for Qwen3 30B-A3B at Q4_K_M. But each token only reads the shared attention weights and its chosen experts, 3.3 billion active parameters instead of 30.5 billion. Since decoding speed is bytes per token, an MoE model decodes like a much smaller dense model. On an M4 Pro with 48 GB, the estimate is about 105 tokens a second for Qwen3 30B-A3B against about 10 for the dense Qwen3 32B, which needs nearly the same memory. Both use the same decode efficiency, but MoE decoding usually reaches a smaller share of the bandwidth bound than dense decoding, so treat the MoE figure as an upper estimate. The gap between the two is the robust part.
The catch is that you still need the memory. If experts spill into system RAM, every token pays for the slower memory. And as the sentence in the figure goes on, more experts get used. A long prompt, or many users at once, touches almost all of them, so prefill and batched serving lose much of the advantage.
Prefill, then decode
From the user’s side, a reply has two phases. First the model reads the whole prompt in parallel; the wait before the first token appears is the time to first token. Then it writes the answer one token at a time. The first phase is compute-bound and the second memory-bound, so they respond to different hardware.
Prefill, then decode
The vertical line marks the end of the prompt, where the first answer token appears. The dashed line is the card’s VRAM (12.0 GiB).
On an RTX 3060 with Llama 3.1 8B, a 1,000-token prompt takes about half a second to read, then each answer token takes around 20 milliseconds. On a Raspberry Pi 5 the same prompt takes about 27 seconds with Llama 3.2 1B, even though the answer then streams at a readable 16 tokens a second.
What this means for local AI
Numbers from the calculator, with Q4_K_M weights, f16 KV cache, 8K of context and default efficiency factors unless stated:
- A 12 GB card (RTX 3060 or Intel Arc B580) runs a 7–8B model with about 5.7 GiB left over. The 3060 decodes it at roughly 55 tokens a second with an empty context; the Arc’s 456 GB/s gives about 70. That headroom is what lets you raise the context to 32K. A 14B model also fits, with 1.3 GiB to spare, at about 29 tokens a second.
- A 16 GB card (RTX 4060 Ti, RTX 5060 Ti or Radeon RX 9060 XT) runs gpt-oss-20b, which ships with 4-bit experts, in about 12.5 GiB with 16K of context: an estimated 96 tokens a second on the 4060 Ti, as an upper estimate.
- A 24 GB card fits a 32B dense model with about 2.5 GiB to spare, at roughly 36 tokens a second on an RTX 4090. A 70B model does not fit; with half of it in system RAM you get about 3 tokens a second.
- Set the context you need, not the maximum. Runtimes reserve the whole KV cache up front. A 128K context costs Llama 3.1 8B 16 GiB in
f16, or 8.5 GiB inq8_0, and decoding at the end of a full 128K context is about a fifth as fast as at the start. - A 16 GB Mac (base M2 and M3 chips have 100 GB/s, the M4 120 GB/s) gives the GPU about 12 GiB by default. An 8B model decodes at about 15 (M2) to 18 (M4) tokens a second, a 14B model at about 8 to 10, and a 1,000-token prompt takes 6 to 13 seconds to read. gpt-oss-20b needs about 12.4 GiB, just over the default share: raise the limit and close other apps. Qwen3 30B-A3B does not fit.
- Bigger Macs can hold big models because the GPU shares system memory, but macOS lets the GPU use only about 75% of it by default (an approximate, undocumented figure). A 64 GB M4 Max fits a 70B model at Q4_K_M in its 48 GiB GPU share, at around 9 tokens a second.
- No graphics card? A desktop with dual-channel DDR5 decodes an 8B model at roughly 14 tokens a second, and a Raspberry Pi 5 runs a 1B model at about 16. Both are fine for short prompts.
When choosing hardware, compare memory bandwidth, not only memory size, and budget the KV cache before setting a long context. There is a privacy reason to run locally too: under the Privacy Act 2020, information privacy principle 5 asks anyone holding personal information to protect it with reasonable security safeguards, and a model on your own hardware keeps prompts and documents on that hardware.
What we simplified
- Efficiency factors stand in for software. Real speed depends on kernels, drivers, batch sizes and CPU threads. We use one decode efficiency (default 70% of peak bandwidth) and one prefill efficiency (default 60% of peak FLOPS) for every device, chosen with CUDA and Metal in mind. Vulkan, ROCm and SYCL users, and anyone on a CPU or Raspberry Pi (where 70% is a rough guess), should measure with
llama-benchand set their own. - One bits-per-weight figure per quant, measured by llama.cpp on Llama 3.1 8B. Other models mix tensor types differently, so their files differ by a few per cent.
- Quality numbers are for one model. The perplexity increases are llama.cpp’s figures for Llama 3 8B.
- Runtime overhead is one allowance. Real overhead depends on the backend, flash attention, batch size and what else is on your screen.
- Offloading is simplified. We split by whole layers, assume 32 GB of DDR5 behind a discrete GPU, and give prefill the faster of computing offloaded layers on the CPU or streaming them over PCIe 4.0. Real runtimes can, for example, keep only an MoE model’s experts on the CPU.
- Apple numbers are partly estimated. Apple does not publish GPU FLOPS, so we derive them from llama.cpp’s measured prompt speeds. The 75% GPU share comes from llama.cpp logs and varies with macOS versions. We keep 3 GiB back for macOS when the limit is raised; that is our assumption, and you can change it.
- MoE uses the dense efficiency. MoE speeds are upper estimates, and the figure uses a seeded random router; real routers have favourite experts.
- No speculative decoding, prompt caching or multi-GPU setups. Each can change the picture substantially.
Next: What quantisation does to a model, where the bits per weight come from.
Inspired by, and worth your time
- LLM Inference Handbook by Modular
- A Visual Guide to Mixture of Experts by Maarten Grootendorst