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

Mesa:一个节省内存的Transformers训练框架

Mesa: A Memory-saving Training Framework for Transformers

Monash University(莫纳什大学)

Zizheng Pan, Peng Chen, Haoyu He, Jing Liu, Jianfei Cai, Bohan Zhuang

摘要:

人们对设计高性能Transformers的兴趣激增。虽然Transformers已经提供了显着的性能改进,但由于在反向传播期间存储梯度计算所需的所有中间激活,训练此类网络是非常内存密集的,特别是对于长序列。为此,我们提出了Mesa,一个节省内存的Transformers训练框架。具体来说,Mesa在前向传递过程中使用精确的激活,同时存储低精度版本的激活,以减少训练过程中的内存消耗。然后在反向传播期间对低精度激活进行去量化以计算梯度。此外,为了解决多头自注意层中激活分布的异质性问题,提出了一种头级激活量化策略,该策略根据每个头的统计信息对激活进行量化,以最小化近似误差。为了进一步提高训练效率,我们通过运行估计来学习量化参数。更重要的是,通过将节省的内存重新投资于采用更大的批处理大小或按比例放大模型大小,我们可以在有限的计算资源下进一步提高性能。在ImageNet、CIFAR-100和ADE 20 K上进行的大量实验表明,Mesa可以在训练期间实现灵活的内存节省(高达50%),同时实现相当甚至更好的性能。代码可在https://github.com/ziplab/Mesa上获得。

英文摘要:

There has been an explosion of interest in designing high-performance Transformers. While Transformers have delivered significant performance improvements, training such networks is extremely memory intensive owing to storing all intermediate activations that are needed for gradient computation during backpropagation, especially for long sequences. To this end, we present Mesa, a memory-saving training framework for Transformers. Specifically, Mesa uses exact activations during forward pass while storing a low-precision version of activations to reduce memory consumption during training. The low-precision activations are then dequantized during back-propagation to compute gradients. Besides, to address the heterogeneous activation distributions in the multi-head self-attention layers, we propose a head-wise activation quantization strategy, which quantizes activations based on the statistics of each head to minimize the approximation error. To further boost training efficiency, we learn quantization parameters by running estimates. More importantly, by re-investing the saved memory in employing a larger batch size or scaling up model size, we may further improve the performance under constrained computational resources. Extensive experiments on ImageNet, CIFAR-100 and ADE20K demonstrate that Mesa can achieve flexible memory-savings (up to 50%) during training while achieving comparable or even better performance. Code is available at https://github.com/ziplab/Mesa.

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

↑