AN ESTIMATE, NOT A MEASUREMENT

This is arithmetic from published model configurations, not a benchmark. It tells you whether a setup is worth trying, not how fast it will run or whether your engine accepts it. Where I have run a matching setup myself, the result links to that measurement; everything else is a starting point to measure on your own machine.

§1The calculator

§2The formula

Memory needed is four parts added together. Everything is counted for one request at a time; a server holding several conversations pays the KV cache once per conversation.

PartFormulaWhat it depends on
Weightstotal parameters × bits per weight ÷ 8Every parameter, including every expert of a mixture-of-experts model
KV cache2 (keys and values) × attention layers × KV heads × head dimension × bytes per element × tokensContext length and cache precision; sliding-window layers stop at their window
Recurrent statelinear-attention layers × heads × key dimension × value dimension × 4 bytesFixed per request in hybrid models; zero in plain transformers
Runtime overhead1.5 GiB + 5% of the weightsThe engine, its compute buffers and activations

A worked example, for Qwen 3.8 27B with a 32,768-token context and a 16-bit cache. Its cache is small for its size, because only 16 of its 64 layers are full attention. Each part is rounded to 0.1 GiB:

QuantizationWeightsKV cacheState + overheadTotal
NVFP4 · 4.5 bits14.6 GiB2.0 GiB2.4 GiB18.9 GiB
Q4_K_M · 4.9 bits15.8 GiB2.0 GiB2.4 GiB20.3 GiB
Q8_0 · 8.52 bits27.6 GiB2.0 GiB3.0 GiB32.6 GiB
BF16 · 16 bits51.7 GiB2.0 GiB4.2 GiB58.0 GiB

Then the verdict compares the total with a budget. On a discrete GPU the budget is its memory; what does not fit can spill into system RAM, minus 8 GiB kept for the operating system. On a Mac it is macOS’s GPU limit. On a DGX Spark it is the unified memory minus 8 GiB.

§3Every assumption

§4The cases a simple formula gets wrong

§5Estimates against measurements

Two of my own measurements check the arithmetic. On the RTX 5090, Qwen 3.8 27B in NVFP4 with an FP8 cache held a physical KV pool of 114,688 tokens. The formula gives exactly 3.5 GiB for that pool, and the engine’s startup log reported the same 3.5 GiB. On the 128 GB M4 Max, the MLX 8-bit weights are about 29.5 GB; Q8_0’s rate gives 29.6 GB.

The calculator is weakest where checkpoints mix precisions. For Flash-Next in NVFP4 it estimates 115 GiB of weights against NVIDIA’s published 123.57 GiB, because that export keeps attention and shared experts in BF16. So where a published file size is known, the calculator uses it. And when the headroom is smaller than the estimate’s typical error (10% of every formula-sized part, 3% of a published file), the verdict says “measure first”.

The calculator in one view

  • Weights are every parameter × bits ÷ 8; “active” parameters change speed, not memory.
  • The KV cache grows with context, but only on full-attention layers.
  • Macs give the GPU about 75% of memory by default; raising iogpu.wired_limit_mb is a deliberate choice.
  • Offload and slow-memory tables make a model fit, and make it slower.
  • An estimate decides what to try; only a measurement decides what works.

How these figures were gathered. Layer counts, attention layouts, KV heads, head dimensions and parameter counts were read from each model’s Hugging Face configuration, parameter count and model card on 8 October 2026; the source of every value is recorded in the calculator’s code. The quantization rates come from llama.cpp’s quantize tool and NVIDIA’s NVFP4 description, read the same day. The two cross-checks are my own runs from August 2026.

Primary sources