Improving Efficiency in Neural Network Accelerator using Operands Hamming Distance Optimization

Meng Li, Yilei Li, Vikas Chandra

TL;DR

This paper tackles the significant energy consumption of neural network accelerators, specifically focusing on the datapath energy. They discover that this energy is directly correlated with "bit flips" when data is moved, which they quantify using Hamming Distance. By proposing novel post-training and training-aware optimization techniques to minimize this Hamming Distance, they achieve substantial datapath energy reductions, up to 8.51x for certain layers.

What Problem Does This Paper Address?

Modern AI inference, especially on edge devices, relies heavily on energy-efficient neural network accelerators. A major contributor to the energy budget of these accelerators is the "datapath energy," which encompasses both the energy used for computations and the energy spent moving data between arithmetic units. While previous work has focused on reducing the number of operations or the precision of data (quantization), the energy associated with data movement itself, particularly the switching activity within logic circuits, has been less explored. This paper identifies that the way data operands are streamed into the arithmetic units significantly impacts this datapath energy, and proposes a method to optimize this streaming process.

Methods

The core of the paper's contribution lies in identifying and exploiting the relationship between datapath energy and the Hamming Distance of operand sequences.

  • Hamming Distance as a Proxy for Bit Flips: The authors establish that the energy consumed by datapath logic is strongly correlated with the number of bit flips occurring when operands are transferred. They define this bit flip phenomenon using the Hamming Distance between binary strings.
  • Post-Training Optimization:
    • Output Channel Reordering: This technique aims to reorder the sequence of output channels to minimize the Hamming Distance of the weight matrices. It's framed as a Traveling Salesman Problem (TSP) and solved using a greedy algorithm.
  • Input Channel Segmentation and Clustering: To further improve reordering effectiveness, they propose segmenting the weight matrix along input channels and applying reordering to these segments. They also introduce a "cluster-then-reorder" approach to group input channels, which can yield better results, especially for layers with many input channels.
  • Hamming Distance-Aware Training: This method incorporates a Hamming Distance loss term into the standard cross-entropy loss during neural network training. This encourages the network to learn weights that result in lower Hamming Distances. They address the non-differentiability of the Hamming Distance calculation using a straight-through estimator and an iterative freeze-and-regularize procedure to handle all bits of the weights.

Datasets

The paper uses the following datasets for training and evaluation:

  • Cifar10
  • Cifar100

The models evaluated are MobileNetV2 and ResNet26.

Key Insights and Ideas

  • Bit Flips are the Culprit: The most significant insight is the direct correlation between datapath energy consumption and the number of bit flips when operands are streamed. This shifts focus from just computation to data movement dynamics.
  • Hamming Distance as an Optimization Target: Quantifying bit flips using Hamming Distance provides a concrete metric for optimization, allowing for the development of targeted algorithms.
  • Co-design of Network and Accelerator: The paper demonstrates that optimizing the neural network's weights (through training or post-processing) can directly benefit the energy efficiency of the accelerator hardware, highlighting the value of co-design.
  • Reordering is Effective, but Needs Nuance: While simple reordering of output channels helps, the paper shows that more sophisticated methods like segmentation and clustering of input channels can further enhance the Hamming Distance reduction.
  • Training-Aware Optimization is Crucial: Post-training optimization is effective, but integrating Hamming Distance minimization directly into the training process yields even greater benefits, especially when combined with post-training methods.

Key Results

The paper reports significant energy savings through their proposed methods:

  • Post-Training Optimization:
    • The "cluster-then-reorder" algorithm achieved an average datapath energy reduction of 1.62x for MobileNetV2 and 1.49x for ResNet26 compared to baseline.
  • They also show that the cluster-then-reorder algorithm can outperform the segment-then-reorder algorithm by up to 1.21x.
  • Training-Aware Optimization:
    • On Cifar10, an average Hamming Distance reduction of 7.55x led to a 6.63x reduction in average energy consumption.
  • On Cifar100, average Hamming Distance reduction was 2.00x, resulting in 1.86x average energy reduction.
  • Combined Optimization:
    • The combination of training-aware and post-training optimization achieved an average datapath energy reduction of 2.85x and up to 8.51x reduction for certain layers on MobileNetV2.

Limitations and Future Work

  • Hardware Support: While the paper discusses hardware support for reordering, the direct reordering method requires no extra hardware. However, segment-then-reorder and cluster-then-reorder require an output address lookup table (LUT), which they argue has negligible overhead.
  • Complexity of Optimal Solution: The optimal output channel reordering problem is computationally expensive (akin to TSP). The paper proposes greedy algorithms to address this, which are efficient but not guaranteed to find the absolute global optimum.
  • Trade-off in Training: The Hamming Distance-aware training involves a trade-off between accuracy and energy reduction, controlled by a regularization coefficient (λ). The paper demonstrates that significant energy reduction can be achieved with minimal accuracy degradation.
  • Future Work: The paper suggests that their techniques are compatible with other optimization methods like pruning and quantization, implying further potential for combined optimizations. The iterative freeze-and-regularize procedure for training-aware optimization could be further explored for different bit widths and network architectures.

Summary updated

BibTeX
@inproceedings{li2021improving,
  author = {Meng Li and Yilei Li and Vikas Chandra},
  title = {{Improving Efficiency in Neural Network Accelerator using Operands Hamming Distance Optimization}},
  booktitle = {ASP-DAC},
  year = {2021},
  doi = {10.1145/3394885.3446242},
}
Figure