[论文解读] FlexLLM: Composable HLS Library for Flexible Hybrid LLM Accelerator Design
FlexLLM 提供一个可组合的高层次综合库,支持阶段定制的混合 LLM 加速器,具备全面量化和分层内存 Transformer 插件,实现了 Llama-3.2 1B 在 FPGA 与 GPU 之间的显著加速与能效提升。
We present FlexLLM, a composable High-Level Synthesis (HLS) library for rapid development of domain-specific LLM accelerators. FlexLLM exposes key architectural degrees of freedom for stage-customized inference, enabling hybrid designs that tailor temporal reuse and spatial dataflow differently for prefill and decode, and provides a comprehensive quantization suite to support accurate low-bit deployment. Using FlexLLM, we build a complete inference system for the Llama-3.2 1B model in under two months with only 1K lines of code. The system includes: (1) a stage-customized accelerator with hardware-efficient quantization (12.68 WikiText-2 PPL) surpassing SpinQuant baseline, and (2) a Hierarchical Memory Transformer (HMT) plug-in for efficient long-context processing. On the AMD U280 FPGA at 16nm, the accelerator achieves 1.29$ imes$ end-to-end speedup, 1.64$ imes$ higher decode throughput, and 3.14$ imes$ better energy efficiency than an NVIDIA A100 GPU (7nm) running BF16 inference; projected results on the V80 FPGA at 7nm reach 4.71$ imes$, 6.55$ imes$, and 4.13$ imes$, respectively. In long-context scenarios, integrating the HMT plug-in reduces prefill latency by 23.23$ imes$ and extends the context window by 64$ imes$, delivering 1.10$ imes$/4.86$ imes$ lower end-to-end latency and 5.21$ imes$/6.27$ imes$ higher energy efficiency on the U280/V80 compared to the A100 baseline. FlexLLM thus bridges algorithmic innovation in LLM inference and high-performance accelerators with minimal manual effort.
研究动机与目标
- 解决 LLM 推理中 prefilling 与 decode 的计算与内存需求差异。
- 提供一个可编程、可组合的 HLS 框架,以实现阶段定制的混合架构。
- 整合全面的量化栈,使 FPGA/ASIC 上实现低位部署时仍保留模型精度。
- 展示以极少代码(≤1K 行)实现模型到硅的快速周转,以用于 LLM 加速器。
提出的方法
- 在 prefilling 阶段引入面向 token_parallelism 与 weight_parallelism 的 2D/1D 体汇架构框架内的阶段定制模块模板。
- 整合支持静态/动态、对称/非对称、逐张量/逐通道粒度,以及异常值处理(旋转、FHT)的全面量化库。
- 提供一组模板化内核模块(线性、非线性、量化/反量化)以及基于 TAPA HLS 框架的可组合工作流。
- 通过将时间复用和空间数据流模块组合来演示混合加速器构建,并在硬件约束下进行 ILP 驱动的优化。
- 集成分层内存 Transformer(HMT)插件,以压缩长上下文处理并实现可扩展的上下文窗口。
实验结果
研究问题
- RQ1阶段定制的混合体系结构能否在 LLM 推理的 prefilling 与 decoding 上优于统一设计?
- RQ2哪些量化策略能够在 FPGA 上实现准确且硬件高效的 LLM 推理,同时保持模型质量?
- RQ3使用 FlexLLM 实现特定模型加速器的速度(在代码行数和周转时间方面)有多快?
- RQ4引入 HMT 插件对长上下文 LLM 工作负载的延迟、上下文长度和能效有何影响?
主要发现
- 在 Llama-3.2 1B 上,FPGA 实现相对于 A100 BF16 基线在 U280 上端到端加速 1.29×,在 Versal V80 上实现 4.71×。
- 解码吞吐在 U280 上比 GPU 基线高 1.64×,在 V80 上高 6.55×。
- 相对于 A100 基线,能效提升 3.14×(U280)和 4.13×(V80)。
- 带有长上下文处理的 HMT 将 prefilling 延迟降低约 23.23×,上下文窗口扩大 64×,端到端延迟在 U280 降低 1.10×、在 V80 降低 4.86×,能效提高 5.21×(U280)和 6.27×(V80)。
- 在长解码下,HMT 增加的资源和延迟开销很小(<7.5% 资源、<0.6% 延迟),但为长上下文工作负载提供可扩展上下文。
- 阶段定制的架构结合量化可在与 GPU 基线相竞争的性能下,保持较低的每 token 能耗。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。