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

利用 2:4 稀疏性加速 Transformer 预训练

Accelerating Transformer Pre-training with 2:4 Sparsity

Tsinghua University(清华大学)

Yuezhou Hu, Kang Zhao, Weiyu Huang, Jianfei Chen, Jun Zhu

AI总结:

本文针对 Transformer 预训练中的 FFN,提出基于 2:4 稀疏性的稳定训练与实际加速技术,在保持稠密训练收敛性的同时获得显著加速。

摘要:

训练大型 transformer 速度缓慢,但近期 GPU 架构的创新为我们带来了优势。NVIDIA Ampere GPU 执行细粒度 2:4 稀疏矩阵乘法的速度可达其稠密等价形式的两倍。鉴于这一特性,我们全面研究了在预训练中加速 transformer 前馈网络(FFN)的可行性。首先,我们定义“翻转率”来监控 2:4 训练过程的稳定性。利用该指标,我们提出三种保持准确率的技术:通过在梯度上应用掩码衰减项来改进稀疏细化的直通估计器;在预热阶段确定可行的衰减因子;以及在预训练接近尾声时通过稠密微调过程提升模型质量。此外,我们设计了两种切实加速训练的技术:通过卷积计算可转置的 2:4 掩码,以及通过减少 GPU L2 缓存未命中来加速门控激活函数。实验表明,我们的 2:4 稀疏训练算法在多个 transformer 预训练任务上取得了与稠密训练算法相似的收敛性,同时在不同形状的 transformer 块上都能观察到明显的实际加速。我们的工具包可在 https://github.com/huyz2023/2by4-pretrain 获取。

英文摘要:

Training large transformers is slow, but recent innovations on GPU architecture give us an advantage. NVIDIA Ampere GPUs can execute a fine-grained 2:4 sparse matrix multiplication twice as fast as its dense equivalent. In the light of this property, we comprehensively investigate the feasibility of accelerating feed-forward networks (FFNs) of transformers in pre-training. First, we define a ``flip rate'' to monitor the stability of a 2:4 training process. Utilizing this metric, we propose three techniques to preserve accuracy: to modify the sparse-refined straight-through estimator by applying the masked decay term on gradients, to determine a feasible decay factor in warm-up stage, and to enhance the model's quality by a dense fine-tuning procedure near the end of pre-training. Besides, we devise two techniques to practically accelerate training: to calculate transposable 2:4 masks by convolution, and to accelerate gated activation functions by reducing GPU L2 cache miss. Experiments show that our 2:4 sparse training algorithm achieves similar convergence to dense training algorithms on several transformer pre-training tasks, while actual acceleration can be observed on different shapes of transformer block apparently. Our toolkit is available at https://github.com/huyz2023/2by4-pretrain.

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

↑