HVKV: Scalable Long-Context Inference through Hypervector KV Cache Retrieval
Abstract
Long-context inference is increasingly bottlenecked by the KV cache rather than the model weights. CPU offloading can extend capacity, but transferring the full KV cache at each decode step turns memory pressure into a bandwidth bottleneck. We present HVKV, a KV-cache retrieval framework based on compact yet effective binary key representations. HVKV keeps these compact binary keys on the GPU for Hamming-distance indexing and offloads the full-precision KV cache to CPU memory, fetching only the selected KV pairs to compute attention over the retrieved top-k subset. This design confines approximation to candidate selection, reducing the cost and memory footprint of index-based retrieval, while preserving full-precision attention. To make this efficient in practice, HVKV combines an incremental Hamming-distance update that reuses distance state across adjacent decode steps with a dual GPU cache for retrieved KV pairs. HVKV matches Full Attention at a 1% token budget while outperforming the strongest compared baseline at similar budgets by 35.0% in average score, and reduces per-token decode latency by up to 32.8% at 1M context.