작은 정확도 budget 을 거대 size 와 속도 win 으로 trade
modern hardware 가 int8 matmul 에 fp32 보다 훨씬 빠름 — 가끔 4x. 메모리 소비도 비례 drop. 비용: 작은 정확도 hit, 보통 well-quantized model 의 표준 benchmark 위 <1%. LLM 위 int4 weight-only quant (2025-2026 가장 활발한 영역 중 하나) 가 7B-param model 을 4GB 에 fit.
quantization 세 맛
- Dynamic quantization — weight int8 저장, activation 은 inference 중 on-the-fly quantize. 한 줄 setup. Linear layer 지배 transformer-shaped model 에 best.
- Static (post-training) quantization (PTQ) — weight 와 activation 둘 다 quantize, 작은 dataset 에 calibrate. dynamic 보다 빠르지만 setup 더.
- Quantization-Aware Training (QAT) — forward pass 에 simulated quantization 으로 train. 가장 정확하지만 setup 가장 느림.
torchao — modern API
역사적 torch.quantization / torch.ao.quantization module 이 standalone torchao 패키지로 이동 중. torchao 가 modern int8 / int4 / weight-only / GPTQ / AWQ 기법 사는 곳. 새 project 엔 거기 시작.
quantization 이 도움 / 해 되는 곳
- 도움: 큰 transformer FFN, 큰 embedding table, LLM serving.
- 해: per-op overhead 가 지배하는 작은 model, non-Linear op 많은 model (unquantized 부분이 bottleneck 됨).