TL;DR
LegoDNN introduces a block-grained scaling framework that optimizes multi-DNN workloads on resource-constrained mobile devices by breaking networks into modular blocks and training compressed variants independently. This approach expands the available model configuration space by up to five orders of magnitude while drastically reducing offline training time and runtime switching energy.
What Problem Does This Paper Address?
Mobile vision applications frequently run multiple Deep Neural Networks (DNNs) simultaneously (e.g., concurrent object detection and image classification). However, mobile devices operate under strict, highly dynamic constraints regarding memory, latency, and battery consumption.
To adapt to these fluctuations, existing methods rely on model-grained scaling (like filter pruning or low-rank decomposition) to create smaller "descendant" models offline. This strategy suffers from two major bottlenecks:
- Combinatorial Explosion in Training: Retraining dozens of full-model variants to cover a wide range of resource budgets takes weeks or months of GPU time. As a result, developers only train a few coarse-grained models, leaving significant amounts of mobile memory and compute unutilized.
- High Runtime Overhead: Switching between full models at runtime requires heavy page-in and page-out operations, causing severe latency spikes and draining battery power.
LegoDNN addresses these challenges by shifting the granularity of scaling from the entire model down to individual structural blocks.
Methods
LegoDNN splits its workflow into an offline phase for block generation and an online phase for dynamic scaling.
Offline Stage: Block Generation, Re-training, and Profiling
- Block Extraction: LegoDNN automatically identifies repeating structural patterns (like ResBlocks in ResNet or dense blocks in VGG) that consume the bulk of the network's compute and memory.
- Localized Training Environments: Instead of pruning and retraining the entire network, LegoDNN isolates each block. It creates a localized training environment by caching the intermediate input and output feature maps of the original block.
- Independent Block Retraining: Descendant blocks of varying sparsities are trained independently using the original block as a teacher. Because it avoids end-to-end backpropagation through the whole network, training is incredibly fast and can run in parallel.
- Profiling: Each block variant is profiled on the target mobile hardware to map its accuracy loss, memory footprint, and latency reduction percentage.
Online Stage: Dynamic Scaling
- Scaling Optimizer: When available system resources change, LegoDNN models the block selection as an Integer Linear Programming (ILP) problem. It searches the massive combinatorial space to find the exact mix-and-match combination of block variants across all running DNNs that maximizes overall accuracy under current latency and memory constraints.
- Block Exchanger: Instead of swapping out the entire network, the runtime system replaces only the specific blocks chosen by the optimizer. Because the input/output channels remain compatible, blocks can be hot-swapped directly in memory without extra reconstruction overhead.
Datasets
The authors evaluated LegoDNN using standard computer vision datasets across 12 popular DNN models:
- Cifar-10 & Cifar-100: Used for standard and progressive image recognition tasks.
- ImageNet2012: Used to evaluate large-scale, complex image classification.
- COCO2017: Used for real-time object detection tasks (via YOLOv3).
While no new datasets were introduced, the authors developed a dedicated multi-DNN benchmark that dynamically spawns and kills vision tasks on real mobile hardware to simulate realistic, fluctuating workloads.
Key Insights and Ideas
- Decoupling Breaks the Bottleneck: The core "aha moment" is that blocks can be treated as independent black boxes during training. Caching intermediate data allows the framework to bypass full-network training, turning a months-long training process into a matter of hours.
- Combinatorial Abundance: By transforming just 5 to 8 original blocks into 5 variants each, LegoDNN generates between $5^5$ (3,125) and $5^8$ (390,625) unique model size options for free.
- Granular Resource Packing: Coarse scaling forces systems to leave hardware resources idle if the next available model size is too large. Finer block-grained scaling allows the system to "fill the gaps," maximizing hardware utilization.
- Approximation vs. Skipping: Unlike FLOP-skipping methods (e.g., BlockDrop) which completely bypass layers and degrade accuracy, LegoDNN retains the network's depth but substitutes blocks with highly optimized, compact approximations.
Key Results
- Massive Configuration Space: LegoDNN provided 1,296x to 279,936x more options in model sizes compared to traditional model-grained baselines.
- Reduced Training Overhead: The massive configuration space was achieved while using only 24% of the offline model generation time required by baselines.
- Accuracy Improvements: Under identical resource budgets, LegoDNN achieved up to a 31.74% average improvement in inference accuracy. In highly restricted memory environments (<30MB), accuracy improved by 52.66%.
- Energy Efficiency: By avoiding full-model swaps, LegoDNN reduced runtime model-switching energy consumptions by 71.07% overall (and up to 78.42% on smartphones).
Limitations and Future Work
- Pruning Dependencies: LegoDNN relies on the ability to prune filters within a block. In extreme architectures where layers cannot be pruned (e.g., group convolutions restricted to a single channel, map, and filter), the framework cannot generate descendant blocks.
- Future Work: The authors plan to explore block-level retraining within a federated learning framework. This would allow descendant blocks to collaboratively learn across multiple distributed devices, enhancing both accuracy and generalization without centralizing private data.
Summary updated