LookupFFN:让Transformer在CPU推理时计算量更低
LookupFFN: Making Transformers Compute-lite for CPU inference
AI总结:
针对CPU推理计算能力不足的问题,提出LookupFFN模块,将FFN核心运算转为内存查找以降低FLOP,在RoBERTa预训练中性能与原FFN相当,适配当前及未来硬件。
摘要:
如今GPU集群已是训练大型深度神经网络(DNN)模型的事实标准,但出于工作流便捷性、安全性和成本等多方面原因,业界许多领域都在研究CPU能否满足日常推理需求。然而GPU与CPU的计算能力差距十分悬殊。基于这些考量,我们研究了现代DNN架构中的核心模块——基于通用矩阵乘法(GEMM)的前馈网络(FFN),评估其可降低计算量(即浮点运算次数FLOP)的程度。具体而言,受近期利用局部敏感哈希(LSH)近似FFN的研究启发,我们提出了一种替代方案,命名为LookupFFN。该方案将大部分核心运算转化为内存查找,利用任意平台上计算与内存两种资源的权衡特性——毕竟CPU的内存资源十分充足。在RoBERTa语言模型预训练任务中,我们的方案与基于GEMM的FFN性能相当,同时大幅降低了所需的FLOP。我们还对可最大化效率的策略进行了详细的硬件性能分析,不仅适配当前硬件,也覆盖了近中期将推出的产品。代码可在https://github.com/mlpen/LookupFFN获取。
英文摘要:
While GPU clusters are the de facto choice for training large deep neural network (DNN) models today, several reasons including ease of workflow, security and cost have led to efforts investigating whether CPUs may be viable for inference in routine use in many sectors of the industry. But the imbalance between the compute capabilities of GPUs and CPUs is huge. Motivated by these considerations, we study a module which is a workhorse within modern DNN architectures, GEMM based Feed Forward Networks (FFNs), and assess the extent to which it can be made compute- (or FLOP-) lite. Specifically, we propose an alternative formulation (we call it LookupFFN) to GEMM based FFNs inspired by the recent studies of using Locality Sensitive Hashing (LSH) to approximate FFNs. Our formulation recasts most essential operations as a memory look-up, leveraging the trade-off between the two resources on any platform: compute and memory (since CPUs offer it in abundance). For RoBERTa language model pretraining, our formulation achieves similar performance compared to GEMM based FFNs, while dramatically reducing the required FLOP. Our development is complemented with a detailed hardware profiling of strategies that will maximize efficiency -- not just on contemporary hardware but on products that will be offered in the near/medium term future. Code is avaiable at \url{https://github.com/mlpen/LookupFFN}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。