Compress LLM KV cache up to 10× with per-token, outlier-aware quantization and little accuracy loss

March 7, 20247 min

Overview

Decision SnapshotNeeds Validation

Clear theory + targeted ablations and numbers on LLaMA-2 (7B/13B) show consistent gains, but experiments are limited to a few zero-shot tasks and one model family.

Citations3

Evidence Strength0.70

Confidence0.78

Risk Signals10

Trust Signals

Findings with numeric evidence: 5/5

Findings with evidence refs: 5/5

Results with explicit delta: 4/5

Reproducibility

Status: Partial assets available

Open source: Partial

At A Glance

Cost impact: 80%

Production readiness: 70%

Novelty: 45%

Authors

Shichen Dong, Wen Cheng, Jiayu Qin, Wei Wang

Links

Abstract / PDF / Code

Why It Matters For Business

QAQ can cut the GPU memory used by KV caches by ~8–10×, enabling longer-context features or reducing GPU requirements and cost with little accuracy loss.

Who Should Care

Summary TLDR

QAQ is a post-training quantization method for the Key-Value (KV) cache used during LLM autoregressive inference. It (1) assigns different quantization strategies to keys and values, (2) keeps rare outlier entries in full precision, and (3) uses an attention-window heuristic to avoid irreversible mistakes. On LLaMA-2 (7B/13B) and three zero-shot tasks, QAQ compresses the KV cache near 8–10× with negligible accuracy loss and ~1.6–1.8× better lossless compression than prior cache-only methods. Code is available.

Problem Statement

The KV cache (stored keys and values from past tokens) grows linearly with context length and quickly dominates GPU memory for long-context LLM inference. Prior eviction heuristics can remove needed tokens. The problem: shrink KV cache memory via quantization while keeping attention outputs (and thus generation quality) intact.

Main Contribution

QAQ: a post-training, per-token quantization formula that assigns bits separately for key and value caches based on predicted impact on attention outputs.

Mixed-precision outlier handling: keep the top/ bottom α% of KV entries at full precision and quantize the rest, reducing quantization error.

Key Findings

Key vectors are more sensitive to quantization than value vectors; uniform 2-bit quantization harms keys far more than values.

NumbersLLaMA-2-7B experiment: 2-bit value quantization retains high accuracy; 2-bit key quantization causes large accuracy drop

Practical UseQuantize keys with more bits than values; treat keys and values with different strategies to preserve accuracy.

Evidence RefSec 3.1, Fig.2(a)

QAQ compresses the KV cache up to about 10× with minimal accuracy loss on evaluated tasks.

NumbersClaimed up to 10×; typical lossless compression ≈7.49.0× on LLaMA-2 tasks

Practical UseYou can reduce KV cache memory by ~8–10× on LLaMA-2 models, enabling longer contexts on the same GPUs.

Evidence RefAbstract; Sec 5.2; Table 1; Fig.3

Results

MetricValueBaselineDeltaSplit / DatasetEvidenceEvidence Ref
AccuracyLLaMA-2-7B: HellaSwag 7.48×, PIQA 7.48×, MathQA 6.04×uncompressed ()≈7 reductionzero-shot evaluationsTable 1; Sec 5.2Table 1
AccuracyLLaMA-2-13B: HellaSwag 8.39×, PIQA 9.02×, MathQA 6.06×uncompressed ()≈6 reductionzero-shot evaluationsTable 1; Sec 5.2Table 1

What To Try In 7 Days

Run the authors' repo on a LLaMA-2-7B model and reproduce memory vs accuracy plots on one dataset.

Try α=1% outliers and attention window n=5; measure memory, latency, and accuracy trade-offs.

Integrate QAQ into your inference pipeline where KV cache size limits context length and measure real-world speed/transfer costs.

Optimization Features

Token Efficiency
Per-token bit assignment based on predicted σ boundsQuantize low-importance tokens to fewer bits
System Optimization
Reduces GPU memory footprint for KV cacheRelies on CPU-GPU transfers when adjusting quantization
Inference Optimization
Per-token adaptive bit allocationMixed-precision: keep outliers at full precisionAttention-window to predict future importanceRe-quantization between CPU and GPU when needed

Reproducibility

Code AvailableYes
Data AvailableNo
Open Source StatusPartial
LicenseUnknown

Risks & Boundaries

Limitations

Relies on the persistence-of-importance assumption; abrupt attention changes still need re-quantization.

Evaluation limited to LLaMA-2 (7B/13B) and three zero-shot tasks; generality to other models/tasks untested.

When Not To Use

On ultra-low-latency systems where CPU–GPU transfers are prohibitively expensive.

When the model uses multi-query attention variants that already reduce KV cache size significantly.

Failure Modes

Underestimating future attention for a token leads to irreversible quantization and degraded output.

Misclassifying outliers (too many or too few) either wastes memory or causes accuracy drops.

Core Entities

Models

LLaMA 2-7BLLaMA 2-13B

Metrics

compression ratio (KV cache size)Accuracy

Datasets

HellaSwagPIQAMathQA

Context Entities

Models

OPT-6BOPT-13BOPT-30B