Quantization practice problems
22 problems · 0 solved
Quantization stores model weights and activations with fewer bits, such as int8 or int4 instead of float32. This shrinks memory and speeds up inference, which is how large models run on smaller GPUs and laptops. It is like saving a photo with fewer colours: done well, you hardly notice the difference. The trick is choosing scales so the error stays small. In these problems you will quantize activations to uint8 with a scale and zero point, quantize weights to int8 and measure the error, compare per-channel and per-tensor schemes, unpack int4 weights from bytes, round float32 to bfloat16, apply group-wise int4 quantization, search for an activation-aware scale before rounding, migrate activation outliers with SmoothQuant, quantize a weight row GPTQ-style with error feedback, and build block-wise 4-bit codebook quantization with double-quantized scales. Start with the Easy problems on scales, zero points and per-channel error. Then do bfloat16, group-wise int4 and SmoothQuant, and finish with GPTQ and codebook quantization. Teams deploying LLMs depend on quantization to cut cost, and interviewers often ask how it affects accuracy and speed.
Easy 5
Medium 11
- Quantize weights to int8 and measure the errorPro
- Group-wise int4 quantization like GPTQ and AWQ checkpointsPro
- Search for an activation-aware per-channel scale before int4 roundingPro
- Round float32 to bfloat16Pro
- Migrate activation outliers with SmoothQuant scalesPro
- Multiply int8 activations by int8 weights and dequantizePro
- Quantize a KV cache to int8 per token and headPro
- Backpropagate through fake quantization with a learned scalePro
- Search the clipping range that minimizes quantization errorPro
- Run a matrix-vector product on packed 4-bit weights with zero pointsPro
- Requantize an int32 accumulator with a fixed-point multiplierPro
Hard 6
- Block-wise 4-bit codebook quantization with double-quantized scalesPro
- Quantise a weight row GPTQ-style with error feedbackPro
- Quantize weights to 4-bit groups while keeping salient columns in floatPro
- Split outlier features into a float matmul and the rest into int8Pro
- Round float values to the FP8 E4M3 formatPro
- Rotate activations with a Hadamard matrix before 4-bit quantizationPro