The download is the cheap part. A local model takes memory the moment it loads, and the llama.cpp documentation states the constraint plainly: models are currently fully loaded into memory, so the machine needs the disk space to store the file and the RAM to hold it, and the two requirements are the same at the moment. The NVIDIA inference documentation puts the same idea into a formula and adds the parts that come after the weights.
That is enough to turn a shopping decision into arithmetic. Parameters times bits per weight, divided by eight, gives the size of the weights. A second calculation covers the working state that grows with the conversation. Both numbers are checkable on paper before a download starts.
Weight memory from a parameter count
The NVIDIA memory guide gives a heuristic for the largest single consumer:
weight_memory_per_gpu = total_parameters x bytes_per_parameter / TP
Bytes per parameter depends on precision: 2 for BF16 and FP16, 1 for FP8, 0.5 for INT4 and NVFP4. The worked examples are a Llama 3.1 8B model in BF16 at tensor parallelism 1, which comes to 16 GB and fits a 24 GB card with room for cache and overhead, and a Llama 3.3 70B model in BF16 at tensor parallelism 4, which comes to 35 GB per device. NVIDIA NIM memory troubleshooting
The formula matters because it separates the two inputs people usually conflate. A parameter count on its own says nothing about memory. Eight billion parameters at two bytes each is 16 GB. The same eight billion at half a byte each is 4 GB. The precision is doing most of the work.
The same page lists what sits beside the weights at startup: the key and value cache, activations, communication buffers, CUDA graphs, and any LoRA adapters or multimodal reservations. On a device that has just enough room for the weights, one of those other allocations is what fails.
Check the estimate against a published table
The llama.cpp quantizer documentation includes a sizes table for Llama 3.1 that makes the relationship concrete.
| Model | Original size | Quantized size (Q4_K_M) |
|---|---|---|
| 8B | 32.1 GB | 4.9 GB |
| 70B | 280.9 GB | 43.1 GB |
| 405B | 1,625.1 GB | 249.1 GB |
The 8B row checks out against the formula. Eight billion parameters at 4.8944 bits per weight is 39.16 billion bits, or about 4.89 billion bytes, which matches the 4.9 GB decimal figure. The original file sits at four bytes per parameter, 32 GB, consistent with 32.1 GB of unquantized weights plus container overhead. llama.cpp quantize documentation
The same document gives per-quantization entries for that model, including measured generation speed on the machine used for the table.
| Quantization | Bits per weight | Size (GiB) | Generation (tokens/s) |
|---|---|---|---|
| IQ1_S | 2.0042 | 1.87 | 79.73 |
| Q4_K_S | 4.6672 | 4.36 | 76.71 |
| Q4_K_M | 4.8944 | 4.58 | 71.93 |
| Q5_K_M | 5.7036 | 5.33 | 67.23 |
| Q8_0 | 8.5008 | 7.95 | 50.93 |
| F16 | 16.0005 | 14.96 | 29.17 |
Two patterns are worth taking from the table. Size tracks bits per weight almost linearly, which is what the format is for. Generation speed also falls as precision rises, so on that hardware the smaller file is the faster one. Quantization is not only a sacrifice in this data: it buys size and speed, and the documented cost is accuracy, which the documentation says is usually measured with perplexity and KL divergence rather than assumed.
Bits per weight is the number to look for
Model pages advertise a parameter count, which is half the input. The other half is the quantization label, and the label maps to a bits-per-weight figure that is stable enough across models to estimate with. Multiply parameters by bits per weight, divide by eight, and the result lands within a few percent of the file size in decimal gigabytes.
| Label family | Approximate bits per weight | Typical use |
|---|---|---|
| IQ1, IQ2 | 2.0 to 2.9 | smallest file, highest risk of quality loss |
| Q3, IQ3 | 3.2 to 4.3 | very tight memory |
| Q4, IQ4 | 4.4 to 4.9 | the usual default |
| Q5, Q6 | 5.5 to 6.6 | more room for quality |
| Q8 | 8.5 | close to the reference weights, large |
| F16 | 16.0 | reference precision |
The naming matters less than the number. Q4_K_M and IQ4_XS differ by a few tenths of a bit per weight, which is small next to the gap between a 7B model and a 70B model.
The cache is the cost that scales with context
Weights are a fixed cost. The cache is not. The Transformers documentation describes the key and value cache as stored past computations that are reused instead of recomputed, and notes that the default dynamic cache grows as generation proceeds. It also lists the alternatives: a static cache that reserves a high fixed amount, a quantized cache that uses less memory, and sliding-window models whose cache stops growing once the window is full. Hugging Face KV cache guide
The growth is predictable enough to budget. A cache stores one key and one value tensor per layer per token, so bytes per token comes to twice the layer count times the key and value head count times the head dimension times the bytes per element. For a model with 32 layers, 8 key and value heads, a head dimension of 128, and 2-byte elements, that is 131,072 bytes, or 128 KiB per token.
| Context length | Cache for the example layout |
|---|---|
| 4,096 tokens | 0.5 GiB |
| 8,192 tokens | 1.0 GiB |
| 16,384 tokens | 2.0 GiB |
| 32,768 tokens | 4.0 GiB |
The example numbers are for a common arrangement, not for every model. Read the actual layer count, head count and head dimension from the model card before trusting the arithmetic for a particular download, because grouped-query attention with fewer key and value heads changes the result by a large factor.
Build a budget for one machine
A worked example makes the pieces stack up. Take a machine with 16 GB of memory shared between processor and graphics, and a candidate model at Q4_K_M with 4.58 GiB of weights. At an 8,192-token context the cache adds about 1 GiB. Add roughly 1 GB for the runtime, buffers and the operating system's own share, and the total lands near 6.6 GiB. That leaves about 9 GB for applications.
Raise the context to 32,768 tokens and the same weights now carry a 4 GiB cache, so the working total moves to about 9.6 GiB. Nothing about the model changed. The context setting did.
That asymmetry is the part most sizing advice misses. A 4-bit quantization makes the weights roughly 3.3 times smaller than the 16-bit file, while the cache per token does not shrink at all. So the tighter the quantization, the larger the share of the budget that context consumes. On a small machine running a 4-bit model at a long context, the cache can approach the size of the weights, and the decision that matters switches from which quantization to choose to how much text to hold in play.
| Machine memory | Planning budget for weights | Realistic ceiling |
|---|---|---|
| 8 GB | about 3 to 4 GB | small model at Q4 with a short context |
| 16 GB | about 8 to 10 GB | mid-size model at Q5, or a larger one at Q4 with a modest context |
| 32 GB | about 16 to 20 GB | 30B class at Q4 |
| 64 GB | about 32 to 40 GB | 70B at Q4 with a generous context |
Those rows are a planning heuristic derived from the halving rule below, not a measurement of any named device. The halving exists because the operating system, the browser and the desktop compositor are real consumers that no model card accounts for.
Where the estimate still goes wrong
Multimodal models carry a second set of files. The quantizer documentation describes a separate mmproj file holding encoders and projectors, usually much smaller than the language model and normally kept at higher precision such as bf16 or Q8, because the memory and speed impact is negligible while the quality impact is not. A model that reads images needs an extra line in the budget, and that line is not zero on a machine already near its limit.
Mixture-of-experts models confuse the count further: only part of the weights is active per token, and the quantizer exposes flags to prune layers and override expert metadata, which suggests such files get edited for a target machine rather than used as shipped.
Choosing a quantization on purpose
Q4_K_M is the default in the documentation's own examples, and it is a reasonable starting point for a general-purpose assistant on consumer hardware, at roughly a third of the 16-bit footprint. Moving up to Q5 or Q6 buys back accuracy at a size cost that is often affordable. Moving down to 3-bit or 2-bit is a different decision: the files get much smaller and the documentation is explicit that quality loss can be significant, with perplexity and divergence as the measures to watch.
Two flags are worth knowing before writing a custom recipe. --allow-requantize permits quantizing tensors that were already quantized, with a warning that this can severely reduce quality compared with quantizing from 16-bit or 32-bit. --imatrix supplies an importance matrix that the documentation describes as a way to reduce the accuracy loss. That second flag explains why community files carrying the same label vary in quality: an importance matrix built from representative text produces a better 4-bit file than a naive one, and the difference is invisible in the filename.
Verify on the machine, not on the label
Load the candidate at the context length you intend to use, then watch memory pressure and swap rather than the free-memory figure, which counts cache the system will reclaim. Send one long, realistic input instead of a short greeting, since that is when the cache reaches its working size.
Sizing on paper takes a few minutes and eliminates most wrong downloads. The trial on the real machine with the real document is the second filter, and it is the one that decides whether the model fits the job rather than only the memory.



