HLSTransform: Energy-Efficient Llama 2 Inference on FPGAs Via High Level Synthesis

📄 arXiv: 2405.00738v1 📥 PDF

作者: Andy He, Darren Key, Mason Bulling, Andrew Chang, Skyler Shapiro, Everett Lee

分类: cs.AR, cs.AI, cs.LG

发布日期: 2024-04-29

备注: 7 pages, 2 figures

🔗 代码/项目: GITHUB


💡 一句话要点

提出HLSTransform以实现FPGA上Llama 2的高效推理

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: FPGA加速器 高层次综合 Llama 2 能效推理 深度学习 边缘计算 开源技术

📋 核心要点

  1. 现有的GPU加速器在深度学习推理中能耗高,限制了其在边缘计算中的应用。
  2. 本文提出HLSTransform,通过高层次综合技术在FPGA上实现Llama 2的高效推理,显著降低能耗。
  3. 实验结果表明,HLSTransform在能耗和推理速度上均优于传统的CPU和GPU,具有显著的性能提升。

📝 摘要(中文)

随着深度学习应用的普及,图形处理单元(GPU)成为主要的硬件加速器,但其高能耗问题引发了环境和经济上的担忧。本文提出了一种基于高层次综合(HLS)的FPGA加速器HLSTransform,专门用于开源的Llama 2大型语言模型(LLM)。通过HLS,我们能够快速原型化FPGA设计,实验结果显示,与Intel Xeon CPU和NVIDIA RTX 3090 GPU相比,能耗分别降低了12.75倍和8.25倍,同时推理速度提升了2.46倍。我们开源了代码,旨在推动FPGA在变换器推理中的应用,并激励更广泛的节能推理方法研究。

🔬 方法详解

问题定义:现有的GPU加速器在深度学习推理中能耗高,导致环境影响和高运营成本,限制了其在边缘计算中的应用。

核心思路:本文提出HLSTransform,通过高层次综合(HLS)技术在FPGA上实现Llama 2的高效推理,旨在降低能耗并提高推理速度。HLS允许快速原型化FPGA设计,避免了低级RTL编码的复杂性。

技术框架:整体架构包括高层次综合设计流程,首先进行模型分析,然后生成FPGA设计,最后进行综合和验证。主要模块包括数据预处理、模型推理和结果输出。

关键创新:HLSTransform的核心创新在于利用HLS技术实现FPGA上的高效推理,显著降低能耗并提升速度。这与传统的GPU推理方法形成鲜明对比,后者通常能耗较高且不适合边缘计算。

关键设计:在设计中,采用了优化的参数设置和网络结构,确保在FPGA上实现最佳性能。具体细节包括数据流优化和并行处理策略,以提高推理效率。实验中还使用了特定的损失函数来优化模型性能。

📊 实验亮点

实验结果显示,HLSTransform在Xilinx Virtex UltraScale+ VU9P FPGA上实现了与Intel Xeon CPU相比能耗降低12.75倍,与NVIDIA RTX 3090 GPU相比能耗降低8.25倍,同时推理速度提升至CPU的2.46倍,且保持了RTX 3090 GPU的53%速度,尽管后者的基准时钟频率高出4倍。

🎯 应用场景

该研究的潜在应用领域包括边缘计算、物联网设备和移动设备等对能效要求高的场景。通过降低能耗,HLSTransform能够使得大型语言模型在资源受限的环境中得以应用,推动智能设备的普及与发展。

📄 摘要(原文)

Graphics Processing Units (GPUs) have become the leading hardware accelerator for deep learning applications and are used widely in training and inference of transformers; transformers have achieved state-of-the-art performance in many areas of machine learning and are especially used in most modern Large Language Models (LLMs). However, GPUs require large amounts of energy, which poses environmental concerns, demands high operational costs, and causes GPUs to be unsuitable for edge computing. We develop an accelerator for transformers, namely, Llama 2, an open-source state-of-the-art LLM, using high level synthesis (HLS) on Field Programmable Gate Arrays (FPGAs). HLS allows us to rapidly prototype FPGA designs without writing code at the register-transfer level (RTL). We name our method HLSTransform, and the FPGA designs we synthesize with HLS achieve up to a 12.75x reduction and 8.25x reduction in energy used per token on the Xilinx Virtex UltraScale+ VU9P FPGA compared to an Intel Xeon Broadwell E5-2686 v4 CPU and NVIDIA RTX 3090 GPU respectively, while increasing inference speeds by up to 2.46x compared to CPU and maintaining 0.53x the speed of an RTX 3090 GPU despite the GPU's 4 times higher base clock rate. With the lack of existing open-source FPGA accelerators for transformers, we open-source our code and document our steps for synthesis. We hope this work will serve as a step in democratizing the use of FPGAs in transformer inference and inspire research into energy-efficient inference methods as a whole. The code can be found on https://github.com/HLSTransform/submission.