SelKV Optimizes LLM KV Cache, Boosting Long Context Performance

Soumia Bouyahiaoui, Manel Kara laouar, Aicha Boutorh, Mohamed Hadj Ameur· July 21, 2026 View original

Summary

SelKV is a training-free framework that optimizes LLM Key-Value (KV) cache memory by selectively merging or dropping tokens and compensating for attention sag. It achieves strong performance on long-context tasks, maintaining near-lossless generation quality while delivering a 3.3x decoding speedup at 100k tokens.

The memory footprint of the Key-Value (KV) cache in Large Language Models (LLMs) is a significant bottleneck, growing linearly with context length during autoregressive text generation. Existing compression methods often indiscriminately merge tokens, which can degrade representations and lead to "attention sag"—where merged tokens receive disproportionate softmax mass. A new training-free framework, SelKV, addresses these issues with a dual-component approach. SelKV first employs a soft cosine gate that adaptively decides whether to merge or drop tokens based on their value-vector similarity, thereby preserving semantic fidelity. Second, it introduces an attention-ratio compensation mechanism that applies a decoding-time logit bias, correcting the softmax imbalance caused by merging. Evaluated on the LongBench dataset, SelKV maintains strong compressed performance even when retaining only 25% of the KV cache. It proves particularly robust for grouped-query attention (GQA) models, achieving near-lossless generation quality and outperforming full-cache baselines on complex multi-document QA tasks, all while delivering a 3.3x decoding speedup at 100k tokens.

Why it matters

For professionals deploying LLMs, especially those requiring very long context windows, SelKV offers a critical solution to memory and speed limitations. By efficiently managing the KV cache, it enables more cost-effective and performant applications, expanding the practical use cases for advanced LLMs.

How to implement this in your domain

  1. 1Investigate integrating SelKV into existing LLM inference pipelines to reduce memory consumption and improve decoding speed for long contexts.
  2. 2Benchmark SelKV's performance on your specific long-context tasks to quantify the gains in speed and memory efficiency.
  3. 3Explore how the selective merging and attention compensation mechanisms can be adapted or fine-tuned for proprietary models.
  4. 4Consider the implications of reduced KV cache size on hardware requirements and cloud costs for LLM deployments.

Who benefits

AI/ML InfrastructureCloud ComputingSoftware DevelopmentContent CreationResearch

Key takeaways

  • SelKV efficiently compresses LLM KV cache, addressing a major memory bottleneck.
  • It uses selective token merging/dropping and attention compensation.
  • The framework maintains near-lossless generation quality on long contexts.
  • It delivers significant decoding speedups (e.g., 3.3x at 100k tokens).

Original post by Soumia Bouyahiaoui, Manel Kara laouar, Aicha Boutorh, Mohamed Hadj Ameur

"arXiv:2607.16213v1 Announce Type: new Abstract: Large Language Models (LLMs) generate text autoregressively, relying on a key-value (KV) cache whose memory footprint grows linearly with context length, creating a major bottleneck. Recent compression methods mitigate this cost via…"

View on X

Originally posted by Soumia Bouyahiaoui, Manel Kara laouar, Aicha Boutorh, Mohamed Hadj Ameur on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses