HADS: Hardware-Aware Deep Subnetworks

Francesco Corti, Balz Maag, Joachim Schauer, Ulrich Pferschy, Olga SaukhPML4LRS @ ICLR 2024

TL;DR

This paper introduces HADS, a novel approach for creating "deep subnetworks" that can dynamically adapt to changing resource constraints on edge devices. By cleverly structuring sparsity and using an iterative knapsack optimizer, HADS allows models to efficiently switch between different computational configurations with minimal overhead, achieving good accuracy and very fast adaptation times.

What Problem Does This Paper Address?

Edge devices, like microcontrollers and mobile phones, are increasingly running deep learning models for tasks such as image recognition and speech processing. However, these devices have limited resources (CPU, memory, energy) that can fluctuate based on the environment or other running tasks. Traditional methods for making models smaller (like pruning and quantization) are often applied at compile time, resulting in a single, static model that is resource-agnostic. This means the model can't adapt its computational needs on the fly. A naive solution of storing multiple models for different resource levels is memory-intensive and incurs overhead when switching. HADS aims to solve this by enabling a single model to efficiently reconfigure itself to match available resources.

Methods

HADS tackles this challenge by creating a set of nested subnetworks within a single model. The core idea is to leverage structured sparsity, meaning that entire neurons or filters are removed, rather than individual weights. This is made possible by exploiting the permutation invariance of neurons in neural networks, which allows reordering neurons without affecting the network's function. This reordering is crucial for maintaining contiguous memory layouts for the active subnetworks, which is beneficial for hardware and cache optimization.

The process of determining which parts of the network to "slice" (i.e., which neurons/filters to keep active for a given subnetwork) is formulated as an iterative knapsack problem. This problem is solved using two heuristic algorithms: a bottom-up (BU) approach and a top-down (TD) approach. The knapsack formulation considers the importance of each computational unit (approximated by gradient information) and its computational cost (measured in MACs, Multiply-Accumulate operations). The goal is to select units that maximize importance while staying within a given computational budget (MACs).

A key innovation is the use of an iterative knapsack optimizer. This means that for a set of k subnetworks, the problem is solved iteratively. The items (computational units) selected for a smaller subnetwork are guaranteed to be included in larger subnetworks. This ensures a nested structure where child subnetworks are always a subset of their parent. The paper also provides theoretical analysis for the BU and TD heuristics, showing that the BU approach offers a better worst-case solution.

Datasets

HADS was evaluated on the following datasets:

  • Google Speech Commands: Used for training and evaluating speech recognition models.
  • FMNIST (Fashion-MNIST): Used for evaluating image classification models.
  • CIFAR10: Used for evaluating image classification models.

The paper also mentions testing on four off-the-shelf mobile and embedded hardware platforms, but specific datasets for these tests are not detailed beyond the general benchmark architectures.

Key Insights and Ideas

  • Structured Sparsity for Hardware Efficiency: By slicing entire neurons/filters, HADS maintains dense matrix operations within subnetworks. This is more hardware-friendly than unstructured sparsity, which can lead to irregular memory access patterns.
  • Permutation Invariance as a Tool: Exploiting the fact that neuron order doesn't change network function is a clever way to enable contiguous memory layouts for subnetworks, simplifying storage and adaptation.
  • Iterative Knapsack for Nested Subnetworks: Formulating the subnetwork selection as an iterative knapsack problem elegantly ensures that smaller subnetworks are always contained within larger ones, creating a hierarchical structure.
  • MACs as a Robust Latency Predictor: The paper empirically validates that MACs are a reliable predictor of inference latency across different devices, reinforcing its use in resource-aware optimization.
  • Minimal Adaptation Overhead: The ability to switch between subnetworks by simply updating layer widths, with adaptation times as low as 40µs, is a significant practical advantage for real-time applications.

Key Results

  • Accuracy: HADS demonstrates outstanding performance in terms of submodel test set accuracy, often outperforming baselines that prune an equal share of computational blocks.
  • Adaptation Time: On an Arduino Nano 33 BLE Sense, a 2-layer fully-connected network achieved an adaptation time of under 40µs.
  • Efficiency: HADS models provide computational benefits even for small networks. The paper shows that HADS knapsack solutions outperform pruning baselines in achieving higher accuracy for the same percentage of MACs.
  • Device Performance: The paper presents results on various devices (Xiaomi Redmi Note 9 Pro, Google Pixel 6, Arduino Nano 33 BLE Sense, Infineon CY8CKIT-062S2), showing a clear trade-off between model size (MACs), accuracy, and inference time, with HADS effectively navigating this trade-off.

Limitations and Future Work

  • Skip Connections: Currently, HADS does not support skip connections, which are common in advanced architectures like MobileNet v2. The authors expect this limitation to be addressed in future research.
  • Generalization to Other Architectures: While the paper focuses on fully-connected and standard convolutional architectures, the appendix discusses a generalization for depthwise-convolution architectures. Further exploration of HADS' applicability to a wider range of complex neural network architectures would be valuable.
  • Real-world Deployment: While tested on mobile and IoT devices, further investigation into the practical deployment challenges and benefits in diverse real-world scenarios would be beneficial.

Summary updated

BibTeX
@inproceedings{corti2024hads,
  author = {Francesco Corti and Balz Maag and Joachim Schauer and Ulrich Pferschy and Olga Saukh},
  title = {{HADS: Hardware-Aware Deep Subnetworks}},
  booktitle = {PML4LRS @ ICLR},
  year = {2024},
  url = {https://openreview.net/forum?id=oDacwa4yb2},
}
Figure