Lab

Will it run on my machine?

Work out whether a model fits on your hardware, and how fast it will talk, from memory and bandwidth alone.

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?

Estimates

Fits on the GPU

6.3 GiB of 12.0 GiB, leaving 5.7 GiB free.

8K
Up to 128K tokens
KV cache precision
Not listed? Choose Custom and enter memory and bandwidth from the spec sheet. Newest in this list: Radeon RX 9060 XT (June 2025); newest model: gpt-oss (August 2025).
Assumptions
70%
Share of peak bandwidth actually achieved. 60–80% is typical.
60%
Share of peak FLOPS achieved while reading the prompt.
0.5 GiB
Driver context and buffers, on top of the logits buffer.
System RAM for offload

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).

GPU memory (VRAM)6.3 GiB of 12.0 GiB
Weights 4.6 GiBWeightsKV cache 1.0 GiBRuntime 0.7 GiBFree 5.7 GiBFreeVRAM 12.0 GiBLlama 3.1 8BLlama 3.1 8BQ4_K_M
Weights 4.6 GiBKV cache 1.0 GiBRuntime 0.7 GiBFree 5.7 GiB

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.

Decode, empty context
55 tok/s
estimated
Decode at 8K tokens
44 tok/s
the cache is read too
Time to first token
499 ms
1,000-token prompt, prefill ≈ 2,004 tok/s
QuantityHow it is worked outValue
Weights8.03B params × 4.89 bits ÷ 84.58 GiB
KV cache2 × 32 layers × 8 KV heads × 128 head size × 2 B per value × 8,192 tokens1.00 GiB
Runtime0.5 GiB + 512 × 128,256 vocab × 4 B0.74 GiB
Read per token7.50B params × 4.89 ÷ 8 + KV at 8K5.28 GiB
5.67e9 B
Decode speed360 GB/s × 0.70 ÷ 5.67e9 B44 tok/s
Prefill time15.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.

Memory is in binary GiB (230 bytes; a “12 GB” card holds 12 GiB). Bandwidth is decimal GB/s (109 bytes per second) from spec sheets. Speeds are first-order estimates: change the efficiency factors under “Assumptions” to match your own measurements. The page address updates as you change settings, so you can bookmark a setup. Model and hardware data checked 26 November 2026.

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

weights=P×bits per weight8

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:

bytes per token=2×layers×KV heads×head size×bytes per value

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:

tokens/s≈bandwidth×efficiencyactive weight bytes+KV bytes so far

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?

ridge at 142 FLOPs per byte
1
Decode reaches the ridge at a batch of about 63.
256
100G1T10T100T0.11101001,00010karithmetic intensity (FLOPs per byte read)attainable FLOP/smemory-boundcompute-boundPrefill, 512 tokens: 1664 FLOPs/byteDecode, one stream: 3.27 FLOPs/byteprefill 512decode, 1 stream
Decode, 1 stream 3.27 FLOPs/BPrefill 512 1664 FLOPs/B
Per stream, at peak
78 tok/s
memory-bound
The one stream
78 tok/s
1.2 TFLOPS used
Weights + all KV caches
4.6 GiB
of 12 GiB
Log–log axes. The solid roof is the hardware’s peak: the slope is memory bandwidth, the flat part is peak compute. The dashed roof applies your efficiency factors. Points sit on the roof at their arithmetic intensity (FLOPs done per byte read). KV cache memory for large batches is not checked against the device here.

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:

prefill time≈2×Pactive×N+attentionpeak FLOPS×efficiency

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

