Skip to content

KV-Cache Quantization

Definition

KV-Cache Quantization is a technique for reducing the precision of storing keys (K) and values (V) in the transformer's attention cache. It is used to decrease the memory footprint of the KV-cache, which is critical when working with long contexts and large batches.

Approaches

  • Post-training quantization: converting cache values to INT8 or FP8 format after model training.
  • Calibrated quantization: selecting quantization ranges based on activation statistics.
  • Mixed precision: quantizing only part of the layers or attention heads.

Impact on Performance

Without quantization: 2 bytes per element (FP16)
With quantization: 1 byte per element (INT8)
Memory savings: up to 50%

KV-cache quantization allows for increasing the context length or batch size with the same amount of VRAM, but may slightly reduce generation quality.

See Also

← All terms