Quantization, distillation, and the local AI revolution
agent37.club
Quantization makes 7B models fit in 4GB. Distillation transfers frontier reasoning to pocket-sized models. Local inference is fast, private, and nearly free at scale.
Making models smaller without making them dumber
| Precision | Size (7B) | Quality |
|---|---|---|
| FP16 (baseline) | 14 GB | 100% |
| INT8 | ~7 GB | ~99.96% |
| INT4 (Q4_K_M) | ~3.8 GB | ~98.1% |
| 2-bit (Q2_K) | ~2.7 GB | ~85-90% |
| 1.58-bit (BitNet) | ~1.5 GB | Comparable at 2B |
How: Layer-by-layer quantization using the inverse Hessian to understand weight sensitivity. When a weight is quantized, the error is redistributed across remaining weights.
How: Observes activations to find salient weights (<1% of all weights have outsized impact). Scales these up before quantization to protect them.
| Quant | Bits | Size | Sweet Spot |
|---|---|---|---|
| Q2_K | 2 | 2.7 GB | Extreme constraints |
| Q4_K_M | 4 | 3.8 GB | Best default |
| Q5_K_M | 5 | 4.3 GB | Quality-sensitive |
| Q8_0 | 8 | 7.2 GB | Near-lossless |
# That's it. One command. ollama run llama3.2 # Downloads the GGUF, loads it, # starts chatting. Q4_K_M by default. # Works on Mac, Linux, Windows. # Or pick your quant: ollama run llama3.2:8b-q5_K_M # API compatible with OpenAI: curl http://localhost:11434/v1/chat/completions \ -d '{"model":"llama3.2","messages":[...]}'
| Platform | Speedup | Energy Saved |
|---|---|---|
| ARM CPUs | 1.37–5.07× | 55–70% |
| x86 CPUs | 2.37–6.17× | 72–82% |
A 100B parameter BitNet model running on a single CPU at 5–7 tokens/sec (human reading speed). No GPU needed.
Teaching small models to think like big ones
Modern LLM distillation mostly uses approach #2: generate massive reasoning datasets, fine-tune student.
# Modern distillation pipeline # 1. Teacher generates reasoning teacher = DeepSeekR1("671B") for problem in dataset: trace = teacher.generate( problem, show_reasoning=True ) training_data.append({ "input": problem, "output": trace }) # 2. Student learns from traces student = Qwen2_5("7B") student.finetune(training_data) # Result: 7B model with 671B reasoning
| Model | AIME 2024 | MATH-500 |
|---|---|---|
| R1-Distill-Qwen-7B | 55.5% | 92.8% |
| R1-Distill-Qwen-32B | 72.6% | 94.3% |
| OpenAI o1-mini | 63.6% | 90.0% |
A 32B distilled model outperforms OpenAI o1-mini. And it’s open-weight.
Berkeley researchers recreated OpenAI’s reasoning capabilities via distillation for $450 in 19 hours.
| Family | Company | Key Models | Standout |
|---|---|---|---|
| Llama 4 | Meta | Scout (109B MoE), Maverick (400B MoE) | 87.3% MATH-500, 10M context (Scout) |
| Qwen 2.5 | Alibaba | 0.5B to 72B, 18T tokens training | 7B: best overall at 7B class. 72B: #1 OpenCompass |
| Gemma 3 | 1B to 27B, multimodal, 128K context | 27B in top 10 on LMArena including closed models | |
| Mistral/Ministral | Mistral AI | 3B to 24B, vision, 256K context | All Ministral 3 models run on single GPU |
| Phi-4 | Microsoft | 14B, distilled from synthetic data | Beat GPT-4o on MATH. 84.8% MMLU |
The 7B–14B range in 2025 is where 70B was in 2023. Performance doubles every year at the same model size.
“Docker for LLMs.” One command: ollama run llama3.2. OpenAI-compatible API. 100+ models. 108M+ Llama downloads.
Pure C/C++ inference engine. GGUF native. CPU-first, GPU optional. The foundation most local tools are built on. By Georgi Gerganov.
High-throughput serving engine. PagedAttention for 2–24× throughput. Tensor/pipeline parallelism. For production multi-user serving.
Apple’s native framework. 21–87% higher throughput than llama.cpp on M-series. Up to 525 tok/s on M4 Max.
| Chip | BW | 8B Q4 | Can Run |
|---|---|---|---|
| M2 Ultra (192GB) | 800 GB/s | ~75 t/s | 70B quantized |
| M4 Max (128GB) | 546 GB/s | ~100 t/s | 70B quantized |
| M4 Pro (24GB) | 273 GB/s | ~45 t/s | 13B quantized |
Memory bandwidth is the limiting factor, not compute.
| GPU | VRAM | 8B Q4 | Price |
|---|---|---|---|
| RTX 3090 | 24 GB | ~90 t/s | ~$800 |
| RTX 4090 | 24 GB | ~128 t/s | ~$1,800 |
| RTX 5090 | 32 GB | ~213 t/s | ~$2,600 |
Critical rule: Model must fit entirely in VRAM. Partial CPU offload devastates speed.
| Model | Input / 1M tokens | Output / 1M tokens |
|---|---|---|
| GPT-4o | $2.50 | $10.00 |
| Claude Sonnet 4 | $3.00 | $15.00 |
| Claude Haiku | $0.80 | $4.00 |
| GPT-4o mini | $0.15 | $0.60 |
| Gemini 2.0 Flash | $0.10 | $0.40 |
| DeepSeek V3 | $0.27 | $1.10 |
GPT-4-equivalent performance: $0.40/M tokens today vs $20 in late 2022. 50× reduction in 2 years.
Hybrid approach: local for 80% routine tasks, API for 20% complex. Typical savings: 60–70%.
| Volume | Winner |
|---|---|
| <100K tok/day | API (always) |
| 100K–2M tok/day | Depends on quality needs |
| >2M tok/day | Local (decisively) |
At 2M tokens/day: API ~$9,125/yr. RTX 4090 setup: ~$1,400/yr amortized. 84% savings.
LLM inference is memory-bandwidth-bound. Each token reads every weight once but does very few FLOPs per weight. The GPU with more bandwidth wins, not more cores.
RTX 5090: 1,790 GB/s bandwidth (77% more than 4090). That’s why it’s 67% faster despite fewer FLOPS gains.
# Install Ollama brew install ollama # macOS # or: curl -fsSL https://ollama.com/install.sh | sh # Run a model ollama run llama3.2 # 8B, general ollama run deepseek-r1:8b # reasoning ollama run qwen2.5-coder # coding ollama run gemma3:12b # multimodal # Use as API (OpenAI-compatible) curl http://localhost:11434/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model":"llama3.2", "messages":[{"role":"user", "content":"Hello!"}]}'
Ollama + Qwen2.5-7B Q4. Good for coding assistance, writing, chat. ~30–45 tok/s.
Ollama + DeepSeek-R1-Distill-32B Q4. Reasoning on par with o1-mini. ~40 tok/s.
Full 70B models. Production-quality inference for personal/team use. ~20–30 tok/s on 70B.
The future of AI is small, fast, and local.
agent37.club