MemShare: Memory Efficient Inference for Large Reasoning Models through KV Cache Reuse

Kaiwen Chen, Xin Tan, Minchen Yu, Hong Xu · OpenReview

Abstract

Large Reasoning Models (LRMs) have achieved significant advances in mathematical reasoning and formal logic tasks. However, their tendency to generate lengthy chain-of-thought sequences leads to substantial memory overhead during inference. We observe that LRMs frequently produce highly similar intermediate reasoning steps, which correspond to similar KV cache states across layers. Motivated by this observation, we propose MemShare, a novel KV cache management approach that effectively reduces memory overhead. MemShare employs a collaborative filtering algorithm to efficiently identify reusable KV cache blocks and enables zero copy cache reuse to significantly reduce memory overhead, improve throughput while maintaining accuracy. Experimental results demonstrate that MemShare delivers up to 84.79% improvement in throughput while maintaining better accuracy compared to existing KV cache management methods.

Introduction

The current frontier of AI belongs to Large Reasoning Models (LRMs) like DeepSeek-R1 and QwQ-32B. Unlike standard LLMs, LRMs generate lengthy internal monologues, or "Chain-of-Thought" (CoT), before providing a final answer. While this improves logical performance, it creates a massive engineering bottleneck: the KV Cache.

To avoid recomputing previous tokens at every step, models store "Key" and "Value" vectors in memory. For a model like QwQ-32B, this cache can balloon to 15GB for a single request, severely limiting server throughput. However, observations suggest that LRMs often repeat reasoning patterns or explore similar paths, leading to "redundant thinking" where the model recalculates nearly identical KV cache states.

Methodology

MemShare addresses this redundancy by identifying and reusing existing KV cache blocks through a two-stage collaborative filtering process and zero-copy sharing.

The MemShare workflow: from autoregressive generation to zero-copy KV cache sharing.

Two-Stage Collaborative Filtering

  1. Step-Level Lexical Similarity: The system monitors generated text for reasoning steps (delimited by characters like \n\n). It uses a lightweight bag-of-words comparison on the CPU to detect if a new step is lexically similar to previous ones.
  2. Block-Level Euclidean Distance: If a lexical match is found, the system performs a precise check by calculating the Euclidean distance between the actual KV cache vectors of the current and candidate blocks. If they fall within a specific threshold, they are deemed interchangeable.

Zero-Copy Cache Reuse

Once a match is confirmed, MemShare updates the model's block table (utilizing a modified PagedAttention mechanism) to point to the existing physical memory block rather than allocating new memory. This allows for immediate reuse without the overhead of data movement.

Key Insights and Redundancy Analysis

A core finding of this research is that redundant thinking is a pervasive feature of LRMs. Quantitative analysis shows that 20-40% of reasoning content is redundant at a 0.8 similarity threshold across various architectures and model sizes.

Similarity ratios across different models and datasets at thresholds of 0.8 and 0.9.

Furthermore, the researchers established that lexical similarity in generated text is a strong predictor of mathematical similarity in the underlying KV cache vectors across almost all transformer layers. This relationship allows the system to use cheap text-based filtering to trigger more expensive vector-based checks only when necessary. The authors also provide a mathematical safety proof (Theorem 1) showing that substituting a KV block with a "sufficiently close" alternative only minimally perturbs the final attention output, preserving model intelligence.

Experimental Results

MemShare was evaluated on rigorous benchmarks including AIME 2024/2025, MATH-500, and GPQA Diamond using models such as DeepSeek-R1-Distill-Qwen-32B and QwQ-32B.

  • Throughput Gains: On the MATH-500 benchmark, MemShare improved throughput by 84.79% for DeepSeek-R1 and 70.88% for QwQ-32B.
  • Accuracy Retention: Accuracy remained remarkably stable; QwQ-32B retained 97.5% of its baseline accuracy on MATH-500 despite aggressive memory sharing.
  • Comparison to Baselines: MemShare consistently outperformed existing methods like Quest, SnapKV, and StreamingLLM. In AIME 24 tests, MemShare achieved over double the accuracy of competitors under similar memory constraints because it reuses rather than evicts critical information.

Limitations and Future Work

While effective, MemShare currently relies on clear delimiters (like double newlines) to segment reasoning steps. Future iterations could explore dynamic similarity thresholds that adjust based on task complexity or model confidence. Additionally, deeper hardware-level integration could further optimize memory management and performance gains.

Summary updated

Abstract

Large Reasoning Models (LRMs) have achieved significant advances in mathematical reasoning and formal logic tasks. However, their tendency to generate lengthy chain-of-thought sequences leads to substantial memory overhead during inference. We observe that LRMs frequently produce highly similar intermediate reasoning steps, which correspond to similar KV cache states across layers. Motivated by this observation, we propose MemShare, a novel KV cache management approach that effectively reduces memory overhead. MemShare employs a collaborative filtering algorithm to efficiently identify reusable KV cache blocks and enables zero copy cache reuse to significantly reduce memory overhead, improve throughput while maintaining accuracy. Experimental results demonstrate that MemShare delivers up to 84.79\% improvement in throughput while maintaining better accuracy compared to existing KV cache management methods.
BibTeX
@misc{chen2025memshare,
  author = {Kaiwen Chen and Xin Tan and Minchen Yu and Hong Xu},
  title = {{MemShare: Memory Efficient Inference for Large Reasoning Models through KV Cache Reuse}},
  year = {2025},
  eprint = {2507.21433},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.21433},
}
Figure