arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2208.01313cs.CVcs.MM
收藏

加速和稳定Transformers的统一归一化

Unified Normalization for Accelerating and Stabilizing Transformers

Hikvision Research Institute(海康威视研究院);Zhejiang University(浙江大学)

Qiming Yang, Kai Zhang, Chaoxiang Lan, Zhi Yang, Zheyang Li, Wenming Tan, Jun Xiao, Shiliang Pu

摘要:

Transformers的可靠结果使其成为各种自然语言和视觉任务中的主流架构。作为Transformers中的默认组件,层归一化(LN)对每个令牌内的激活进行归一化,以提高健壮性。然而,LN需要在推理以及除法和平方根运算中进行动态统计计算,导致硬件效率低下。更重要的是,用其他硬件高效的归一化方案(例如,批量归一化)会导致性能下降,甚至在训练中崩溃。我们发现这种困境是由激活统计的异常行为引起的,包括迭代过程中的大波动和跨层的极端离群值。为了解决这些问题,我们提出了统一规范化(UN),它可以通过与其他线性运算融合来加快推理速度,并实现与LN相当的性能。UN致力于通过使用定制的波动平滑策略校准激活和梯度统计来提高性能。同时,采用自适应离群点过滤策略避免训练过程中的崩溃,理论上证明了该策略的有效性,并通过实验验证了其有效性。我们证明,联合国可以是一个有效的下拉替代LN进行广泛的实验语言和视觉任务。此外,我们评估我们的方法在GPU上的效率。配备UN的Transformers具有约31%的推理加速和近18%的内存减少。代码将在https://github.com/hikvision-research/Unified-Normalization上发布。

英文摘要:

Solid results from Transformers have made them prevailing architectures in various natural language and vision tasks. As a default component in Transformers, Layer Normalization (LN) normalizes activations within each token to boost the robustness. However, LN requires on-the-fly statistics calculation in inference as well as division and square root operations, leading to inefficiency on hardware. What is more, replacing LN with other hardware-efficient normalization schemes (e.g., Batch Normalization) results in inferior performance, even collapse in training. We find that this dilemma is caused by abnormal behaviors of activation statistics, including large fluctuations over iterations and extreme outliers across layers. To tackle these issues, we propose Unified Normalization (UN), which can speed up the inference by being fused with other linear operations and achieve comparable performance on par with LN. UN strives to boost performance by calibrating the activation and gradient statistics with a tailored fluctuation smoothing strategy. Meanwhile, an adaptive outlier filtration strategy is applied to avoid collapse in training whose effectiveness is theoretically proved and experimentally verified in this paper. We demonstrate that UN can be an efficient drop-in alternative to LN by conducting extensive experiments on language and vision tasks. Besides, we evaluate the efficiency of our method on GPU. Transformers equipped with UN enjoy about 31% inference speedup and nearly 18% memory reduction. Code will be released at https://github.com/hikvision-research/Unified-Normalization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