vLLM 양자화 — FP8 KV 캐시 보정 예제
vLLM 양자화 — FP8 KV 캐시 보정 예제
vLLM의 양자화는 정밀도를 낮춰 메모리 점유를 줄여 더 다양한 디바이스에서 큰 모델을 실행할 수 있게 해요. AutoAWQ, BitsAndBytes, GGUF, INT4 W4A16, INT8 W8A8, FP8 W8A8 외에도 Quantized KV Cache가 포함돼요.
FP8 KV 캐시 보정 예제
llm-compressor의 one-shot 교정으로 Llama의 어텐션과 KV 캐시를 FP8로 양자화할 수 있어요.
from llmcompressor.modifiers.quantization import QuantizationModifier
fp8_args = QuantizationArgs(num_bits=8, type="float", strategy="tensor") # 또는 "attn_head"
recipe = QuantizationModifier(
config_groups={"attention": QuantizationScheme(targets=["LlamaAttention"],
input_activations=fp8_args)},
kv_cache_scheme=fp8_args, # KV 캐시 양자화: k/v_scale
)
oneshot(model=model, dataset=ds, recipe=recipe, max_seq_length=2048, num_calibration_samples=512)
HuggingFaceH4/ultrachat_200k 같은 교정 데이터셋으로 스케일을 계산해 최대 정확도를 얻어요.