表征偏移:统一令牌压缩与FlashAttention
Representation Shift: Unifying Token Compression with FlashAttention
AI总结:
针对FlashAttention与多数免训练令牌压缩方法不兼容的问题,提出免训练、模型无关的表征偏移指标衡量令牌变化,实现二者无缝集成,还可推广至CNN等模型,在视频任务中取得显著加速。
摘要:
Transformer已在视觉、语言和视频领域取得显著成功。然而,任务复杂度的提升催生了更大规模的模型和更多的令牌,导致自注意力的二次计算成本及GPU内存访问开销升高。为降低自注意力的计算成本,已有研究提出令牌压缩技术,丢弃冗余或信息量较低的令牌。同时,FlashAttention等融合注意力内核被开发出来,通过避免构建注意力图及其对应的HBM I/O操作来缓解内存开销,但这导致其与大多数免训练令牌压缩方法不兼容——这类方法依赖注意力图判断令牌重要性。本文提出表征偏移(Representation Shift),这是一种免训练、模型无关的指标,用于衡量每个令牌表征的变化程度。该方法无需注意力图或重新训练,即可将令牌压缩与FlashAttention无缝集成,还可进一步推广至Transformer之外的CNN和状态空间模型。大量实验表明,表征偏移可实现与FlashAttention兼容的有效令牌压缩,在视频文本检索和视频问答任务中分别实现最高5.5%和4.4%的显著加速。代码可在https://github.com/mlvlab/Representation-Shift获取。
英文摘要:
Transformers have demonstrated remarkable success across vision, language, and video. Yet, increasing task complexity has led to larger models and more tokens, raising the quadratic cost of self-attention and the overhead of GPU memory access. To reduce the computation cost of self-attention, prior work has proposed token compression techniques that drop redundant or less informative tokens. Meanwhile, fused attention kernels such as FlashAttention have been developed to alleviate memory overhead by avoiding attention map construction and its associated I/O to HBM. This, however, makes it incompatible with most training-free token compression methods, which rely on attention maps to determine token importance. Here, we propose Representation Shift, a training-free, model-agnostic metric that measures the degree of change in each token's representation. This seamlessly integrates token compression with FlashAttention, without attention maps or retraining. Our method further generalizes beyond Transformers to CNNs and state space models. Extensive experiments show that Representation Shift enables effective token compression compatible with FlashAttention, yielding significant speedups of up to 5.5% and 4.4% in video-text retrieval and video QA, respectively. Code is available at https://github.com/mlvlab/Representation-Shift.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。