通过重构前馈层,显著加速视觉Transformer且精度不降反升。
RePaViT: Scalable Vision Transformer Acceleration via Structural Reparameterization on Feedforward Network Layers
- 让部分通道跳过激活函数,形成线性路径实现推理时结构重参数化。
- 大模型上提速超66%,RePa-ViT-Large精度反而提升1.7%。
- 首次在前馈层应用结构重参数化,适合追求高效部署的开发者。
我们发现,随着模型规模增大,前馈网络(FFN)层而非注意力层是视觉Transformer(ViT)推理延迟的主要来源。为此,本文提出一种新的通道空闲机制,支持测试阶段对FFN层进行后训练结构重参数化。具体而言,每个FFN层中一组特征通道保持空闲,绕过非线性激活函数,形成线性通路,从而实现推理时的结构重参数化。该方法生成一系列可重参数化的视觉Transformer(RePaViTs),在多种ViT模型上实现了显著的延迟降低,且精度损失极小甚至有所提升。方法效果随模型规模增大而持续增强:在大型和超大规模模型上,RePa-ViT-Large与RePa-ViT-Huge分别获得66.8%和68.7%的加速,同时在相同训练策略下,准确率分别提高1.7%和1.1%。据我们所知,RePaViT是首个在FFN层应用结构重参数化的视觉Transformer加速方法,为高效ViT的发展提供了新方向。源代码已开源:https://github.com/Ackesnal/RePaViT。
原文摘要 · Abstract (English)
We reveal that feedforward network (FFN) layers, rather than attention layers, are the primary contributors to Vision Transformer (ViT) inference latency, with their impact signifying as model size increases. This finding highlights a critical opportunity for optimizing the efficiency of large-scale ViTs by focusing on FFN layers. In this work, we propose a novel channel idle mechanism that facilitates post-training structural reparameterization for efficient FFN layers during testing. Specifically, a set of feature channels remains idle and bypasses the nonlinear activation function in each FFN layer, thereby forming a linear pathway that enables structural reparameterization during inference. This mechanism results in a family of ReParameterizable Vision Transformers (RePaViTs), which achieve remarkable latency reductions with acceptable sacrifices (sometimes gains) in accuracy across various ViTs. The benefits of our method scale consistently with model sizes, demonstrating greater speed improvements and progressively narrowing accuracy gaps or even higher accuracies on larger models. In particular, RePa-ViT-Large and RePa-ViT-Huge enjoy 66.8% and 68.7% speed-ups with +1.7% and +1.1% higher top-1 accuracies under the same training strategy, respectively. RePaViT is the first to employ structural reparameterization on FFN layers to expedite ViTs to our best knowledge, and we believe that it represents an auspicious direction for efficient ViTs. Source code is available at https://github.com/Ackesnal/RePaViT.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。