Lab 10: Quantization Reading Lab
Annotated code reading lab. Running code is optional.
Quantization Reading Lab
This lab maps directly to the handbook section. Read the related handbook section first, then use the lab page and starter file to connect the concept to concrete variables, shapes, APIs, and interview-ready explanations.
Quantization Reading Lab
Separate weight, activation and KV-cache quantization before discussing memory or quality tradeoffs.
Mechanism to keep in mind
- `target` says what tensor is quantized.
- `saved_memory` depends on that target.
- `risk` records where error can affect model behavior.
Starter preview
Excerpt from code/lab-10-quantization-reading/quantization_plan.md. The linked starter file is the source of truth.
A Transformer block turns token ids into vectors, mixes context with attention, applies per-token nonlinear transformations, and uses residual and normalization layers to keep deep training stable.What each block is doing
- Setup / contract
- `target` says what tensor is quantized.
- Main transition
- `saved_memory` depends on that target.
- Interview hook
- `risk` records where error can affect model behavior.
Reading checkpoints
- Kernel support decides whether smaller tensors are faster.
- KV quantization is separate from weight-only quantization.
- Use current docs for supported backends.
What this lab prevents
- Do not report only bit width.
- Do not assume quantization preserves quality in every workload.
How to say it out loud
Separate weight, activation and KV-cache quantization before discussing memory or quality tradeoffs. Then explain the code by naming the state being transformed, the axis or shape that matters, and the tradeoff that would appear in a real system.
Additional intuition
- Use official docs and papers for API behavior and factual claims; use blogs only to improve the mental picture.
- If support matrices, performance behavior or backend choices are version-sensitive, check current docs before repeating them.
- A strong interview answer names the state object, the shape or axis it changes, and the tradeoff it creates.
