Skip to main content
← Home

Quantization

Making models fit - 6 chapters

From FP16 to INT4: how to compress LLM weights 2-4x with minimal quality loss. Methods, tradeoffs, and practical deployment.

01
The memory wall

Why Quantize?

Quantization stores model weights or activations with fewer bits, which can reduce memory use and sometimes improve throughput. The realized savings and speed depend on metadata, kernels, hardware, and whether the workload is memory- or compute-bound.

A rough weight-only estimate is parameter count × bits per weight ÷ 8, before scales, zero-points, alignment, and runtime buffers. Quantization can make larger batches or longer contexts fit, but KV cache and temporary activations also consume memory. Quality must be measured on the intended tasks; lower precision does not guarantee negligible loss.

The Memory Wall
Memory Required (70B model)
FP16
140 GB
INT8
70 GB
INT4
35 GB
GPU Compatibility
A100 80GB
FP16: 2x
INT8: 1 GPU
INT4: 1 GPU
A100 40GB
FP16: 4x
INT8: 2x
INT4: 1 GPU
RTX 4090 24GB
FP16: 6x
INT8: 3x
INT4: 2x
RTX 3090 24GB
FP16: 6x
INT8: 3x
INT4: 2x
RTX 4080 16GB
FP16: 9x
INT8: 5x
INT4: 3x
Estimated Cost ($/hour per GPU)
A100 80GB
FP16: $4.42/hrINT4: $2.21/hr
A100 40GB
FP16: $4.40/hrINT4: $1.10/hr
RTX 4090 24GB
FP16: $4.44/hrINT4: $1.48/hr
RTX 3090 24GB
FP16: $2.64/hrINT4: $0.88/hr
FP16 Size140 GB
INT4 Size35 GB
Savings75%
1 / 6

forwardpass.dev

An interactive educational project visualizing how LLM inference, training, and deployment work - from raw text to generated response.

Further reading

  • "Attention Is All You Need" - Vaswani et al., 2017
  • "Language Models are Few-Shot Learners" - Brown et al., 2020
  • "The Illustrated Transformer" - Jay Alammar
  • "Neural Networks: Zero to Hero" - Andrej Karpathy

Built with

  • Next.js + TypeScript
  • Framer Motion
  • Tailwind CSS
  • js-tiktoken
Everything runs in your browser - no data is sent to any server.