MadaKV: Adaptive Modality-Perception KV Cache Eviction for Efficient Multimodal Long-Context Inference

Kunxi Li, Zhonghua Jiang, Zhouzhou Shen, Zhaode Wang, Chengfei Lv, Shengyu Zhang, Fan Wu, Fei Wu

Abstract

Multimodal Large Language Models (MLLMs) face significant memory constraints during long-context inference due to the linear growth of the Key-Value (KV) cache. Existing KV cache eviction methods are primarily designed for text and often fail to account for the distinct attention patterns of visual tokens. We present MadaKV, an adaptive modality-perception KV cache eviction strategy. MadaKV dynamically identifies modality preferences across attention heads and employs hierarchical compression compensation to maintain critical information. Our approach reduces memory usage by up to 95% and improves inference speed by 1.5x while preserving accuracy across diverse multimodal benchmarks.

Introduction

As Multimodal Large Language Models (MLLMs) like LLaVA and Qwen-VL evolve, they are increasingly tasked with processing complex, long-form inputs such as hour-long videos or extensive technical documents. However, these models suffer from a significant "memory problem." To generate text efficiently, they utilize a Key-Value (KV) cache to store past information. As context length grows, this cache expands linearly, leading to massive memory consumption and degraded performance. MadaKV addresses this by introducing an adaptive strategy that recognizes the varying importance of visual and textual tokens across different parts of the model.

The Challenge: Modality-Agnostic Limitations

Current KV cache eviction methods, such as H2O or SnapKV, typically treat all tokens uniformly. However, multimodal data presents two unique challenges that these "modal-agnostic" methods ignore:

  1. Sparsity Heterogeneity: Text tokens often exhibit "sharp" attention, where a few specific words carry most of the weight. In contrast, visual tokens often show "diffuse" attention, with importance spread across many pixels.
  2. Modality Preference: Different attention heads within a model specialize. Some act as "visual specialists," while others focus primarily on text.
Comparison between modal-agnostic sparsity and MadaKV's modality-aware token eviction.

By ignoring these differences, standard eviction policies may inadvertently delete critical visual details required by specialized heads, leading to hallucinations or errors.

Methodology: Adaptive Modality Perception

MadaKV introduces two novel components to manage multimodal cache complexity:

  • Modality Preference Adaptation (MPA): Instead of a fixed budget, MPA dynamically calculates a preference metric. It uses "proxy tokens" (such as the final question in a prompt) to determine which previous tokens the model is prioritizing. If an attention head favors visual tokens, MadaKV allocates a larger budget to retain visual information for that specific head.
  • Hierarchical Compression Compensation (HCC): Recognizing that transformer layers are not equal, HCC modulates eviction across the model. Early layers, which build foundational representations, may retain more information, while subsequent layers compensate with more aggressive eviction to stay within total memory limits.

Experimental Evaluation

The authors evaluated MadaKV using MileBench, a benchmark for long-context MLLMs, across tasks including Text Needle In A Haystack (TN), multimodal conversational QA (MMCoQA), and image retrieval. Testing was conducted on LLaVA-v1.5 (7B and 13B) and Qwen2.5-VL-7B.

Analysis and Results

A key finding of this research is the clear "division of labor" within MLLMs. Heatmap analysis reveals that specific attention heads consistently specialize in either visual or textual processing.

Heatmap showing the distribution of modality preferences across layers and attention heads.

Key Performance Metrics:

  • Memory Efficiency: MadaKV reduces the KV cache footprint by 80% to 95%. For example, on an NVIDIA A100, memory usage can drop from 1.63 GiB to just 0.16 GiB.
  • Inference Speed: By reducing the data volume processed by the GPU, MadaKV improves decoding latency by 1.3x to 1.5x.
  • Accuracy: In the "Needle in a Haystack" task, MadaKV outperformed previous multimodal methods like LOOK-M by over 6%, maintaining performance remarkably close to a full-cache baseline.

Conclusion

MadaKV demonstrates that modality-aware memory management is essential for efficient multimodal inference. While currently focused on text-image relationships in models up to 13B parameters, future work will explore extending this adaptive logic to video and audio modalities, as well as scaling to even larger "frontier" models with million-token contexts.

Summary updated

BibTeX
@inproceedings{li2025madakv,
  author = {Kunxi Li and Zhonghua Jiang and Zhouzhou Shen and Zhaode Wang and Chengfei Lv and Shengyu Zhang and Fan Wu and Fei Wu},
  title = {{MadaKV: Adaptive Modality-Perception KV Cache Eviction for Efficient Multimodal Long-Context Inference}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure