Reproduce “KVQuant: Towards 10 Million Context Length LLM Inference with KV Cache Quantization” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W. Mahoney, Yakun Sophia Shao, Kurt Keutzer, Amir Gholami

KVQuant compresses the attention cache for inference through per-channel Key quantization before rotary positional embedding, per-token Value quantization, calibrated non-uniform codebooks, and sparse outlier storage. On LLaMA-7B Wikitext-2, its nominal 3-bit configuration with 1% outliers reports perplexity 5.75 versus 5.68 for fp16 and reduces estimated 128K cache size from 64.0 GB to 13.3 GB. This is a memory estimate, not evidence of accurate million-token comprehension.

Key insights

  • KV cache activations exhibit unique distribution properties, like per-channel outliers and the effect of RoPE, that benefit from specialized quantization strategies.
  • Extracting a small percentage of outliers and storing them separately allows the remaining dense part of activations to be quantized with much higher fidelity at ultra-low bitwidths.
  • Careful calibration (offline vs. online) and custom kernel development are crucial for achieving both high accuracy and runtime efficiency in dynamic activation quantization.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.