[论文解读] Larq Compute Engine: Design, Benchmark, and Deploy State-of-the-Art Binarized Neural Networks
Larq Compute Engine (LCE) 是一种针对二值化神经网络(BNNs)的高度优化的推理引擎,可在移动设备上实现最先进性能。通过与 TensorFlow 和 TensorFlow Lite 集成,LCE 在 Pixel 1 手机上将二值卷积加速了 8.5–18.5 倍,并支持从训练到部署的端到端流程,从而推动开发出 QuickNet——一种简单且高精度的 BNN,其在 ImageNet 上的延迟和精度表现优于现有模型。
We introduce Larq Compute Engine, the world's fastest Binarized Neural Network (BNN) inference engine, and use this framework to investigate several important questions about the efficiency of BNNs and to design a new state-of-the-art BNN architecture. LCE provides highly optimized implementations of binary operations and accelerates binary convolutions by 8.5 - 18.5x compared to their full-precision counterparts on Pixel 1 phones. LCE's integration with Larq and a sophisticated MLIR-based converter allow users to move smoothly from training to deployment. By extending TensorFlow and TensorFlow Lite, LCE supports models which combine binary and full-precision layers, and can be easily integrated into existing applications. Using LCE, we analyze the performance of existing BNN computer vision architectures and develop QuickNet, a simple, easy-to-reproduce BNN that outperforms existing binary networks in terms of latency and accuracy on ImageNet. Furthermore, we investigate the impact of full-precision shortcuts and the relationship between number of MACs and model latency. We are convinced that empirical performance should drive BNN architecture design and hope this work will facilitate others to design, benchmark and deploy binary models.
研究动机与目标
- 解决边缘设备上 Binarized Neural Networks (BNNs) 在训练、基准测试和部署方面缺乏集成且高性能软件工具的问题。
- 通过提供高度优化、手工调优的二值运算,克服现有 BNN 框架中推理速度慢的实际障碍,以提升移动端推理性能。
- 使研究人员和开发者能够无缝地使用熟悉的 TensorFlow 和 TensorFlow Lite 生态系统来设计、训练和部署 BNNs。
- 通过实证方法识别 BNN 架构中的性能瓶颈,并评估架构选择(如全精度残差连接和 MAC 数量与延迟的相关性)在实际应用中的影响。
- 开发一种新型、简单且可复现的 BNN 架构——QuickNet,通过单阶段训练过程在 ImageNet 上实现最先进的精度和延迟表现。
提出的方法
- 利用 TensorFlow 和 TensorFlow Lite 构建 BNN 的全栈推理流水线,包括基于 MLIR 的图转换器,可将训练好的模型映射为优化后的推理图。
- 引入高度优化、手工调优的 BGEMM(二值 GEMM)内核,通过使用 XOR 和 POPCOUNT 操作加速二值卷积,在 Pixel 1 手机上实现 8.5–18.5 倍的加速。
- 通过支持混合精度模型,使单个模型中可共存二值和全精度层,并实现自动位打包和精度管理。
- 使用复杂的转换器,将训练期间使用的模拟二值操作在推理时转换为真正的二值操作,从而确保功能保真度和性能。
- 采用面向硬件的设计方法,针对 64 位 ARM 设备(包括 Pixel 1 手机和 Raspberry Pi 4)进行优化,确保实际性能的相关性。
- 在真实设备上进行实证基准测试,评估不同 BNN 架构和设计选择下的延迟、精度和 MAC 效率。
实验结果
研究问题
- RQ1现有 BNN 架构中的主要延迟瓶颈是什么,特别是与全精度组件的关系如何?
- RQ2不同类型的残差连接(如全精度与二值)对 BNN 推理延迟和精度有何影响?
- RQ3在不同 BNN 架构之间比较时,乘加操作数(MACs)与实际推理延迟的相关性有多大?
- RQ4是否可以通过一种简单、单阶段训练方法,构建出在精度和延迟方面均优于复杂多阶段方法的 BNN 架构?
- RQ5如何设计软件工具链,以弥合全精度模型与二值化模型在可用性和性能方面的差距?
主要发现
- 与全精度实现相比,Larq Compute Engine 在 Pixel 1 手机上将二值卷积加速了 8.5 倍至 18.5 倍,通过优化的 BGEMM 内核显著提升了性能。
- QuickNet 是一种采用单阶段训练流程的简单 BNN,其在 ImageNet 上实现了最先进的精度和延迟表现,尽管结构简单,但仍优于现有二值化神经网络。
- 全精度残差连接虽然带来微小的延迟开销,但能显著提升精度,因此在 BNN 设计中具有充分合理性。
- 当比较根本不同的 BNN 架构时,MAC 数量无法准确预测实际延迟,例如 BinaryAlexNet 的延迟接近于 MAC 数相近的其他模型的两倍。
- 在真实设备上的实证基准测试表明,如层精度和操作布局等架构选择对延迟有显著影响,凸显了面向硬件设计的重要性,而非仅依赖理论指标。
- LCE 与 Larq 及 TensorFlow Lite 的集成,实现了 BNN 开发的无缝端到端流程,显著降低了研究人员和实践者的技术门槛。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。