Llama 3.1 8B · 8K context · RTX 3060 12 GB
QuantBitsWeightsMemory neededFittok/sPPL +
16.0015.0 GiB
22/32 on GPU8.1baseline
8.507.9 GiB
fits280.0026
6.566.1 GiB
fits350.0217
5.705.3 GiB
fits390.0569
4.894.6 GiB
fits440.1754
4.674.4 GiB
fits460.2689
4.464.2 GiB
fits48–
4.003.7 GiB
fits520.6569
3.763.5 GiB
fits55–
3.163.0 GiB
fits623.5199
2.932.7 GiB
fits66–
Bars show total memory needed (weights, KV cache and runtime) against the line for available memory (hidden on narrow screens). Decode is in tokens per second; PPL + is the perplexity increase. Bits per weight are llama.cpp’s published effective values for Llama 3.1 8B; other models land close but not exactly. Perplexity increase is llama.cpp’s own published figure for Llama 3 8B, relative to F16; it is a rough guide to quality loss, not a measurement of this model. A dash means llama.cpp publishes no figure. Select a row to use it above.

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

top-8 of 128 experts per token, per layer
router“Kia”Expert 1Expert 2Expert 3Expert 4Expert 5Expert 6Expert 7Expert 8Expert 9Expert 10Expert 11Expert 12Expert 13Expert 14Expert 15Expert 16Expert 17Expert 18Expert 19Expert 20Expert 21Expert 22Expert 23Expert 24Expert 25Expert 26Expert 27Expert 28Expert 29Expert 30Expert 31Expert 32Expert 33Expert 34Expert 35Expert 36Expert 37Expert 38Expert 39Expert 40Expert 41Expert 42Expert 43Expert 44Expert 45Expert 46Expert 47Expert 48Expert 49Expert 50Expert 51Expert 52Expert 53Expert 54Expert 55Expert 56Expert 57Expert 58Expert 59Expert 60Expert 61Expert 62Expert 63Expert 64Expert 65Expert 66Expert 67Expert 68Expert 69Expert 70Expert 71Expert 72Expert 73Expert 74Expert 75Expert 76Expert 77Expert 78Expert 79Expert 80Expert 81Expert 82Expert 83Expert 84Expert 85Expert 86Expert 87Expert 88Expert 89Expert 90Expert 91Expert 92Expert 93Expert 94Expert 95Expert 96Expert 97Expert 98Expert 99Expert 100Expert 101Expert 102Expert 103Expert 104Expert 105Expert 106Expert 107Expert 108Expert 109Expert 110Expert 111Expert 112Expert 113Expert 114Expert 115Expert 116Expert 117Expert 118Expert 119Expert 120Expert 121Expert 122Expert 123Expert 124Expert 125Expert 126Expert 127Expert 128
Used for this token 8Used earlier in the sentence 0Not yet used 120
In memory (all experts)
17.4 GiB
30.53B params
Read per token
1.7 GiB
3.30B active params
Decode, this MoE
61 tok/s
estimated; 30 of 48 layers on the GPU
A dense model this size
6.4 tok/s
same memory, every weight 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.

One layer shown. A real model routes every token separately in each of its 48 layers, using a small learned router; here a seeded random choice stands in for it. Words stand in for tokens. Speeds assume Q4_K_M weights, 1,024 tokens of context and the hardware chosen above (RTX 3060 12 GB). They use the same decode efficiency as dense models, but MoE decoding usually reaches a smaller share of the bandwidth bound, so treat the MoE figure as an upper estimate; the ratio between the two tiles is the robust part.

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

Llama 3.1 8B · Q4_K_M · RTX 3060 12 GB
2,000
1,000
0 s21 s
Prefill: read 2,000 prompt tokens at once 1.0 sDecode: 1,000 tokens one at a time 20 s
02468101205001.0k1.5k2.0k2.5k3.0ktokens in the contextGiBVRAM

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).

Time to first token
1.0 s
compute-bound
Average decode
51 tok/s
memory-bound
KV cache at the end
0.37 GiB
3,000 tokens
Estimated with the efficiency factors from the calculator. Runtimes usually reserve the whole context window up front; the chart shows how much of that reservation fills as the conversation grows. Each new token must read the whole cache so far, so decoding slows a little as the line climbs.

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 in q8_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-bench and 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