- The paper presents a novel contractive iterated-map coding method that maps codebook indices to low-dimensional vectors, ensuring lossless KV-cache storage with O(1) retrieval.
- It demonstrates that per-head hybrid residual VQ with key-biased bit allocation minimizes perplexity increases while achieving high compression ratios on GPT-2.
- The archive doubles as a searchable index, supporting random access and suffix-based retrieval to enable efficient inference-time memory augmentation in transformer models.
Fractal KV-Cache Archives: Lossless Symbolic Storage with In-Place Retrieval for Long-Context LLM Inference
Motivation and Context
Transformer-based LLM inference over long contexts is fundamentally memory-bound due to the exponential growth of the KV cache, which stores all key and value representations in every layer for every token. The predominant mitigation strategies—quantization, eviction, and offloading—focus on lossy reduction of cache tensor footprints. This paper addresses the post-quantization serialization and retrieval problem: how to store quantized KV states as symbol streams efficiently, and whether the storage layer can provide advanced primitives like random access and in-place search.
Contractive Iterated-Map Coding and Storage Primitive
The contractive iterated-map code—generalizing classical chaos game representation—maps sequences of codebook indices (symbols) to low-dimensional real vectors via repeated contraction toward polygon vertices, one per symbol. Critical properties:
- Losslessness: Encoding and decoding are bijective, provided contraction ratios (r) are chosen to guarantee disjointness of symbol cells in the polygon, bounded by the kissing constant for N-gon alphabets Figure 1.
- Efficiency: Linear-time encoding, O(1) amortized append, and O(1) random access to any position. Direct measurements show encoding at 0.68μs/char and random access at 311μs for a 106-character document.

Figure 1: Decoding is possible only if contraction cells for each symbol are disjoint; shrinkage to the kissing ratio is required for large codebooks.
This coding approach makes the archive both a storage and retrieval structure—two capabilities not generally found in typical byte-compressed serialization.
Quantization Study: Compression and Fidelity Tradeoffs
A controlled study on GPT-2 (124M, 1024-token contexts) quantifies compression/fidelity tradeoffs as follows:
- Per-head VQ vs. Pooled VQ: Per-head codebooks outperform pooled codebooks, Pareto-dominating both in rate-distortion curves and perplexity increase at matched bit budgets. For instance, two-stage per-head residual VQ incurs a +15.0% perplexity increase at 54× compression, vs. +37.2% for pooled RVQ Figure 2.
- Key-Value Asymmetry: Quantizing keys is N0 more harmful to perplexity than quantizing values. Per-head hybrid RVQ (with N1-depth for keys, N2 for values) yields minimum cost: N3 perplexity at N4 compression.
- Optimal Bit Allocation: The pronounced key/value quantization asymmetry motivates bit-asymmetric hybrids—allocating more bits to keys yields best operating points within perplexity budgets.

Figure 2: Per-head codebooks (blue/green) Pareto-dominate pooled codebooks (red), with the bit-asymmetric hybrid achieving minimal perplexity penalty at high compression.
Compression comes from quantization, not serialization. The iterated-map codec—while not outperforming byte-oriented compressors in raw size—offers enhanced access and search capabilities.
In-Place Retrieval: Archive as Search Index
A key feature is that the archive is inherently searchable without decompression. Because the contraction ratio ensures geometric decay of symbol influence, suffix similarity directly corresponds to spatial proximity in the index vector:
- Suffix Retrieval Law: Common suffixes yield positions within N5 of each other Figure 3.
- Recall and Precision: Full recall is achieved for all query lengths; precision depends on numerical precision of the index vector. Double-precision yields near-perfect precision, with single-precision serving as a coarse pre-filter.
- Query Efficiency: Brute-force nearest-neighbor in 2D is practical (N6\,ms/query over N7 positions), and spatial indexing can further accelerate. Retrieval does not require text rehydration or decompression; decoding from matched point reconstructs the underlying sequence.

Figure 3: Suffix length corresponds to proximity in the compressed archive; recall is perfect, and precision is bounded by numerical index granularity.
This retrieval primitive directly supports inference-time memory augmentation, allowing archival searches for contexts matching probes with minimal compute and I/O.
The approach complements work in random-access KV quantization (e.g., FibQuant (Lee et al., 12 May 2026), KVQuant (Hooper et al., 2024), KIVI (Liu et al., 2024)), advancing from quantizer and codebook geometry to the storage layer itself. The use of chaos game representation and universal sequence maps as active, searchable archives is novel in the KV-cache context. Unlike embedding-based retrieval systems, this structure supports suffix-based substring search inherently due to the contractive mapping property.
Limitations
The study's scope is limited to GPT-2, a single dataset, and one context length. Results may be conservative as larger models are empirically more tolerant of quantization. Codebooks are corpus-trained rather than fully online or corpus-independent. The retrieval capability currently supports sequence structure, not semantic embedding retrieval. Raw size performance is matched by byte compressors; the value is in access and search functionality. Comparative evaluation against state-of-the-art quantizers is left for future work.
Conclusion
This work establishes contractive iterated-map codes as first-class storage formats for quantized KV caches: lossless, efficient, and uniquely suitable for in-place search and random access. Per-head residual VQ with key-biased bit allocation achieves substantial compression (N8 of fp16) at tractable perplexity increase (N9 on GPT-2). The archive doubles as an efficient search index, supporting direct suffix-matching and context retrieval. The results have implications for inference-time memory management and retrieval augmentation in LLMs. Future developments may combine advanced quantizers with this retrieval-capable storage, extend to larger models and tasks, and explore semantic retrieval embedding.