arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.18513cs.CL
收藏

SlimFit:基于训练动态的Transformer模型内存高效微调

SlimFit: Memory-Efficient Fine-Tuning of Transformer-based Models Using Training Dynamics

University of California Berkeley(加州大学伯克利分校);Lawrence Berkeley National Laboratory(劳伦斯伯克利国家实验室)

Arash Ardakani, Altan Haan, Shangyin Tan, Doru Thom Popovici, Alvin Cheung, Costin Iancu, Koushik Sen

AI总结:

SlimFit通过动态分析训练动态、运行时层间调度以及量化和剪枝冻结低贡献层,将ViT和BERT等Transformer模型微调的GPU内存占用平均降低2.2倍,且准确率仅下降约0.2%,使原本需多块32GB GPU的微调可在单块GPU上完成。

摘要:

基于Transformer的模型(如BERT和ViT)已在多种自然语言处理(NLP)和计算机视觉(CV)任务上取得最先进的结果。然而,这些模型在微调过程中极其占用内存,使其难以部署在内存资源有限的GPU上。为解决这一问题,我们引入了一个名为SlimFit的新工具,该工具通过动态分析模型的训练动态并在微调期间冻结贡献较小的层来降低这些模型的内存需求。要冻结的层通过运行时层间调度算法进行选择。SlimFit对特定层采用量化和剪枝,以平衡动态激活的负载并最小化静态激活的内存占用,其中静态激活是指无论是否冻结都无法丢弃的激活。这使得SlimFit能够冻结多达95%的层,并在GLUE、SQuAD 2.0、CIFAR-10、CIFAR-100和ImageNet等不同NLP和CV基准/数据集上,将ViT和BERT等基于Transformer的模型的整体设备端GPU内存使用量平均降低2.2倍,准确率平均下降0.2%。对于此类NLP和CV任务,SlimFit最多可将设备端总内存使用量降低3.1倍,而准确率下降最多仅为0.4%。因此,虽然以128的批量大小在ImageNet上微调ViT和在SQuAD 2.0上微调BERT分别需要3块和2块32GB GPU,但SlimFit能够在单个32GB GPU上完成它们的微调,且没有显著的准确率下降。

英文摘要:

Transformer-based models, such as BERT and ViT, have achieved state-of-the-art results across different natural language processing (NLP) and computer vision (CV) tasks. However, these models are extremely memory intensive during their fine-tuning process, making them difficult to deploy on GPUs with limited memory resources. To address this issue, we introduce a new tool called SlimFit that reduces the memory requirements of these models by dynamically analyzing their training dynamics and freezing less-contributory layers during fine-tuning. The layers to freeze are chosen using a runtime inter-layer scheduling algorithm. SlimFit adopts quantization and pruning for particular layers to balance the load of dynamic activations and to minimize the memory footprint of static activations, where static activations refer to those that cannot be discarded regardless of freezing. This allows SlimFit to freeze up to 95% of layers and reduce the overall on-device GPU memory usage of transformer-based models such as ViT and BERT by an average of 2.2x, across different NLP and CV benchmarks/datasets such as GLUE, SQuAD 2.0, CIFAR-10, CIFAR-100 and ImageNet with an average degradation of 0.2% in accuracy. For such NLP and CV tasks, SlimFit can reduce up to 3.1x the total on-device memory usage with an accuracy degradation of only up to 0.4%. As a result, while fine-tuning of ViT on ImageNet and BERT on SQuAD 2.0 with a batch size of 128 requires 3 and 2 32GB GPUs respectively, SlimFit enables their fine-tuning on a single 32GB GPU without any significant accuracy degradation.

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

↑