Part V · Putting it together
Ch 13. Fewer bits per number
How big is one number?
GPT-2 small has about 124 million weights, and its files store each one in 4 bytes: about 500 MB in all.[1] The same rule works for any model:
memory for the weights ≈ number of weights × bits per weight ÷ 8 bytes
GPT-2 small has 124,439,808 weights. Its published files store each one as a 32-bit floating-point number: 4 bytes (Ch 3), enough for about seven significant digits.[1][1] That comes to about 498 MB. The same rule works for any model:
memory for the weights ≈ number of weights × bits per weight ÷ 8 bytes
At 16 bits, GPT-2 small needs about 249 MB. The largest Llama 3 model from Ch 12, with 405 billion weights, needs about 810 GB at 16 bits and about 203 GB at 4 bits. A smaller model is also quicker to load and to read from memory.
Does a weight need that much detail? Rounding each number to one of a few allowed values is called quantizationquantization: Storing a model’s numbers with fewer bits each, by rounding them to a small set of allowed values, so the model takes less memory. Ch 13. With 8 bits a number can take 256 values; with 4 bits, only 16. Slide GPT-2 small down from 32 bits and watch what it predicts after “The cat sat on the”:
Does a weight need seven digits? Storing numbers with fewer bits, by rounding each one to a small set of allowed values, is called quantizationquantization: Storing a model’s numbers with fewer bits each, by rounding them to a small set of allowed values, so the model takes less memory. Ch 13. With 8 bits a number can take 256 different values; with 4 bits, 16; with 2 bits, only 4. To make those few values count, each block of 32 weights shares one scale, set by its largest number, and each weight is stored as a small whole number times that scale. File formats for sharing models, like GGUF’s Q4_0 and Q8_0, work this way.[2][2] Slide GPT-2 small down from 32 bits and watch what it predicts after “The cat sat on the”:
At 16 and 8 bits nothing visible changes. At 6 and 5 bits the guesses drift, but stay sensible. At 4 bits and below, the model falls apart and writes gibberish.
At 16 and 8 bits nothing visible changes: the same top guess, ” floor”, the same next twelve tokens, and almost the same loss (Ch 7) on a test passage. At 6 and 5 bits the guesses drift: ” bed”, then ” table”, still sensible. At 4 bits and below the model falls apart, repeating “The stack.” or writing gibberish, and its loss shoots up. Look at the dots: as the bits run out, each weight snaps to a coarser grid, and the small weights in a block with one large weight are rounded hardest.
Block rounding, written down
For a block of 32 weights whose largest size is , -bit rounding works like this:
where is the block’s scale (stored once), is the small whole number stored for weight , and is the value the model uses. Each weight moves by at most . In the block the widget shows, , so at 4 bits the step is about 0.098, and every weight smaller than 0.049 becomes exactly 0. That’s why the small weights suffer most.
The scale costs 16 bits per block, half a bit per weight, so “4-bit” really means about 4.5 bits per weight: GPT-2 small at 4 bits takes 70 MB, not 62. GGUF’s Q4_0 stores exactly this, 4-bit numbers plus one 16-bit scale per 32.[2]
You have been using a quantized model all along. The live GPT-2 on this site runs with 8-bit weights, a 128 MB download instead of about 500 MB. It was rounded by a different method than the demo’s, and its percentages differ from the recorded ones: it gives ” floor” 15.4% instead of 7.6%.
Rounding with care
This demo rounds in the plainest way. Better methods keep more quality with fewer bits. One lets
the model practice with the rounding during training, called quantization-aware trainingquantization-aware training (QAT): Training a model with the rounding of quantization already in place, so it learns weights that still work after rounding. Ch 13 (QAT). Google’s Gemma 4 QAT models use 4-bit weights, and their model card describes their quality
as similar to the 16-bit originals.[2] That is what the qat in a model name
means.
This demo uses the plainest method, rounding to the nearest allowed value. Better methods keep more
quality at fewer bits. Large transformers have a few unusually large numbers that plain rounding
handles badly; treating them separately lets 8-bit versions match 16-bit ones even at 175 billion
weights.[3][3] Another way is to let the model learn to cope with the rounding.
With quantization-aware trainingquantization-aware training (QAT): Training a model with the rounding of quantization already in place, so it learns weights that still work after rounding. Ch 13 (QAT), the weights are rounded during training too, so training nudges them (Ch 7) toward values that
still work after rounding.[4][4] Google’s Gemma 4 models come in QAT versions with
4-bit weights, and their model card describes their quality as similar to the 16-bit
originals.[5][5] That is what the qat in a model name means.
In QAT, the forward pass uses the rounded weights , so the loss includes the rounding error, while backpropagation treats rounding as if it weren’t there and updates the full-precision weights . Rounding has a slope of 0 almost everywhere, so without that shortcut no weight would ever move.[4] The outlier method instead finds the few feature dimensions with very large values and multiplies them in 16 bits, and everything else in 8.[3]
A small model like GPT-2 has less to spare than a big one, and this demo rounds everything, including the token table. So read the 4-bit result as “plain rounding has limits”, not “4 bits is too few”.
Recipe card
Recap
- Memory for the weights is about the number of weights × bits per weight ÷ 8 bytes.
- Quantization rounds each weight to one of a few allowed values, shared in blocks with one scale.
- GPT-2 small is unchanged at 8 bits, drifts at 6 and 5, and breaks at 4 with plain rounding.
- Better methods, like quantization-aware training, keep quality at 4 bits.
- A block’s scale is and each weight stores : about 4.5 bits per weight at 4 bits.
Next question: smaller numbers make a model cheaper to store and read. Could it also write faster, without changing a single word?
Sources
- OpenAI and Hugging Face (2019). GPT-2 model card (openai-community/gpt2). Hugging Face. Accessed October 23, 2026.
- Google DeepMind (2026). Gemma 4 QAT model card (google/gemma-4-E2B-it-qat-mobile-transformers). Hugging Face. Accessed October 23, 2026.
Sources
- OpenAI and Hugging Face (2019). GPT-2 model card (openai-community/gpt2). Hugging Face. Accessed October 23, 2026.
- Hugging Face (2026). GGUF: quantization types. Hugging Face Hub documentation. Accessed October 23, 2026.
- Tim Dettmers et al. (2022). LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale. NeurIPS.
- Benoit Jacob et al. (2018). Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference. CVPR.
- Google DeepMind (2026). Gemma 4 QAT model card (google/gemma-4-E2B-it-qat-mobile-transformers). Hugging Face. Accessed October 23, 2026.
Sources
- OpenAI and Hugging Face (2019). GPT-2 model card (openai-community/gpt2). Hugging Face. Accessed October 23, 2026.
- Hugging Face (2026). GGUF: quantization types. Hugging Face Hub documentation. Accessed October 23, 2026.
- Tim Dettmers et al. (2022). LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale. NeurIPS.
- Benoit Jacob et al. (2018). Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference. CVPR.
- Google DeepMind (2026). Gemma 4 QAT model card (google/gemma-4-E2B-it-qat-mobile-transformers). Hugging Face. Accessed October 23, 2026.