PrefixQuant: 정적 양자화가 LLMs에서 동적 양자화를 앞서는 이유: 접두사 이상치
PrefixQuant: Static Quantization Beats Dynamic through Prefixed Outliers in LLMs
October 7, 2024
저자: Mengzhao Chen, Yi Liu, Jiahao Wang, Yi Bin, Wenqi Shao, Ping Luo
cs.AI
초록
양자화는 대규모 언어 모델 (LLM)을 배포하기 위해 기억 효율성과 추론 속도를 향상시키는 데 필수적입니다. 활성화 양자화에 대한 기존 방법은 주로 채널별 이상치에 대응하며 종종 토큰별 이상치를 무시하여 토큰별 동적 양자화에 대한 비용이 증가하게 됩니다. 이를 해결하기 위해 우리는 PrefixQuant라는 새로운 기술을 소개합니다. 이 기술은 이상치 토큰을 재훈련 없이 오프라인에서 분리하는 기술입니다. 구체적으로, PrefixQuant는 높은 빈도의 이상치 토큰을 식별하고 KV 캐시에 접두어를 붙여 추론 중에 이상치 토큰의 생성을 방지하고 양자화를 간소화합니다. 우리의 지식으로는, PrefixQuant는 비싼 토큰별 동적 양자화를 능가하는 효율적인 텐서별 정적 양자화를 가능하게 하는 최초의 기술입니다. 예를 들어, W4A4KV4 (4비트 가중치, 4비트 활성화 및 4비트 KV 캐시) Llama-3-8B에서 PrefixQuant를 사용한 텐서별 정적 양자화는 5가지 상식 추론 작업에서 7.43의 WikiText2 난해도와 71.08%의 평균 정확도를 달성하여 QuaRot과 같은 이전의 토큰별 동적 양자화 방법을 능가합니다. 또한, PrefixQuant를 사용하여 W4A4 양자화된 모델의 추론 속도는 FP16 모델보다 1.60배에서 2.81배 빠르며 QuaRot 모델보다 1.2배에서 1.3배 빠릅니다. 우리의 코드는 https://github.com/ChenMnZ/PrefixQuant에서 확인할 수 있습니다.
English
Quantization is essential for deploying Large Language Models (LLMs) by
enhancing memory efficiency and inference speed. Existing methods for
activation quantization mainly address channel-wise outliers, often neglecting
token-wise outliers, leading to reliance on costly per-token dynamic
quantization. To address this, we introduce PrefixQuant, a novel technique that
isolates outlier tokens offline without re-training. Specifically, PrefixQuant
identifies high-frequency outlier tokens and prefixes them in the KV cache,
preventing the generation of outlier tokens during inference and simplifying
quantization. To our knowledge, PrefixQuant is the first to enable efficient
per-tensor static quantization to outperform expensive per-token dynamic
quantization. For instance, in W4A4KV4 (4- bit weight, 4-bit activation, and
4-bit KV cache) Llama-3-8B, PrefixQuant with per-tensor static quantization
achieves a 7.43 WikiText2 perplexity and 71.08% average accuracy on 5
common-sense reasoning tasks, outperforming previous per-token dynamic
quantization methods like QuaRot with 0.98 perplexity improvement and +5.98
points accuracy. Additionally, the inference speed of W4A4 quantized models
using PrefixQuant is 1.60x to 2.81x faster than FP16 models and exceeds QuaRot
models by 1.2x to 1.3x. Our code is available at
https://github.com/ChenMnZ/PrefixQuant.Summary
AI-Generated Summary