[论文解读] Alternating Multi-bit Quantization for Recurrent Neural Networks
该论文提出用于 RNN 的交替多比特量化,将权重和激活量化为多比特二进制码,从而在最小准确度损失下实现显著的内存节省和 CPU 推理加速。它在 LSTM/GRU 上展示 2-bit 和 3-bit 量化,相对于现有方法有显著改进,并扩展到图像分类。
Recurrent neural networks have achieved excellent performance in many applications. However, on portable devices with limited resources, the models are often too large to deploy. For applications on the server with large scale concurrent requests, the latency during inference can also be very critical for costly computing resources. In this work, we address these problems by quantizing the network, both weights and activations, into multiple binary codes {-1,+1}. We formulate the quantization as an optimization problem. Under the key observation that once the quantization coefficients are fixed the binary codes can be derived efficiently by binary search tree, alternating minimization is then applied. We test the quantization for two well-known RNNs, i.e., long short term memory (LSTM) and gated recurrent unit (GRU), on the language models. Compared with the full-precision counter part, by 2-bit quantization we can achieve ~16x memory saving and ~6x real inference acceleration on CPUs, with only a reasonable loss in the accuracy. By 3-bit quantization, we can achieve almost no loss in the accuracy or even surpass the original model, with ~10.5x memory saving and ~3x real inference acceleration. Both results beat the exiting quantization works with large margins. We extend our alternating quantization to image classification tasks. In both RNNs and feedforward neural networks, the method also achieves excellent performance.
研究动机与目标
- 降低可部署在资源受限设备和支持高并发服务器上的循环神经网络的内存占用和延迟。
- 使用一个有原则性的优化方法,将权重和激活量化为多比特二进制码。
- 证明交替最小化在降低计算开销的同时实现高精度量化,并在各任务上具有竞争力的准确率。
- 展示在 LSTM 和 GRU 语言模型上的有效性,并扩展到图像分类任务。
提出的方法
- 将多比特量化形式化为一个使用二进制码 {-1,+1} 的优化问题,并学习系数和码字。
- 发现一旦量化系数被固定,二进制码字就可以通过二叉搜索树 (BST) 高效推导。
- 采用交替最小化:固定系数以优化码字,然后固定码字以优化系数;在实践中使用贪婪初始化和两轮交替循环。
- 在 RNN 中按行对权重进行量化,并在推理期间对激活进行在线量化。
- 在 CPU 上实现二进制乘法内核,并通过连接二进制码以实现高效的矩阵-向量乘积来利用并行性。
- 使用直通估计(straight-through)来估计梯度,在双层优化设置中进行训练,并应用裁剪以将权重保持在 [-1,1]。
实验结果
研究问题
- RQ1交替多比特量化能否缩小量化 RNN 与全精度 RNN 在语言建模任务上的性能差距?
- RQ22-bit 和 3-bit 量化在 PTB、WikiText-2、Text8 数据集上对 LSTM/GRU 的内存、速度和困惑度的影响如何?
- RQ3该方法是否能推广到超出 RNN 的图像分类任务?
- RQ4在 CPU 硬件上的计算权衡和实际加速增益有哪些?
主要发现
- 2-bit 量化在 LSTM/GRU 语言模型上达到约 16x 内存节省和约 6x CPU 推理加速,同时有可接受的准确性损失。
- 3-bit 量化几乎不损失准确性(在某些情况下甚至提升),约 10.5x 内存节省和 ~3x 加速。
- 交替量化在 PTB、WikiText-2、Text8 数据集上持续优于先前的多比特方法(Uniform、Balanced、Greedy、Refined)。
- 将权重按行量化并进行在线激活量化,使在 CPU 硬件上实现实际加速成为可能。
- 该方法在图像分类任务上也取得了有利结果,表明该方法不仅限于 RNN 的普适性。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。