通过动态稀疏注意力加速长上下文多模态模型的预填充阶段
MMInference: Accelerating Pre-filling for Long-Context VLMs via Modality-Aware Permutation Sparse Attention
- 基于模态感知的排列稀疏机制,利用视频时空局部性发现独特网格模式
- 在100万token下预填充速度提升8.3倍,精度保持不变
- 无需修改模型或微调,可无缝集成到现有多模态系统中
将长上下文能力与视觉理解结合,为视觉语言模型(VLMs)打开了前所未有的潜力。然而,预填充阶段的二次方注意力复杂度仍是实际部署的主要障碍。为此,我们提出MMInference(多模态百万令牌推理),一种动态稀疏注意力方法,用于加速长上下文多模态输入的预填充阶段。首先,我们的分析揭示了视频输入的时间与空间局部性导致独特的稀疏模式——网格模式;同时,VLMs在不同模态间表现出显著不同的稀疏分布。我们引入基于排列的方法来利用这一独特的网格模式,并解决模态边界问题。通过离线搜索每头的最佳稀疏模式,MMInference根据输入动态构建稀疏分布。我们还提供了优化的GPU内核以实现高效的稀疏计算。值得注意的是,MMInference可无缝集成到现有VLM流水线中,无需任何模型修改或微调。在多个多模态基准测试(包括Video QA、Captioning、VisionNIAH和Mixed-Modality NIAH)上,使用当前最先进的长上下文VLM(LongVila、LlavaVideo、VideoChat-Flash、Qwen2.5-VL)进行实验,结果显示在100万令牌下,预填充阶段速度最高提升8.3倍,且保持精度。代码已公开于https://aka.ms/MMInference。
原文摘要 · Abstract (English)
The integration of long-context capabilities with visual understanding unlocks unprecedented potential for Vision Language Models (VLMs). However, the quadratic attention complexity during the pre-filling phase remains a significant obstacle to real-world deployment. To overcome this limitation, we introduce MMInference (Multimodality Million tokens Inference), a dynamic sparse attention method that accelerates the prefilling stage for long-context multi-modal inputs. First, our analysis reveals that the temporal and spatial locality of video input leads to a unique sparse pattern, the Grid pattern. Simultaneously, VLMs exhibit markedly different sparse distributions across different modalities. We introduce a permutation-based method to leverage the unique Grid pattern and handle modality boundary issues. By offline search the optimal sparse patterns for each head, MMInference constructs the sparse distribution dynamically based on the input. We also provide optimized GPU kernels for efficient sparse computations. Notably, MMInference integrates seamlessly into existing VLM pipelines without any model modifications or fine-tuning. Experiments on multi-modal benchmarks-including Video QA, Captioning, VisionNIAH, and Mixed-Modality NIAH-with state-of-the-art long-context VLMs (LongVila, LlavaVideo, VideoChat-Flash, Qwen2.5-VL) show that MMInference accelerates the pre-filling stage by up to 8.3x at 1M tokens while maintaining accuracy. Our code is available at https://aka.ms/MMInference.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。