Block VIII · AI on your own machine · Lesson 41
Quantization: how to fit a big model on your graphics card
You'll understand what Q4_K_M, FP8, FP4 or MLX mean and learn to calculate how much video memory you need based on parameters, bits and cache. Also why in MoE models both total and active parameters matter so much.
- 11 min
- 9 animated slides
- 4-question quiz
- Narrated in 6 languages
What you'll see in this lesson
- Quantizing: storing the numbers with less detail
Quantizing means rounding the model's weights so they take less space: from 16 bits per number to 8, to 4 or even less.
- The basic math: parameters × bits ÷ 8
Multiply the parameters by the bits for each one and divide by 8: the result is the bytes the weights take up.
- GGUF and Q4_K_M: how to read the file name
GGUF is the format of llama.cpp, Ollama and LM Studio; the suffix in the name tells you how many bits it uses and how.
- Dynamic quantizations: more bits where it matters
Unsloth doesn't round everything the same: it keeps sensitive layers at more bits and squeezes the tough ones, to lose less quality.
- FP8, NVFP4 and MXFP4: graphics card formats
These are formats the graphics card computes natively; vLLM and SGLang use them, and many models now ship this way.
- MLX: the Mac's own format
On a Mac with an M chip, MLX makes use of unified memory and is often faster than GGUF; LM Studio uses it directly.
- The KV cache: what the conversation uses
Besides the weights, the model stores two vectors for every token it reads; with long contexts that's several gigs.
- MoE: total for memory, active for speed
In a mixture-of-experts model everything has to fit, but each token only reads a part: that's why it's much faster.
- Summary
Do the math before downloading: weights by bits, plus the conversation cache, plus a margin.
Tools and concepts
- GGUF
- Unsloth Dynamic
- NVFP4
- MLX
- KV cache
Sign in with your Google account to access this lesson and the whole course.