Table of Contents
Fetching ...

PolarQuant: Leveraging Polar Transformation for Efficient Key Cache Quantization and Decoding Acceleration

Songhao Wu, Ang Lv, Xiao Feng, Yufei Zhang, Xun Zhang, Guojun Yin, Wei Lin, Rui Yan

TL;DR

PolarQuant reframes key-cache quantization for long-context LLMs by rotating paired key-dimension sub-vectors into polar coordinates, where outliers become smooth distributions in $r$ and $\theta$. It quantizes $r$ with $n$ bits and $\theta$ with $m$ bits, partitioning the plane into $2^{n+m}$ regions and encoding each 2D sub-vector by its region index. A key feature is a decoding pathway that replaces dequantization with a lookup table, turning the query-key inner product into a sequence of fast table lookups and additions, yielding up to $1.27\times$ speedups on GPUs while maintaining downstream accuracy. The approach eliminates the group-wise overhead of prior methods, reduces quantization parameters, and demonstrates robustness across models and tasks, including long-context benchmarks like LongBench. PolarQuant is implemented with a fused Triton kernel and shows practical benefits for long-context LLM deployment, with open-source release planned.

Abstract

The KV cache in large language models is a dominant factor in memory usage, limiting their broader applicability. Quantizing the cache to lower bit widths is an effective way to reduce computational costs; however, previous methods struggle with quantizing key vectors due to outliers, resulting in excessive overhead. We propose a novel quantization approach called PolarQuant, which efficiently addresses the outlier challenge. We observe that outliers typically appear in only one of two dimensions, which are rotated together by a specific angle when rotary position embeddings are applied. When represented as two-dimensional vectors, these dimensions exhibit well-structured patterns, with radii and angles smoothly distributed in polar coordinates. This alleviates the challenge of outliers on per-channel quantization, making them well-suited for quantization. Thus, PolarQuant divides key vectors into groups of two-dimensional sub-vectors, encoding them as the corresponding quantized radius and the polar angle, rather than quantizing original key vectors directly. PolarQuant achieves the superior efficiency in KV cache quantization and accelerates the decoding process by turning the query-key inner product into a table lookup, all while maintaining the downstream performance of full-precision models.

PolarQuant: Leveraging Polar Transformation for Efficient Key Cache Quantization and Decoding Acceleration

TL;DR

PolarQuant reframes key-cache quantization for long-context LLMs by rotating paired key-dimension sub-vectors into polar coordinates, where outliers become smooth distributions in and . It quantizes with bits and with bits, partitioning the plane into regions and encoding each 2D sub-vector by its region index. A key feature is a decoding pathway that replaces dequantization with a lookup table, turning the query-key inner product into a sequence of fast table lookups and additions, yielding up to speedups on GPUs while maintaining downstream accuracy. The approach eliminates the group-wise overhead of prior methods, reduces quantization parameters, and demonstrates robustness across models and tasks, including long-context benchmarks like LongBench. PolarQuant is implemented with a fused Triton kernel and shows practical benefits for long-context LLM deployment, with open-source release planned.

Abstract

The KV cache in large language models is a dominant factor in memory usage, limiting their broader applicability. Quantizing the cache to lower bit widths is an effective way to reduce computational costs; however, previous methods struggle with quantizing key vectors due to outliers, resulting in excessive overhead. We propose a novel quantization approach called PolarQuant, which efficiently addresses the outlier challenge. We observe that outliers typically appear in only one of two dimensions, which are rotated together by a specific angle when rotary position embeddings are applied. When represented as two-dimensional vectors, these dimensions exhibit well-structured patterns, with radii and angles smoothly distributed in polar coordinates. This alleviates the challenge of outliers on per-channel quantization, making them well-suited for quantization. Thus, PolarQuant divides key vectors into groups of two-dimensional sub-vectors, encoding them as the corresponding quantized radius and the polar angle, rather than quantizing original key vectors directly. PolarQuant achieves the superior efficiency in KV cache quantization and accelerates the decoding process by turning the query-key inner product into a table lookup, all while maintaining the downstream performance of full-precision models.

Paper Structure

This paper contains 16 sections, 18 equations, 1 figure, 5 tables.

Figures (1)

  • Figure 1: (a) Illustration of outliers in key vectors. We highlight two dimensions rotated together by RoPE that exhibit outliers (exemplified by Llama 3.1-8B-Instruct Layer 0 Head 0). (b) When viewing these two dimensions in a two-dimensional plane, although the individual x- or y-axis may contain outliers, they collectively form stable circular patterns, making quantization of the original outliers easier. Each blue dot represents a mapped two-dimensional vector, with transparency indicating frequency. (c) An example of PolarQuant using $m=3$ bits to quantize polar angles and $n=2$ bits to quantize radii. The colorful arrows indicate sub-vectors formed by pairs of dimensions in the keys; the quantized results are shown with colorful dashed arrows, and the quantization error is represented by the grey dashed arrow.