NQKV: A KV Cache Quantization Scheme Based on Normal Distribution Characteristics

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Cai, Zhihang, Zhang, Xingjun, Tan, Zhendong, Wei, Zheng
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866912386917597184
author Cai, Zhihang
Zhang, Xingjun
Tan, Zhendong
Wei, Zheng
author_facet Cai, Zhihang
Zhang, Xingjun
Tan, Zhendong
Wei, Zheng
contents Large Language Models (LLMs) have demonstrated remarkable proficiency across a wide range of tasks. However, LLMs often require larger batch sizes to enhance throughput or longer context lengths to meet task demands, which significantly increases the memory resource consumption of the Key-Value (KV) cache during inference, becoming a major bottleneck in LLM deployment. To address this issue, quantization is a common and straightforward approach. Currently, quantization methods for activations are limited to 8-bit, and quantization to even lower bits can lead to substantial accuracy drops. To further save space by quantizing the KV cache to even lower bits, we analyzed the element distribution of the KV cache and designed the NQKV algorithm. Since the elements within each block of the KV cache follow a normal distribution, NQKV employs per-block quantile quantization to achieve information-theoretically optimal quantization error. Without significantly compromising model output quality, NQKV enables the OPT model to perform inference with an 2x larger batch size or a 4x longer context length, and it improves throughput by 9.3x compared to when the KV cache is not used.
format Preprint
id arxiv_https___arxiv_org_abs_2505_16210
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle NQKV: A KV Cache Quantization Scheme Based on Normal Distribution Characteristics
Cai, Zhihang
Zhang, Xingjun
Tan, Zhendong
Wei, Zheng
Machine Learning
Artificial Intelligence
Computation and Language
Large Language Models (LLMs) have demonstrated remarkable proficiency across a wide range of tasks. However, LLMs often require larger batch sizes to enhance throughput or longer context lengths to meet task demands, which significantly increases the memory resource consumption of the Key-Value (KV) cache during inference, becoming a major bottleneck in LLM deployment. To address this issue, quantization is a common and straightforward approach. Currently, quantization methods for activations are limited to 8-bit, and quantization to even lower bits can lead to substantial accuracy drops. To further save space by quantizing the KV cache to even lower bits, we analyzed the element distribution of the KV cache and designed the NQKV algorithm. Since the elements within each block of the KV cache follow a normal distribution, NQKV employs per-block quantile quantization to achieve information-theoretically optimal quantization error. Without significantly compromising model output quality, NQKV enables the OPT model to perform inference with an 2x larger batch size or a 4x longer context length, and it improves throughput by 9.3x compared to when the KV cache is not used.
title NQKV: A KV Cache Quantization Scheme Based on Normal Distribution Characteristics
topic Machine Learning
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2505.16210