2022 의 LLM.int8() 부터 2025 의 SpinQuant 까지 — quantization 의 발전은 "outlier 와 어떻게 협상할 것인가" 의 연속이다. 같은 INT4/FP4 grid 위에 같은 LLM 을 어떻게 다른 trick 으로 박아 넣는가. GPTQ · AWQ · SmoothQuant · QuaRot · SpinQuant · KIVI · Quartet 으로 이어지는 family 를 한 강의에 정리. ScaleML 시리즈의 compression 측면.
GPTQAWQSmoothQuantSpinQuantQuaRotKV quantFP4QAT vs PTQ
LLM 이 BF16 으로 학습된다. 70B 모델 = 140GB. 그런데 inference 할 때는 같은 모델을 INT4 로 깎으면 35GB — A100 한 장에 들어간다. 이게 어떻게 가능한가, 그리고 어디까지 가능한가. 2022 LLM.int8() 부터 2025 SpinQuant 까지 — 강의의 답은 알고리즘의 lineage.
왜 LLM 이 quantize 하기 어려운가 — outlier (large activation) 가 양자화 grid 를 망친다.
각 알고리즘은 outlier 와 어떻게 협상하는가 — GPTQ 는 weight 만 보정, AWQ 는 activation 까지 본 weight 보정, SmoothQuant 는 outlier 를 weight 로 옮김, SpinQuant 는 rotation 으로 흩기.
다음 frontier 는 어디인가 — 2-bit, BitNet, sub-bit. 알고리즘이 따라가야 하는 hardware 도.
강의의 인지적 frame
quantization 의 발전을 한 줄 — "outlier 와의 협상의 형식이 진화". LLM.int8() 은 outlier 만 따로, GPTQ 는 weight 단위로 정밀 보정, SmoothQuant 는 위치 이동, SpinQuant 는 회전으로 흩음. 각자 다른 trade-off.
"quantization 알고리즘의 발전사는 — outlier 라는 single 문제 위에서 다섯 다른 협상 방식의 진화다."강의 §1 재구성
§ 02weight-only vs activation· Two scopes
"무엇을 양자화하는가" 가 trade-off 의 첫 갈림길
quantization 의 첫 분류 — 무엇을 quantize 하는가. weight 만? activation 도? KV cache 도?
scope 1 · weight-only
메모리 절약 위주
weight 만 INT4/FP4. activation 은 BF16 그대로. 메모리 4×, but compute 는 BF16 matmul (또는 dequant 후 matmul). memory bound phase (decoding) 에서 throughput ↑. 대표: GPTQ, AWQ.
scope 2 · weight + activation
속도 + 메모리
weight 도 INT8/INT4, activation 도 INT8. INT × INT matmul 가능 — 진짜 빠른 compute. compute bound phase (prefill) 에서도 wins. 대표: SmoothQuant, INT8 학습/추론.
scope 3 · KV cache
long context 메모리
KV cache 자체를 INT4/INT8. long context 에서 가장 큰 메모리 burden 해결. 대표: KIVI, KVQuant. L072 와 직접 연결.
scope 4 · 학습 자체
native low-bit training
학습 forward / backward 자체에 양자화 적용. FP8 (TransformerEngine), FP4 (Quartet). 대표: L069 Quartet.
왜 weight-only 가 default 인가
LLM inference 의 decoding phase 는 memory-bound. 한 token 생성에 모델 weight 전체를 한 번 read. 이 read 가 가장 큰 비용 — INT4 weight 면 4× 빠르게 read 가능 (HBM bandwidth 절약). compute (matmul) 자체는 BF16 으로 해도 됨. 그래서 weight-only 만으로 큰 throughput 이득.
phase 별 다른 답
prefill (긴 prompt 처리) 은 compute bound. activation 도 quantize 하면 INT × INT matmul 로 더 빠름. decoding (한 token 씩) 은 memory bound. weight-only 로 충분. 한 모델이 두 phase 에서 다른 quantization scheme 을 쓸 수 있다.
"무엇을 quantize 하는가의 답은 phase 마다 다르다 — 하나의 모델이 두 답을 동시에 가질 수 있다."학습 노트 · §2
§ 03GPTQ 알고리즘· Second-order PTQ
"weight 한 column 씩 양자화하면서 뒤를 보정" — Hessian 의 정밀 사용
GPTQ (Frantar & Alistarh, 2022) 는 LLM 의 첫 강력한 PTQ. 핵심 — 한 weight column 을 양자화한 후 그 error 를 다음 column 에 분배. second-order (Hessian) 정보로 어느 column 이 sensitive 한지 가중.
알고리즘의 골격 (단순화).
# GPTQ — weight matrix W 를 column 단위로 quantize
H = X @ Xᵀ # Hessian (calibration data 로)
H_inv = inverse(H + λI)
for i in range(W.shape[1]):
w_i = W[:, i]
# quantize 한 column
q_i = quantize(w_i)
error = w_i - q_i
# 남은 column 들에 error 분배 (Hessian 가중)
W[:, i+1:] += error[:, None] * H_inv[i, i+1:]
핵심 idea — "이 column 을 양자화하면서 생긴 error 를 남은 column 으로 보상하면, 전체 error 가 줄어든다". OBQ (Optimal Brain Quantization) 의 LLM-scale 적용.
GPTQ 의 약속
3-4 bit weight 까지 안정적. 더 낮은 비트는 어려움.
calibration set 만 필요 (~128 samples). 학습 데이터 필요 없음.
single GPU 에서 70B 모델 양자화 가능 — 4시간 정도.
activation 그대로. memory only 이득.
한계
GPTQ 는 activation 의 outlier 를 안 봄. 그래서 activation-quantization 으로 확장하면 깨짐. 또 group size (예: 128) 같은 hyperparameter 의 sensitivity. perplexity 가 group size 에 robust 하지 않음.
§ 04AWQ + SmoothQuant· Activation-aware
"sensitive 한 weight 는 보존, 나머지는 깎는다" — 또는 "outlier 를 weight 로 옮긴다"
GPTQ 가 weight only 의 가장 강력한 형태라면, AWQ (Lin et al., 2023) 와 SmoothQuant (Xiao et al., 2022 — 같은 강의자 family) 는 activation 정보를 quantization 에 가져온다.
AWQ — Activation-aware Weight Q
중요 weight 는 보존
weight 마다 importance 가 다름 — 그 weight 가 곱해지는 activation magnitude 가 큰 weight 가 더 sensitive. 1% salient weight 는 BF16, 나머지는 INT4. 또는 group 단위 scale 로 salient channel 을 양자화 grid 에 잘 fit. weight only, 학습 없이.
SmoothQuant
outlier 를 W 로 이동
activation X 에 outlier 가 있으면, X · diag(s) 와 diag(1/s) · W 로 동등 변환 — outlier 를 weight 로 흡수. activation 이 평탄해져서 INT8 quantize 쉬움. weight + activation 둘 다 INT8 가능.
FIG · SmoothQuant 의 trickX · W = (X · s) · (s⁻¹ · W)
scale s 의 결정이 알고리즘의 핵심. activation 의 max 와 weight 의 max 의 trade-off. X 와 W 가 비슷한 dynamic range가 되도록.
두 알고리즘의 위치
AWQ 와 SmoothQuant 는 동시에 사용 가능 — SmoothQuant 가 activation 평탄화한 후 AWQ 로 weight 보정. "중요한 weight 보존" + "outlier 를 weight 로 이동" 의 합. 실 production engine (TensorRT-LLM, vLLM) 에서 둘 다 지원.
§ 05SpinQuant rotation· Learned rotation
"outlier 를 흩는다" — Hadamard 의 학습된 버전
QuaRot (Ashkboos et al., 2024) → SpinQuant (Liu et al., 2024) 의 lineage. Quartet 에서 학습 시 사용된 same 의 idea — orthogonal rotation 으로 outlier 를 흩어 모든 channel 의 분포를 평탄화.
QuaRot — fixed Hadamard
Hadamard matrix H 는 모든 element ±1 의 직교 행렬. x · H 는 x 의 모든 dimension 을 mix — outlier 가 다른 dimension 에 흩어짐. Hᵀ 의 inverse 는 weight 에 흡수. 결과는 정확히 동일, 양자화는 더 쉬워짐.
SpinQuant — learned rotation
fixed Hadamard 대신 학습된 orthogonal matrix R. 양자화 error 를 minimize 하는 R 을 직접 optimize. Stiefel manifold 위에서 gradient descent. fixed H 보다 일관적으로 더 좋음.
FIG · 4 가지 양자화 family 의 outlier 처리 비교같은 input 다른 trick
방법scopeoutlier 처리학습 필요대표 metric
LLM.int8()W+A INT8분리 (FP16)없음최초
GPTQW INT4Hessian 가중없음정확도 ↑
AWQW INT4salient 보존없음실용
SmoothQuantW+A INT8scale 이동없음속도 ↑
QuaRotW INT4 / W+Afixed Hadamard없음rotation
SpinQuantW INT4 / W+Alearned rotationlightSOTA
Quartet학습 자체 FP4Hadamard + heterogeneousfull학습 시
timeline 의 큰 모양 — 2022 (LLM.int8) → 2023 (GPTQ, AWQ, SmoothQuant) → 2024 (QuaRot) → 2025 (SpinQuant, Quartet). 알고리즘이 점점 정교해지고, 동시에 hardware 도 native FP4 로 따라옴.
§ 06학습 vs 추론 양자화· PTQ · QAT · QAT-aware training
"언제 양자화하는가" — 알고리즘의 두 번째 큰 차원
scope (무엇을) 외에 또 다른 axis — 언제. 학습 후 (PTQ), 학습 중 (QAT), 처음부터 (native low-bit training).
PTQ — Post-Training Quantization
학습 후, calibration 만
학습 끝난 모델을 받아서 calibration set (~128 samples) 으로 양자화. 빠름 (수시간), 학습 데이터 불필요. 대표: GPTQ, AWQ, SpinQuant. 정확도 손실 작음 (4-bit 까지).
QAT — Quant-Aware Training
학습 중 fake quant
학습 forward 에 양자화 노이즈를 주입 (straight-through estimator). 모델이 양자화에 robust 하게 학습. 학습 비용 ↑. 더 낮은 bit (2-3) 에서 PTQ 보다 좋음. 대표: BitNet b1.58.
native low-bit training
처음부터 low-bit
forward 와 backward 자체가 low-bit (FP8, FP4). master weight 은 따로. 대표: TransformerEngine FP8, Quartet FP4. 학습 자체가 빠름.
distillation + quant
teacher → student
큰 BF16 teacher 가 작은 quantized student 를 가르침. recovery 가 가장 좋음. 단, teacher 비용 추가. 4-bit 도 어렵다면 distillation 이 마지막 방어선.
실전 가이드
가장 단순한 path — frontier 모델은 BF16 학습 → GPTQ/AWQ/SpinQuant 로 PTQ 만. 4-bit 까지는 거의 항상 충분. 2-bit 같은 더 깊은 압축이 필요하면 QAT 또는 distillation. 학습 자체를 FP4 로 하는 건 frontier — Blackwell 같은 hardware 와 묶임.
§ 07hardware 가속· Tensor core path
"INT4 weight 을 BF16 activation 과 어떻게 곱하는가" — kernel 의 진짜 question
알고리즘이 INT4 를 약속해도, 실제 GPU 에서 빨라지려면 — INT4 × BF16 또는 INT4 × INT8 matmul 을 tensor core 가 직접 지원해야 함. 그렇지 않으면 dequantize → BF16 matmul 이라는 우회. memory 만 wins, compute 안 wins.
Marlin 은 INT4 weight × FP16 activation 의 fast kernel — vLLM / TensorRT-LLM 의 backend. CUTLASS 위에 layer 된 dequant-fused matmul. weight-only 4-bit 의 production path.
Marlin / Machete / FP6-LLM
같은 weight-only 4-bit kernel 이 여러 구현으로 — 각 backend 가 자기 sweet spot. Marlin 은 vLLM 표준, Machete 는 더 새로운 구현. FP6-LLM 같은 6-bit fast kernel 도 등장 (확인 필요). 각 backend 가 정확도 ↔ 속도 trade-off.
production reality
실제 production 의 quantized inference 는 — 알고리즘 (GPTQ/AWQ) 으로 weight 깎기 → quant config (group size, dtype) 설정 → engine (vLLM, TGI, TensorRT-LLM) 의 kernel 호출. 알고리즘과 kernel 이 모두 production-ready 일 때만 의미.
§ 08정확도 vs 속도· Trade-off frontier
"몇 bit 까지 가도 괜찮은가" — 정량적 답을 본다
실측 결과의 큰 모양. accuracy (perplexity, MMLU 등) vs throughput / memory.
FIG · bit 별 정확도와 속도 (Llama-2 70B 기준 예시)확인 필요
FP16 (baseline)
~0.0 PPL gap
FP8
~0.05
INT8 (SmoothQuant)
~0.10
INT4 (GPTQ g128)
~0.20
INT4 (AWQ)
~0.18
INT4 (SpinQuant)
~0.13
INT3
~0.50
INT2
~1.5+
PPL gap 0.2 까지는 downstream task 에 거의 영향 없음. 4-bit 이 sweet spot — 메모리 4×, 정확도 거의 무손실. 2-bit 은 큰 손실 — QAT 또는 distillation 필요.
throughput 측면
memory bandwidth — INT4 weight 면 BF16 대비 4× 빠른 read. decoding throughput 직접 4× 가까이 향상.
batch size — 같은 GPU 에 4× 더 큰 batch. 처리량 wins.
compute — weight-only 의 경우 기껏 1-2× 향상. activation 도 quantize 하면 4× 가능.
overhead — dequant kernel, scale broadcast 의 비용. 잘 짜진 kernel (Marlin) 에서 거의 무시.
"4-bit 은 LLM 의 sweet spot — 정확도와 속도 의 동시에 양보 거의 없는 영역."학습 노트 · §8
§ 09차세대· 2-bit · sub-bit · BitNet
frontier — "1.58-bit" 가 진짜 가능한가
BitNet b1.58 — Microsoft 의 ternary weight {-1, 0, 1}. log₂3 ≈ 1.58 bit. 처음부터 학습. 같은 size BF16 모델과 비슷한 정확도 보고. processing 의 game changer 가능성.
2-bit PTQ — VPTQ, QuIP#, AQLM 같은 vector-quantization 기반. group 단위로 codebook + index. 성공적으로 4-bit 의 절반.
mixed precision — sensitivity-aware. 일부 layer 는 8-bit, 나머지는 2-bit. 한 모델에 여러 bit 가 섞임.
1-bit — XNOR networks 의 LLM 버전. 아직 frontier research. 정확도 손실이 크지만 hardware 우위 매우 큼.
FP4 native training — Quartet 류. inference 만 quantize 가 아니라 학습 자체를 4-bit. Blackwell 시점.
algorithmic vs hardware
2-bit 알고리즘은 software 로 검증되지만 — 2-bit native tensor core 가 없으면 production 의미 부족. 알고리즘과 hardware 가 함께 가야 함. BitNet 같은 시도는 algorithmic 검증 단계, hardware support 가 따라오기를 기다림.
"4-bit 은 production, 2-bit 은 frontier, 1-bit 은 algorithmic — 알고리즘은 항상 hardware 보다 한 단계 앞서 있다."학습 노트 · §9
§ 10기억할 메모와 코드· Key takeaways
다시 열었을 때 5분 안에 잡혀야 할 것
outlier 협상의 진화
분리 (LLM.int8) → Hessian 가중 (GPTQ) → salient 보존 (AWQ) → scale 이동 (SmoothQuant) → rotation (QuaRot/SpinQuant).
weight-only vs W+A
decoding (memory bound) 은 weight-only 충분, prefill (compute bound) 은 W+A 가 wins.
PTQ default
4-bit 까지는 거의 항상 PTQ (GPTQ/AWQ/SpinQuant) 로 충분. 2-bit 은 QAT 필요.
SmoothQuant trick
X · diag(s) · diag(s⁻¹) · W. outlier 를 weight 로 흡수.
SpinQuant
learned orthogonal rotation. fixed Hadamard 보다 일관적으로 좋음. 현 SOTA.
Marlin kernel
INT4 × FP16 fast matmul. vLLM / TRT-LLM 의 backend. weight-only 4-bit 의 production.
4-bit sweet spot
PPL gap < 0.2, 메모리 4×. 거의 free lunch.
phase 별 다른 답
decoding 은 weight-only, prefill 은 W+A. 한 모델이 두 답을 동시에.