Topic 1 of 6 · 4 min read
How quantization shrinks memory needs
Goal: Calculate the weight memory of a model at 16, 8 and 4 bits per weight.
Quantization stores each model weight in fewer bits, so the file and the memory it needs shrink in direct proportion.
Check yourself · 1 of 3
Roughly how much memory do the weights of a 14B-parameter model need at 8 bits per weight?
Why it matters
A model's weights must sit in fast memory (GPU VRAM, or unified memory on a Mac) while it runs. A 70-billion-parameter model at 16 bits does not fit on a 24 GB card, but the same model at 4 bits can be split between that card and system RAM. Quantization is usually the difference between "cannot run it" and "runs on my machine".
The arithmetic
Weight memory is parameters times bytes per weight. Open-weight models are normally released in 16-bit form (BF16 or FP16), which is 2 bytes per weight.
memory (GB) ~= parameters (billions) x bits per weight / 8
8B model at 16 bit: 8 x 16 / 8 = 16 GB
8B model at 8 bit: 8 x 8 / 8 = 8 GB
8B model at 4 bit: 8 x 4 / 8 = 4 GB
70B model at 16 bit: 70 x 16 / 8 = 140 GB
70B model at 4 bit: 70 x 4 / 8 = 35 GB
This is a floor, not the whole bill. Real 4-bit formats store extra scale values per block of weights, so a "4-bit" file is closer to 4.5 bits per weight. You also need room for the KV cache (which grows with context length), activations and the runtime. Plan for the weights plus roughly 10 to 20 percent, more at long context.
Why it is often faster too
Generating one token means reading nearly every weight from memory once. On most consumer hardware, speed is limited by memory bandwidth, not arithmetic. Fewer bytes to read means more tokens per second. A 4-bit model often generates noticeably faster than the 16-bit one on the same card, if both fit. Prompt processing (prefill) is compute-bound, so it gains less.
What is being quantized
Usually only the weights. Activations and the KV cache can stay at 16 bits, and the KV cache can be quantized separately in some runners. Some layers, such as embeddings and the output layer, are often kept at a higher precision because they are more sensitive.
Before and after
Before: "My 12 GB GPU cannot load a 14B model, so I need a bigger GPU." At 16 bits the weights are 28 GB, which is true. After: at 4 bits the weights are about 7 GB, about 8 GB with block scales, and with a few GB for cache the model fits in 12 GB.
What goes wrong
- Counting only the weights. A model that "should" fit at 10 GB fails to load because a 32k context needs several GB of KV cache.
- Assuming linear quality. Memory falls in a straight line with bits, but quality does not. Going from 16 to 8 bits is nearly free; going below 4 bits starts to hurt.
- Expecting speed gains when the model spills into system RAM. Once layers run on the CPU, the slowest memory sets the pace.
Examples
Will a 32B model fit in 24 GB?
At 4 bits the weights are about 16 GB, roughly 18 GB with block scales. That leaves around 6 GB for the cache and runtime, so it fits at a moderate context. At 8 bits the weights alone are 32 GB, so it does not.
Estimating from a file
A repository lists a 4-bit file of 4.9 GB for an 8B model. 4.9 x 8 / 8 billion weights is about 4.9 bits per weight. That is higher than 4 because of scales and a few layers kept at higher precision.
Key points
- Weight memory is parameters times bits per weight divided by 8, in gigabytes for billions of parameters.
- Halving the bits halves the weight memory: a 70B model needs about 140 GB at 16 bits and about 35 GB at 4 bits.
- Real files are larger than the floor because block scales add roughly half a bit per weight.
- The KV cache and runtime need memory on top of the weights, and the cache grows with context length.
- Decoding is mostly memory-bandwidth bound, so fewer bytes per weight usually means more tokens per second.
Common mistakes
- Treating the file size as the total memory needed and forgetting the KV cache.
- Assuming a 4-bit model is four times smaller than an 8-bit one; it is half the size.
- Expecting the same quality loss at every bit width.
Check yourself · 2 of 3
A 4-bit quantized model is often faster than the 16-bit one on the same GPU. What is the main reason?
Check yourself · 3 of 3
A 4-bit 8B model file is 4.9 GB. Why is that more than the 4 GB the simple formula gives?
Practice items, not counted towards your mastery.
Start here
- Quantization overview (Hugging Face Transformers docs) (opens in a new tab)DocsFree
Hugging Face's comparison of quantization methods (GPTQ, AWQ, bitsandbytes and others) and what each supports.
- llama.cpp quantize tool (opens in a new tab)DocsFree
The official list of quant types, the importance-matrix option and the llama-quantize command line.
- GGUF on the Hugging Face Hub (opens in a new tab)DocsFree
What the GGUF file format holds and how the Hub shows quant types for a repository.
More for this topic
- A visual guide to quantization (opens in a new tab)ArticleFree
Illustrated walk-through of how weights are mapped to fewer bits and what outliers do to the result.
- llama.cpp discussion: quantization types and perplexity (opens in a new tab)ArticleFree
Maintainers' tables of size and perplexity for each quant type, the evidence behind common level choices.