Quantization 道练习题
22 道题 · 0 已解决
Quantization 使用更少的比特数(例如 int8 或 int4 而不是 float32)来存储模型权重和 activations。这可以减少内存占用并加速 inference,也是大模型能在较小的 GPU 和笔记本电脑上运行的关键。这就像是用更少的颜色保存照片:如果做得好,你几乎察觉不到区别。其中的技巧在于选择合适的 scales 以使误差保持在较小范围内。在这些题目中,你将完成:将 activations 通过 scale 和 zero point 量化为 uint8;将 weights 量化为 int8 并测量误差;对比 per-channel 和 per-tensor 方案;从 bytes 中 unpack int4 权重;将 float32 round 到 bfloat16;应用 group-wise int4 quantization;在 rounding 前搜索 activation-aware scale;使用 SmoothQuant 迁移 activation outliers;以 GPTQ 风格结合 error feedback 量化 weight row;以及构建带有 double-quantized scales 的 block-wise 4-bit codebook quantization。建议从关于 scales、zero points 和 per-channel error 的 Easy 题目开始。然后练习 bfloat16、group-wise int4 和 SmoothQuant,最后完成 GPTQ 和 codebook quantization。部署 LLM 的团队依赖 quantization 来降低成本,面试官也经常会问及它如何影响 accuracy 和速度。
简单 5
中等 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
困难 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