ChatPaper.aiChatPaper

PrefixQuant: la quantizzazione statica batte la dinamica attraverso gli outlier prefissati nei LLMs

PrefixQuant: Static Quantization Beats Dynamic through Prefixed Outliers in LLMs

October 7, 2024
Autori: Mengzhao Chen, Yi Liu, Jiahao Wang, Yi Bin, Wenqi Shao, Ping Luo
cs.AI

Abstract

La quantizzazione è essenziale per implementare i Large Language Models (LLM) migliorando l'efficienza della memoria e la velocità di inferenza. I metodi esistenti per la quantizzazione delle attivazioni affrontano principalmente i valori anomali per canale, spesso trascurando i valori anomali per token, il che porta a dipendere dalla costosa quantizzazione dinamica per token. Per affrontare questo problema, presentiamo PrefixQuant, una tecnica innovativa che isola i token anomali offline senza la necessità di un nuovo addestramento. In particolare, PrefixQuant identifica i token anomali ad alta frequenza e li prefissa nella cache KV, impedendo la generazione di token anomali durante l'inferenza e semplificando la quantizzazione. A nostra conoscenza, PrefixQuant è il primo a consentire una quantizzazione statica efficiente per tensore per superare la costosa quantizzazione dinamica per token. Ad esempio, in W4A4KV4 (pesi a 4 bit, attivazioni a 4 bit e cache KV a 4 bit) Llama-3-8B, PrefixQuant con quantizzazione statica per tensore raggiunge una perplessità di 7.43 su WikiText2 e un'accuratezza media del 71.08% su 5 compiti di ragionamento di senso comune, superando i metodi precedenti di quantizzazione dinamica per token come QuaRot con un miglioramento della perplessità di 0.98 e un aumento dell'accuratezza di +5.98 punti. Inoltre, la velocità di inferenza dei modelli quantizzati W4A4 utilizzando PrefixQuant è 1.60x a 2.81x più veloce rispetto ai modelli FP16 e supera i modelli QuaRot di 1.2x a 1.3x. Il nostro codice è disponibile su 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.
PDF332November 16, 2024