KVSeal: Serving Long-Context LLMs with Losslessly Compressed KV Caches

Hangyu Liang, Zeyu MiarXiv 2026

TL;DR

When Large Language Models (LLMs) process massive prompts—like an entire codebase or book—their temporary working memory, known as the KV Cache, balloons in size and becomes the primary bottleneck in both GPU capacity and speed. Most remedies shrink this memory by throwing away tokens or rounding off numbers, risking silent accuracy failures on the exact needle-in-a-haystack details you cared about. KVSeal solves this by losslessly compressing the live KV Cache right in GPU memory, cutting memory usage and speeding up token generation while recovering every single original bit.

What Problem Does This Paper Address?

Every time an LLM generates a single new word, it has to look back at all the previous words in the conversation. To avoid recalculating past work, models store historical Key and Value activations—the KV Cache—in GPU memory. As context windows stretch to ratusan of thousands or millions of tokens, this cache dwarfs the model itself (a 256K-token prompt on Llama-3.1-8B eats 32 GiB of memory, over twice the size of the model's weights!). Worse, reading this massive history from memory for every single generated token creates a severe memory-bandwidth traffic jam.

Existing fixes like quantization (lowering numerical precision) or sparse attention (skipping tokens) force an uncomfortable trade-off: save memory, risk losing accuracy. Lossless compression promises memory savings with zero fidelity loss, and researchers have previously applied it to static model weights or network transfers. However, applying lossless compression to a live, resident KV Cache is tricky:

  1. Dynamic lifecycles: Memory pages grow token-by-token and get deleted independently; they can't be tangled up in one giant global compressed file.
  2. GPU architecture: GPUs hate variable-length codes (like standard zip/Huffman files) because parallel threads get out of sync trying to find where their data starts.
  3. Decompression overhead: If you unpack compressed data back into main GPU memory before running attention, the extra read/write trip erases your bandwidth savings.

Methods

KVSeal integrates lossless compression directly into the PagedAttention memory manager (used by engines like vLLM) and the FlashAttention-2 compute kernel through three coordinated designs:

  • Page-Local 4-Bit Exponent Format: Standard 16-bit numbers (BF16) dedicate 8 bits to their exponent. Using offline calibration, KVSeal finds the 16 most common contiguous exponent values for each attention head and encodes them into compact 4-bit fixed-length codes while keeping sign and mantissa bits untouched. Rare outliers ("escape values") get a placeholder in the main array so parallel GPU threads never lose their place, while their true 16-bit values and positions are stashed in a fixed-size "escape record" buffer inside that exact same memory page.
  • Compression-Aware Page Lifecycle: Pages currently accepting new tokens stay uncompressed (OPEN). Once a page fills up (e.g., at 16 tokens), it is SEALED and compressed on the fly. If an unusual page has too many outliers to fit its escape buffer, it simply stays uncompressed (RAW) in a separate physical pool. Upper-level schedulers see one unified logical sequence.
  • Mixed-Format Fused Attention: During generation, KVSeal doesn't decompress pages back to main GPU memory. Instead, it fuses two-stage decompression (parallel dense reconstruction + sparse outlier fix-up) directly into the attention kernel on-chip, overlapping memory fetches with bit-unpacking. Raw and compressed pages are processed along specialized paths and seamlessly merged using standard online-softmax rescaling.

Datasets

No new benchmarks are introduced. The authors use standard existing datasets across distinct domains:

  • PG-19 (books) is used for offline exponent-window calibration.
  • LongBench-v1 (multi-task long-context understanding) is used for end-to-end task accuracy and profiling.
  • MATH and CodeSearchNet (alongside PG-19 and LongBench-v1) are used to test cross-domain calibration robustness—verifying whether compression windows tuned on books still work on math proofs and code.

Key Insights and Ideas

  • BF16 exponents are shockingly predictable: Looking across layers and models, 99.84% to 99.96% of all KV Cache BF16 exponents cluster inside a tight, contiguous window of just 16 values out of 256 possibilities. That statistical redundancy gives you a ~25% size reduction almost for free without touching numerical precision.
Figure 1. Global BF16 exponent distributions of K/V activa- tions.
  • Compression makes decoding faster, not slower: Ordinarily, decompressing data costs time. Because LLM token decoding is starved for memory bandwidth rather than compute, transferring ~24% fewer bytes from main memory saves more time than the lightweight bit-unpacking costs—especially when unpacking one tile is hidden behind fetching the next.
  • Bit-exact inputs $\neq$ bit-exact outputs (and that's okay): Even though KVSeal recovers every K/V bit identically, routing raw and compressed pages through separate split-paths changes the order in which floating-point numbers are added together. Because floating-point addition isn't associative, outputs can diverge slightly over long sequences—yet overall task accuracy remains virtually indistinguishable.

Key Results

Evaluated across four models (Qwen3-4B, Llama-3.1-8B, Mistral-24B, and Qwen3-30B-A3B) on NVIDIA RTX 4090 and L40S GPUs:

  • Storage & Capacity: Achieves 1.306$\times$ physical KV compression, expanding usable context length capacity by 24.0%–26.4% under identical GPU memory budgets (e.g., pushing Llama-3.1-8B from 108K to 137K tokens per request).
  • Codec Speed: Encodes at 542.4 GB/s and decodes at 532.0 GB/s on an RTX 4090—outperforming all tested lossless GPU codecs and even beating a raw BF16 memory copy (502.8 GB/s) due to reduced memory traffic.
  • Latency Speedups: Fused attention runs up to 1.27$\times$ faster than FlashAttention-2 at 128K context, translating to a 1.13$\times$–1.19$\times$ end-to-end decode speedup over stock vLLM at 96K tokens.
  • Calibration Robustness: Escape rates stay below 0.08% even as prompts scale to 256K tokens, and cross-domain page fallback rates stay at or below 0.048%.

Limitations and Future Work

  • Prefill Compute Bottlenecks: When processing long initial prompts (prefill) with hundreds of query tokens at once, attention becomes compute-bound rather than bandwidth-bound, exposing decompression overhead. KVSeal currently works around this with a threshold policy—switching to one-time decompression into a temporary buffer for queries over ~256–512 tokens—which requires extra workspace memory.
  • Hardware Sensitivity: Next-generation accelerators with higher memory-bandwidth-to-compute ratios will make raw memory loads cheaper relative to bit-unpacking instructions, potentially narrowing speedups (though capacity gains remain).
  • Architecture & System Scope: The prototype targets standard Multi-Head and Grouped-Query Attention (MHA/GQA). Adapting page-local compression to newer layouts like Multi-head Latent Attention (MLA) or linear attention states, as well as testing interactions with preemption and cache eviction, remains future work.

Summary updated

BibTeX
@misc{liang2026kvseal,
  author = {Hangyu Liang and Zeyu Mi},
  title = {{KVSeal: Serving Long-Context LLMs with Losslessly Compressed KV Caches}},
  year = {2026},
  eprint = {2611.40469},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40469},
}
Figure