Fractal KV-Cache Archives: Lossless Symbolic Storage with In-Place Retrieval for Long-Context LLM Inference

· Source: Machine Learning · Field: Technology & Digital — Artificial Intelligence & Machine Learning · Depth: Expert, quick

Summary

Fractal KV-Cache Archives introduce a novel method for lossless symbolic storage and in-place retrieval of quantized key-value (KV) caches, addressing the memory cost of long-context LLM inference. This approach utilizes contractive iterated-map codes to serialize a symbol sequence into low-dimensional real vectors, forming an efficient archive format. The method offers O(1) random access and O(1) amortized append, operating in linear time. A study on GPT-2 with 1024-token contexts demonstrated that per-head residual vector quantization, combined with a small exact window (4 attention sinks + 32 recent tokens), reduces the archived cache by 36-54x compared to an fp16 cache, incurring an 11-15% perplexity cost. The research also quantified a key/value asymmetry, finding key quantization approximately 4x more damaging than value quantization, informing a hybrid bit allocation scheme. Furthermore, the archive functions as a search index, enabling approximate substring queries directly on stored vectors and decoding matched context without full text materialization. The code is released and reproducible.

Key takeaway

For Machine Learning Engineers optimizing long-context LLM inference, you should consider implementing Fractal KV-Cache Archives to significantly reduce memory footprint. This method allows you to achieve 36-54x memory reduction with a manageable 11-15% perplexity cost. Prioritize value quantization over key quantization, as keys are approximately 4x more sensitive. Furthermore, explore using the archive's built-in search index for efficient context retrieval without full text materialization.

Key insights

Fractal KV-Cache Archives offer lossless, O(1) access storage for quantized LLM KV caches, doubling as a search index.

Principles

Method

Serialize quantized KV cache symbol streams into low-dimensional real vectors using contractive iterated-map codes, enabling O(1) random access and append.

In practice

Topics

Best for: NLP Engineer, Research Scientist, AI Scientist, Machine Learning Engineer, AI Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning.