4300: Quantization Aware Training (QAT)¶
Module Overview¶
This module covers Quantization Aware Training (QAT), a technique to train models that perform well after quantization. Unlike Post-Training Quantization (PTQ), QAT simulates quantization effects during training, allowing the model to adapt to lower precision.
Why QAT Matters¶
- Better accuracy than PTQ: Models learn to compensate for quantization loss
- Extreme compression: Enable 4-bit, 3-bit, even 2-bit inference
- Production deployment: Run LLMs on consumer hardware
- Edge deployment: Deploy models on mobile/IoT devices
Learning Path¶
Core Concepts (Start Here)¶
- 4301: QAT Foundations - What is QAT, how it works, why it's better than PTQ
- 4302: Fake Quantization - Straight-through estimators, quantization simulation
- 4303: QAT for Transformers - Applying QAT to attention layers, embeddings, activations
Advanced Techniques¶
- 4304: Low-bit QAT - 4-bit, 3-bit, 2-bit training strategies
- 4305: Quantization Configuration - Selecting which layers to quantize, per-channel vs per-tensor
Practical Guides¶
- 4306: PyTorch QAT Guide - QAT with PyTorch native support
- 4307: Transformers QAT Guide - QAT with Hugging Face Transformers
- 4308: BitBlade QAT Guide - Advanced QAT with bitsandbytes
Prerequisites¶
Before starting this module, ensure you understand:
- Quantization basics (from 4100: Low-bit Quantization)
- Transformer architecture (from 3400: Architectures)
- Training fundamentals (from 2400: Pretraining)
- PyTorch autograd (how gradients flow through custom ops)
See PREREQUISITES.md for details.
Assessment¶
Validate your knowledge with:
- 4300: Quantization Aware Training - Quiz - Test your understanding (25 questions, 80% to pass)
- 4300: Quantization Aware Training - Practice - Hands-on exercises
Related Topics¶
- 4100: Low-bit Quantization - PTQ techniques (GGUF, EXL2, AWQ)
- 4200: KV Cache - Quantizing cache for memory efficiency
- 5100: PEFT - Combining QAT with LoRA/QLoRA
- 2300: Framework Engineering - Building QAT into ML frameworks
Key Takeaways¶
After this module, you will be able to:
- ✅ Explain how QAT differs from PTQ
- ✅ Implement fake quantization with STE
- ✅ Apply QAT to transformer models
- ✅ Configure per-layer quantization schemes
- ✅ Train models for 4-bit inference
- ✅ Evaluate quantized model accuracy
- ✅ Debug common QAT issues
Module Duration: 20 hours
Difficulty: ⭐⭐⭐ Advanced