Field Log · Entry
LLM Quantization: GPTQ·AWQ·SmoothQuant·FP8·KV Cache (7/10)
오늘의 결론
- “4-bit model”만으로는 정보가 부족합니다. 어떤 tensor를 어떤 format·granularity로 quantize하고 어느 kernel에서 실행하는지 말해야 합니다.
- Weight-only quantization은 model weight memory를 줄이고, weight-activation quantization은 matrix multiply 경로까지 낮은 precision으로 바꾸며, KV cache quantization은 long-context·동시성 memory를 줄입니다.
- Quantization은
scale,zero point, clipping range, per-tensor·channel·group granularity가 만드는 근사 오차입니다. Metadata와 padding 때문에 실제 byte는parameter × bits/8보다 큽니다.- GPTQ·AWQ·SmoothQuant·LLM.int8·KIVI는 서로 같은 문제의 순위표가 아닙니다. Target tensor와 outlier 처리 방식이 다릅니다.
- 작은 checkpoint가 빠른 checkpoint라는 보장은 없습니다. Hardware가 packed format과 low-precision kernel을 지원하고 target batch·context에서 fallback 없이 실행해야 합니다.
앞 글에서는 frozen base 위에 작은 adapter를 학습했습니다. 이제 model을 실제 GPU memory와 latency budget에 맞춰 배포해야 합니다.
high-precision checkpoint
→ quantization recipe
→ packed artifact + metadata
→ engine kernel
→ target workload benchmark
Quantization은 file conversion이 아니라 수치 근사와 execution path의 공동 설계입니다.
그림 1. Weight, activation, KV cache는 lifetime과 distribution이 다르다. 같은 bit 수라도 quantizer와 kernel이 다르면 memory·속도·품질이 달라진다.
Quantization이 하는 일
연속적인 real value를 제한된 discrete level로 근사합니다.
Affine Quantization
가장 기본적인 식은 다음과 같습니다.
q = clamp(round(x / s) + z, q_min, q_max)
x: 원래 실수q: quantized integers: scalez: zero pointq_min,q_max: bit format의 integer 범위
Dequantization은 다음입니다.
x_hat = s(q − z)
오차는:
e = x − x_hat
Quantizer는 downstream output에 덜 해로운 s, z, clipping을 찾는 문제입니다.
Bit 수와 Level 수
Unsigned b bit는 2^b개 level을 표현합니다.
8 bit → 256 levels
4 bit → 16 levels
2 bit → 4 levels
Signed symmetric range는 implementation에 따라 한쪽 endpoint 사용 방식이 다를 수 있습니다. “INT4”라는 이름만 보고 정확한 code range를 추측하지 않고 format spec을 확인합니다.
Symmetric과 Asymmetric
Symmetric
Zero point를 0으로 두고 양·음 범위를 대칭으로 잡습니다.
z = 0
s ≈ max(|x|) / q_max
장점은 계산이 단순한 점입니다. Distribution이 한쪽으로 치우치면 level을 낭비할 수 있습니다.
Asymmetric
Minimum과 maximum을 모두 사용해 scale과 zero point를 정합니다.
s = (x_max − x_min) / (q_max − q_min)
z ≈ q_min − x_min / s
Zero를 정확히 표현하도록 round와 clamp합니다. Metadata와 kernel이 더 복잡할 수 있습니다.
Clipping Trade-off
최댓값 하나가 매우 크면 scale이 커져 대부분 값의 resolution이 낮아집니다.
values:
many around −1...1
one outlier at 20
Range를 −20...20으로 잡으면 4-bit level 간격이 큽니다. Outlier를 clip하면 outlier error는 커지지만 대다수 값 error는 작아질 수 있습니다.
choose clipping threshold
to minimize:
local reconstruction error
or layer/output/task error
최댓값만 보는 방식과 calibration objective를 사용하는 방식이 다릅니다.
Granularity
Per-tensor
Tensor 전체가 scale 하나를 공유합니다.
metadata small
kernel simple
error can be large
Per-channel
Output channel 또는 input channel별 scale을 사용합니다.
W[d_out, d_in]
scale[d_out] # one possible axis
어느 axis인지 반드시 기록합니다.
Per-group
연속 weight g개가 scale을 공유합니다.
group_size = 128
one scale per 128 weights
Group가 작을수록 local range에 잘 맞지만 metadata와 kernel overhead가 늘어납니다.
Per-token / Per-sequence
Activation이나 KV cache에서 runtime token 단위 scale을 계산할 수 있습니다. Dynamic quantization 비용이 생깁니다.
Memory 계산은 Payload와 Metadata로 나눈다
P개 weight를 b bit로 저장하는 raw payload는:
payload_bytes = P × b / 8
7B parameter의 이상적인 raw payload 예시는:
BF16: 7e9 × 2 bytes ≈ 14 GB
INT8: 7e9 × 1 byte ≈ 7 GB
INT4: 7e9 × 0.5 byte ≈ 3.5 GB
십진 GB 기준의 거친 값입니다.
실제 Artifact
artifact_bytes
= packed_values
+ scales
+ zero_points
+ group metadata
+ tensor headers
+ alignment padding
+ unquantized modules
Group Scale Overhead 예
Group 128개마다 FP16 scale 하나를 저장하면 scale overhead만 weight당:
2 bytes / 128 weights
= 0.015625 bytes per weight
Zero point와 packing metadata가 추가될 수 있습니다.
어떤 Tensor를 Quantize하는가
1. Weight-only
weights: INT4 / INT8
activation: FP16 / BF16
accumulate: implementation-dependent
W4A16, W8A16처럼 표기합니다. 여기서 A16이 FP16인지 BF16인지 별도로 말해야 합니다.
2. Weight + Activation
weights: INT8 or FP8
activation: INT8 or FP8
accumulate: INT32 / FP16 / FP32 etc.
Hardware의 low-precision matrix multiply를 활용할 수 있지만 activation outlier가 어렵습니다.
3. KV Cache
weights: unchanged or separately quantized
KV cache: INT8 / INT4 / lower-bit method
Long context와 concurrency에서 runtime memory를 줄입니다.
4. 그 밖
- Embedding
- LM head
- Norm
- Router
- Logits
- Activation checkpoint
Sensitivity와 kernel 때문에 일부 module을 higher precision으로 남길 수 있습니다.
PTQ와 QAT
Post-training Quantization, PTQ
이미 학습된 checkpoint를 calibration과 변환으로 quantize합니다.
checkpoint
→ calibration
→ quantized artifact
재학습 비용이 낮습니다. GPTQ, AWQ, SmoothQuant는 대표적인 PTQ 계열 접근입니다.
Quantization-aware Training, QAT
Training 중 quantization effect를 simulation하거나 low-precision path를 고려해 weight를 조정합니다.
forward: fake quant / quantized behavior
backward: surrogate gradient recipe
더 많은 training 비용과 data가 필요하지만 낮은 bit에서 품질을 회복할 수 있습니다.
Weight-only LoRA와 혼동하지 않는다
QLoRA는 quantized frozen base 위에서 adapter를 학습하는 PEFT recipe입니다. Base weight quantization artifact 생성과 final serving quantization은 별도 단계입니다.
Calibration Dataset
Quantizer가 activation distribution이나 weight sensitivity를 추정할 때 사용하는 sample입니다.
Cover해야 할 Slice
- 한국어·영어·mixed text
- Code
- 짧은 prompt
- Long retrieved context
- Tool schema와 JSON
- Repeated structured fields
- Multimodal token이 있으면 해당 input
- MoE면 다양한 expert routing
Calibration Manifest
calibration:
dataset_version: quant-cal-v5
sample_count: 1024
token_count: 4194304
sequence_lengths: [512, 2048, 8192]
task_slices:
korean: 0.25
english: 0.20
code: 0.15
rag_long_context: 0.20
tool_json: 0.20
tokenizer_hash: sha256:...
seed: 20260716
Calibration과 Evaluation 분리
Evaluation set을 calibration에 쓰면 quantizer가 test distribution에 맞춰진 leakage가 됩니다.
calibration split ≠ evaluation split
LLM.int8(): Activation Outlier 분리
LLM.int8() 연구는 큰 Transformer에서 systematic outlier feature가 나타나는 문제를 다룹니다.
핵심은 대부분의 matrix multiplication을 8-bit로 처리하되 outlier feature dimension은 higher precision 경로로 분리하는 mixed-precision decomposition입니다.
normal dimensions → INT8 matmul
outlier dimensions → FP16 matmul
combine outputs
논문은 연구한 model 범위에서 최대 175B parameter까지 품질 보존 결과를 보고했습니다. 이것을 모든 architecture와 task에서 “lossless”라고 일반화하지 않습니다.
운영 Trade-off
- Outlier threshold
- Higher-precision fraction
- 두 kernel과 combine overhead
- Model별 outlier distribution
- Library implementation
GPTQ: Approximate Second-order Weight Quantization
GPTQ는 pretrained Transformer의 weight를 one-shot으로 낮은 bit에 quantize하는 PTQ 방법입니다. Approximate second-order information을 사용해 weight quantization error가 layer output에 미치는 영향을 보정합니다.
단순 weight MSE만 최소화하는 대신 calibration activation을 통해 다음 형태의 reconstruction을 고려한다고 이해할 수 있습니다.
minimize ||WX − W_hat X||²
W: original weightW_hat: quantized weightX: calibration activation
실제 algorithm은 weight를 순차적으로 quantize하며 remaining weights를 보정하고 Hessian 관련 근사를 효율적으로 사용합니다.
GPTQ Config
gptq:
bits: 4
group_size: 128
symmetric: true
activation_order: true
damp_percent: 0.01
calibration_hash: sha256:...
implementation_version: x.y.z
필드와 의미는 library마다 다릅니다. 같은 “GPTQ 4-bit”도 다른 artifact입니다.
GPTQ의 평가
- Layer reconstruction error
- Perplexity
- Downstream task
- Packed kernel support
- Conversion time
- Memory
- Target batch throughput
원 논문의 속도·품질 수치는 사용 hardware와 kernel 조건의 결과입니다.
AWQ: Activation-aware Weight Quantization
AWQ는 모든 weight가 똑같이 중요하지 않으며 activation observation으로 salient weight channel을 식별해 보호하는 weight-only PTQ 접근입니다.
핵심 intuition은 다음과 같습니다.
a small fraction of salient weights
can strongly affect output quality
use activation statistics
to choose scaling that protects them
Weight를 무조건 higher precision으로 남기는 방식만이 아니라 per-channel scaling을 통해 quantization error를 줄이는 recipe를 제안합니다.
GPTQ와 AWQ를 한 줄로 비교하면
| 항목 | GPTQ | AWQ |
|---|---|---|
| target | weight-only PTQ | weight-only PTQ |
| signal | approximate second-order/output reconstruction | activation-aware salient weight scaling |
| training backprop | 없음 | 없음 |
| calibration | 필요 | 필요 |
| 결과 | quantized packed weights | quantized packed weights |
| 실제 속도 | kernel/engine 의존 | kernel/engine 의존 |
어느 쪽이 항상 우수하다고 말하지 않고 model·task·engine에서 비교합니다.
SmoothQuant: Activation의 어려움을 Weight로 이동
Activation outlier 때문에 W8A8이 어렵습니다. SmoothQuant는 mathematically equivalent scaling transformation으로 activation quantization 난이도를 weight 쪽으로 이동합니다.
Linear layer Y = XW에 diagonal scale S를 삽입하면 orientation에 따라 다음처럼 표현할 수 있습니다.
Y
= XW
= (X S⁻¹)(S W)
Activation X를 줄이고 weight W 쪽 range를 늘려 두 tensor의 quantization 난이도를 조절합니다.
Smoothing Strength
Activation과 weight range를 얼마나 나눌지 hyperparameter가 필요합니다. 너무 activation 쪽만 보호하면 weight quantization이 어려워질 수 있습니다.
W8A8의 의미
Weight와 activation matrix multiplication을 INT8 path로 만들 수 있어 supported hardware에서 throughput 이점이 가능합니다. 그러나 norm, softmax, residual, logits 등 모든 operation이 INT8이 되는 것은 아닙니다.
SmoothQuant 논문은 여러 LLM에서 W8A8 PTQ와 memory·speed 결과를 보고했습니다. Deployment engine의 exact implementation을 확인합니다.
FP8은 INT8과 다르다
FP8은 8-bit floating-point format입니다. Exponent와 mantissa bit를 가집니다.
대표적으로 논의되는 format은:
E4M3: exponent 4, mantissa 3
E5M2: exponent 5, mantissa 2
세부 encoding과 special value는 spec과 hardware를 확인합니다.
Trade-off
- E4M3: 상대적으로 precision이 높고 range가 좁음
- E5M2: range가 넓고 precision이 낮음
Tensor role에 따라 format을 다르게 사용할 수 있습니다.
Scaling이 여전히 필요하다
FP8도 dynamic range를 효율적으로 쓰기 위한 scaling recipe가 필요합니다.
- per-tensor scale
- delayed scaling
- amax history
- block scaling
- overflow detection
Hardware의 FP8 Tensor Core와 compiler/kernel 지원이 핵심입니다.
FP8 Training과 Inference
FP8은 training matrix multiply와 inference에 모두 쓰일 수 있지만 accumulation, master weights, optimizer state는 더 높은 precision을 사용합니다. “FP8 model”도 어느 tensor와 phase인지 명시합니다.
KV Cache Quantization
KV cache memory 근사는 현대 Decoder 구조 글에서 다음과 같았습니다.
KV_bytes
≈ 2 × layers × tokens × n_kv_heads × head_dim × bytes_per_element
Cache dtype을 BF16 2 byte에서 INT8 1 byte로 낮추면 raw payload는 대략 절반, 4-bit는 대략 1/4이 될 수 있습니다. Scale metadata와 residual high-precision buffer는 별도입니다.
왜 Weight Quantization과 별개인가
- KV는 request마다 runtime에 생성
- Context length에 따라 증가
- Batch/session별 값
- Attention kernel이 매 decode step 읽음
- K와 V distribution이 다를 수 있음
KIVI
KIVI는 tuning-free asymmetric 2-bit KV cache quantization을 연구합니다. 논문은 key cache와 value cache의 distribution을 분석해 key는 channel별, value는 token별 quantization을 사용하는 접근을 제안합니다.
K cache:
per-channel quantization
V cache:
per-token quantization
또한 최근 token을 higher precision residual cache에 유지하고 일정 단위로 quantize하는 구현 전략을 사용합니다.
주의
- 논문의 model·task·context 범위
- Engine kernel availability
- Metadata와 residual buffer
- Long-generation error accumulation
- Attention quality
- GQA/MQA layout
2-bit라는 숫자만 보고 production memory를 계산하지 않습니다.
KV Cache를 무엇으로 평가할까
- Long-context retrieval accuracy
- Position별 evidence use
- Multi-turn consistency
- Long generation coherence
- Repetition
- Attention output error
- Token-level logit drift
- Decode latency
- Max stable concurrency
- Actual allocated memory
짧은 benchmark만 통과해 long-context RAG에 안전하다고 결론 내리지 않습니다.
Quantization Error가 Layer를 거쳐 누적된다
한 layer의 작은 output error가 residual stream을 통해 다음 layer 입력이 됩니다.
h_l_quant = h_l_ref + e_l
h_(l+1)_quant
= f_(l+1)(h_l_ref + e_l) + new_error
Error가 단순히 선형 합산된다고 볼 수는 없지만, local weight reconstruction metric만으로 final behavior를 보장할 수 없는 이유입니다.
Sensitive Module
Model과 task에 따라 다음을 higher precision으로 남길 수 있습니다.
- First/last layer
- LM head
- Embedding
- Attention output
- Router
- Norm
- 특정 outlier channel
Exception list도 model artifact의 일부입니다.
MoE Quantization
MoE는 추가 문제를 만듭니다.
- Expert별 activation distribution
- Calibration에서 드문 expert 미활성
- Router logit precision
- Expert별 scale
- Packed expert kernel
- All-to-all 통신과 dequantization 위치
Calibration routing histogram을 저장합니다.
expert coverage:
min samples per expert
token count per expert
language/task distribution per expert
활성화되지 않은 expert를 통계 없이 quantize했다고 안전하다고 볼 수 없습니다.
Quantized Artifact의 Identity
quantized_model:
source_checkpoint_hash: sha256:...
tokenizer_hash: sha256:...
chat_template_hash: sha256:...
method: awq
target: weights
bits: 4
group_size: 128
symmetric: true
scale_dtype: fp16
packing_layout: engine-layout-v3
excluded_modules: [lm_head]
calibration_manifest: quant-cal-v5
converter_commit: abc123
library_versions:
quantizer: x.y.z
engine: a.b.c
artifact_hash: sha256:...
File extension이나 repository 이름만으로 재현하지 않습니다.
Kernel이 없으면 압축 이점이 사라진다
가능한 경로 A: Fused Low-bit Kernel
packed INT4 weights
→ fused load/dequant/matmul
→ higher-precision accumulation
Memory bandwidth와 compute를 효율적으로 사용할 수 있습니다.
경로 B: Full Dequantize 후 Matmul
packed INT4 weights
→ dequantize full tensor to BF16
→ regular BF16 matmul
Temporary memory와 conversion overhead로 이점이 작아질 수 있습니다.
Silent Fallback
Engine가 unsupported shape나 GPU에서 higher-precision kernel로 fallback할 수 있습니다.
verify:
loaded tensor dtype/layout
selected kernel
fallback count
temporary buffer
profiler trace
Batch와 Context에 따라 속도가 달라진다
Weight-only quantization은 memory bandwidth-bound decode에서 이점이 클 수 있습니다. 큰 batch prefill처럼 compute utilization이 높은 구간에서는 dequantization과 kernel efficiency가 다르게 작동합니다.
Benchmark Grid
workloads:
- prompt: 128
output: 128
concurrency: [1, 16, 64]
- prompt: 4096
output: 256
concurrency: [1, 8, 32]
- prompt: 32768
output: 128
concurrency: [1, 4]
metrics:
- time_to_first_token
- inter_token_latency
- prefill_tokens_per_second
- decode_tokens_per_second
- request_latency_p95
- peak_weight_memory
- peak_kv_memory
- energy_if_available
하나의 batch=1 tokens/s로 production 결론을 내리지 않습니다.
Quality Evaluation
1. Numerical
- Layer output MSE
- Cosine similarity
- Logit error
- KL divergence between output distributions
- Top-k token agreement
2. Language Modeling
- Held-out loss/perplexity
- Language·domain slice
- Long sequence
3. Product Task
- RAG claim support
- Citation accuracy
- Tool name/argument exactness
- JSON validity
- Code tests
- Safety and over-refusal
- Calibration
4. Robustness
- Long context position
- Rare token·Unicode
- Numeric precision
- Repeated structure
- Adversarial prompts
- Multi-turn
Average benchmark가 같아도 structured output의 한 character error가 tool call 전체를 실패시킬 수 있습니다.
Quantization의 Non-uniform Failure
숫자
작은 logit 변화로 digit token 선택이 달라질 수 있습니다.
Code
한 token syntax error가 compile 실패가 됩니다.
Tool JSON
Quote, bracket, enum 하나가 schema를 깨뜨립니다.
한국어
Tokenizer와 calibration coverage가 부족하면 영어 평균에 가릴 수 있습니다.
Long Context
KV error와 position별 attention이 결합됩니다.
그래서 slice별 quality floor를 둡니다.
Perplexity 차이를 과신하지 않는다
FP16 PPL: 6.21
INT4 PPL: 6.25
평균 차이가 작아도 high-risk task나 tool schema에서 실패가 늘 수 있습니다. 반대로 PPL 차이가 조금 있어도 product task가 유지될 수 있습니다.
PPL은 중요한 smoke metric이지만 release metric 전체는 아닙니다.
Quantization과 Sampling
Greedy decoding에서는 작은 logit 순위 변화가 token을 바로 바꿉니다. Sampling에서는 random seed와 distribution 차이가 결합됩니다.
비교 방법
- Teacher-forced logit comparison
- Greedy deterministic generation
- Fixed random number stream when supported
- Many-sample task distribution
- Sequence-level judge
생성 text 하나가 다르다고 실패로 보거나, 비슷하다고 parity로 보지 않습니다.
Quantization과 Adapter Merge
LoRA 글의 권장 흐름을 다시 연결합니다.
higher-precision base
+ adapter delta
→ merged model
→ calibration
→ serving quantization
→ full evaluation
순서를 고정해야 하는 이유
Adapter를 merge하면 weight distribution이 바뀝니다. Base만 calibration한 quantization scale이 merged model에 최적이라는 보장이 없습니다.
Dynamic Adapter + Quantized Base
Engine가 지원하면 quantized base와 higher-precision adapter branch를 함께 실행할 수 있습니다. Kernel, scale, batching, merge parity는 별도 평가합니다.
Quantization과 Safety
Safety behavior는 decision boundary에 민감할 수 있습니다.
small logit shift
→ refuse vs comply token changes
평가:
- Harmful compliance
- Benign over-refusal
- Authorization
- Prompt injection
- Sensitive data leakage
- Abstention calibration
Quantized model을 “같은 model의 작은 파일”로만 취급하지 않습니다.
Quantized Artifact Security
Serialization
- Executable deserialization 피하기
- Tensor shape·dtype validation
- Hash/signature
- Size limit
- Unknown metadata reject
Converter Supply Chain
- Quantizer code version
- Container digest
- Dependency lock
- Calibration data access
- Reproducible artifact hash where possible
Runtime
- Unsupported kernel fallback alert
- NaN/Inf logit monitoring
- Corrupted scale detection
- Canary
- Original checkpoint rollback
선택 순서
목표 1. Weight Memory 감소
먼저 weight-only INT8 또는 4-bit GPTQ/AWQ를 비교합니다.
목표 2. Matrix Throughput
Hardware가 지원하면 SmoothQuant W8A8, FP8 등 weight-activation path를 검토합니다.
목표 3. Long-context Concurrency
GQA와 함께 KV cache INT8/INT4 또는 KIVI류를 검토합니다.
목표 4. Fine-tuning Memory
QLoRA를 검토하되 final serving format과 분리합니다.
같은 “memory 부족”도 어떤 state가 병목인지에 따라 해법이 다릅니다.
Baseline Matrix
| Candidate | Weight | Activation | KV | 목적 |
|---|---|---|---|---|
| B0 | BF16 | BF16 | BF16 | reference |
| B1 | INT8 weight-only | BF16 | BF16 | low-risk compression |
| B2 | GPTQ/AWQ INT4 | BF16 | BF16 | weight memory |
| B3 | SmoothQuant W8A8 | INT8 | BF16 | throughput |
| B4 | candidate B2 | BF16 | INT8 | long-context memory |
| B5 | candidate B2 | BF16 | lower-bit KV | aggressive test |
한 번에 weight·activation·KV를 모두 바꾸면 regression 원인을 찾기 어렵습니다.
Quantization Experiment Manifest
experiment_id: quant-rag-agent-v8
reference:
checkpoint_hash: sha256:...
dtype: bfloat16
candidates:
- id: awq-w4a16-g128
method: awq
weight_bits: 4
activation_dtype: bfloat16
group_size: 128
symmetric: true
excluded_modules: [lm_head]
calibration_manifest: quant-cal-v5
artifact_hash: sha256:...
- id: smoothquant-w8a8
method: smoothquant
weight_bits: 8
activation_bits: 8
smoothing_alpha: 0.5
calibration_manifest: quant-cal-v5
runtime:
hardware: example-gpu
driver: x.y
engine: serving-v6
kernels: kernel-bundle-v4
evaluation:
suite: rag-agent-quant-v7
workload_trace: prod-trace-redacted-v3
값은 예시입니다. Method별 parameter 의미는 implementation 문서에 맞춥니다.
흔한 오해와 처방
1. 4-bit면 Memory가 정확히 1/4이다
Scale, zero point, group metadata, unquantized module, padding이 있습니다.
처방: File 크기, loaded weight memory, runtime peak를 모두 측정합니다.
2. GPTQ와 AWQ는 Bit Format 이름이다
Calibration과 weight quantization algorithm family입니다.
처방: Bit, group, symmetry, layout, implementation을 함께 기록합니다.
3. Weight-only 4-bit면 Activation도 4-bit다
Activation은 BF16/FP16일 수 있습니다.
처방: W4A16처럼 tensor별 dtype과 accumulation을 명시합니다.
4. SmoothQuant는 Weight만 Quantize한다
Activation outlier 문제를 smoothing해 W8A8을 가능하게 하는 접근입니다.
처방: Transformation, smoothing strength, actual INT8 kernel을 확인합니다.
5. FP8은 INT8의 다른 이름이다
Exponent와 mantissa가 있는 floating format입니다.
처방: E4M3/E5M2, scale, accumulation, hardware path를 기록합니다.
6. KV Cache Quantization은 Weight Artifact에 포함된다
Runtime request cache의 별도 policy일 수 있습니다.
처방: Engine config, residual cache, scale layout, context benchmark를 분리합니다.
7. 작은 File이면 빠르다
지원 kernel이 없으면 dequantization과 fallback으로 느릴 수 있습니다.
처방: Profiler에서 selected kernel과 fallback을 확인합니다.
8. Perplexity가 비슷하면 Production Parity다
Tool JSON, 숫자, safety, long context failure가 평균에 가릴 수 있습니다.
처방: Product slice floor와 latency·memory gate를 함께 적용합니다.
Production 체크리스트
- Weight, activation, KV 중 quantize할 tensor를 구분했다.
- Bit format, signedness, scale, zero point를 기록한다.
- Per-tensor·channel·group granularity와 axis를 기록한다.
- Clipping objective와 outlier policy가 있다.
- Raw payload와 metadata·unquantized module memory를 분리 계산한다.
- Calibration dataset에 language·code·tool·long-context slice가 있다.
- Calibration과 locked evaluation data를 분리한다.
- GPTQ/AWQ method와 exact implementation version을 기록한다.
- SmoothQuant transformation과 smoothing strength를 기록한다.
- FP8 format·scale·accumulation·hardware를 명시한다.
- KV cache quantization을 weight quantization과 별도 실험한다.
- GQA head layout과 KV scale axis가 engine에 호환된다.
- MoE calibration에서 모든 expert coverage를 확인한다.
- Packed layout을 native로 실행하는 kernel이 있다.
- Silent higher-precision fallback을 profile한다.
- Target batch·context·concurrency에서 TTFT·ITL·throughput을 측정한다.
- Perplexity와 task·grounding·tool·safety를 모두 평가한다.
- Long-context와 long-generation regression을 평가한다.
- Adapter merge 후 새 calibration과 quantization을 수행한다.
- Quantized artifact hash와 original checkpoint rollback이 있다.
스스로 확인하기
- Affine quantization의
scale과zero point는 각각 무엇을 결정하는가? - Per-group quantization에서 group을 작게 하면 어떤 trade-off가 생기는가?
- Weight-only
W4A16과 W8A8은 어떤 tensor의 dtype이 다른가? - GPTQ와 AWQ가 calibration activation을 사용하는 목적은 어떻게 다른가?
- SmoothQuant가 activation outlier 문제를 weight 쪽으로 이동시키는 식을 설명할 수 있는가?
- KV cache quantization을 weight quantization과 별도로 평가해야 하는 이유는 무엇인가?
- Quantized file이 작아도 inference가 빨라지지 않을 수 있는 이유는 무엇인가?
앞 글에서 parameter-efficient training을, 이 글에서 low-precision deployment를 연결했습니다. 다음 글은 분산 LLM 학습: DDP·FSDP·ZeRO·TP·PP입니다. Weight·gradient·optimizer·activation 중 무엇이 memory를 차지하는지부터 data, tensor, pipeline, sequence/context parallel을 조합하는 법을 다룹니다.
참고자료
- LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
- GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers
- SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models
- AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration
- FP8 Formats for Deep Learning
- KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache