[论文解读] On-Device Training Under 256KB Memory
该论文提出一种算法-系统协同设计,能够在仅有 256KB SRAM 和 1MB Flash 的微控制器上进行真实的 CNN 训练,使用 Quantization-Aware Scaling、Sparse Update 和 Tiny Training Engine,在保持精度的同时实现显著的内存和速度提升。
On-device training enables the model to adapt to new data collected from the sensors by fine-tuning a pre-trained model. Users can benefit from customized AI models without having to transfer the data to the cloud, protecting the privacy. However, the training memory consumption is prohibitive for IoT devices that have tiny memory resources. We propose an algorithm-system co-design framework to make on-device training possible with only 256KB of memory. On-device training faces two unique challenges: (1) the quantized graphs of neural networks are hard to optimize due to low bit-precision and the lack of normalization; (2) the limited hardware resource does not allow full back-propagation. To cope with the optimization difficulty, we propose Quantization-Aware Scaling to calibrate the gradient scales and stabilize 8-bit quantized training. To reduce the memory footprint, we propose Sparse Update to skip the gradient computation of less important layers and sub-tensors. The algorithm innovation is implemented by a lightweight training system, Tiny Training Engine, which prunes the backward computation graph to support sparse updates and offload the runtime auto-differentiation to compile time. Our framework is the first solution to enable tiny on-device training of convolutional neural networks under 256KB SRAM and 1MB Flash without auxiliary memory, using less than 1/1000 of the memory of PyTorch and TensorFlow while matching the accuracy on tinyML application VWW. Our study enables IoT devices not only to perform inference but also to continuously adapt to new data for on-device lifelong learning. A video demo can be found here: https://youtu.be/0pUFZYdoMY8.
研究动机与目标
- 在超小型边缘设备上实现端上训练,满足严格的内存预算(256KB SRAM)。
- 开发量化感知优化,使8位训练在不增加额外内存的情况下稳定。
- 通过稀疏梯度更新和自动化更新方案降低内存占用。
- 构建一个轻量级编译器驱动的训练系统,用于裁剪和重新排列反向图以提高效率。
- 在真实硬件上演示部署,并展示在 tinyML 任务中与云端训练相竞争的准确性。
提出的方法
- 直接更新真实的量化图(int8 前向/反向),以适应紧凑的内存预算。
- 量化感知缩放(QAS)自动缩放梯度,在不增加额外内存的情况下稳定8位训练。
- 稀疏更新基于贡献分析选择性地更新层/张量,以满足内存约束。
- 自动化贡献分析选择更新哪些偏置/权重以及以何种粒度更新。
- Tiny Training Engine (TTE) 使用代码生成来编译静态的反向图、裁剪未使用的节点,并使就地更新和算子融合成为可能。
- 图裁剪和算子重新排序降低峰值内存并加速微控制器上的训练。
实验结果
研究问题
- RQ1能否使在具备256KB SRAM和1MB Flash的设备上对CNN进行端上训练成为可行?
- RQ2QAS 是否在没有额外内存代价的情况下弥合 int8 训练与浮点训练之间的精度差距?
- RQ3稀疏更新和编译时图优化能否在维持迁移学习性能的同时满足严格的内存预算?
主要发现
- 相较于 PyTorch/TensorFlow,内存占用减少超过 1000 倍,使在 256KB SRAM 和 1MB Flash 上进行训练成为可能。
- QAS 使在多个数据集上,int8 的全量化训练达到与浮点训练相同的精度。
- 稀疏更新结合贡献分析在远低于更新所有层的内存条件下实现更高的下游精度。
- TTE 图生成与裁剪实现了 7-9x 的内存节省,以及通过算子重新排序带来 20-21x 的峰值内存降低。
- 在 Cortex M7 MCU(STM32F746)上的端上训练实现了有竞争力的精度(如 VWW 的 top-1 89.1%),并且每次迭代性能显著更快(比完整 TF-Lite Micro 风格更新快 23-25 倍)。
- 该框架使 tinyML 应用实现端上终身学习和隐私保护个性化成为可能。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。