SparseByteNN: A Novel Mobile Inference Acceleration Framework Based on Fine-Grained Group Sparsity

Haitao Xu, Songwei Liu, Yuyang Xu, Shuai Wang, Jiashi Li, Chenqian Yan, Liangqiang Li, Lean Fu, Xin Pan, Fangmin ChenarXiv 2023

Abstract

To address the challenge of increasing network size, researchers have developed sparse models through network pruning. However, maintaining model accuracy while achieving significant speedups on general computing devices remains an open problem. In this paper, we present a novel mobile inference acceleration framework SparseByteNN, which leverages fine-grained kernel sparsity to achieve real-time execution as well as high accuracy. Our framework consists of two parts: (a) A fine-grained kernel sparsity schema with a sparsity granularity between structured pruning and unstructured pruning. It designs multiple sparse patterns for different operators. Combined with our proposed whole network rearrangement strategy, the schema achieves a high compression rate and high precision at the same time. (b) Inference engine co-optimized with the sparse pattern. The conventional wisdom is that this reduction in theoretical FLOPs does not translate into real-world efficiency gains. We aim to correct this misconception by introducing a family of efficient sparse kernels for ARM and WebAssembly. Equipped with our efficient implementation of sparse primitives, we show that sparse versions of MobileNet-v1 outperform strong dense baselines on the efficiency-accuracy curve. Experimental results on Qualcomm 855 show that for 30% sparse MobileNet-v1, SparseByteNN achieves 1.27x speedup over the dense version and 1.29x speedup over the state-of-the-art sparse inference engine MNN with a slight accuracy drop of 0.224%.

Introduction

Deep learning models are increasingly deployed on mobile devices, yet their growing size poses significant challenges for resource-constrained hardware. While network pruning is a standard technique to reduce redundancy, it often falls into the "Pruning Paradox." Unstructured pruning, which removes individual weights, maintains high accuracy but creates irregular memory access patterns that general-purpose CPUs (like ARM) cannot accelerate. Conversely, structured pruning removes entire filters to ensure hardware friendliness but often results in substantial accuracy loss, particularly in lightweight architectures like MobileNet.

SparseByteNN resolves this by introducing Fine-Grained Kernel Group Pruning (FKGP). This approach identifies a "Goldilocks" granularity—structured enough for hardware acceleration via SIMD instructions, yet flexible enough to preserve model precision.

The SparseByteNN Framework

The SparseByteNN workflow is a comprehensive pipeline designed to bridge the gap between high-level training frameworks and efficient mobile execution. As shown in Figure 1, the process begins with standard training in frameworks like TensorFlow or PyTorch, followed by a critical "Network Rearrange" phase and iterative sparse fine-training. The resulting model is converted via ONNX into a format compatible with the ByteNN execution engine.

The SparseByteNN workflow from training to execution.

Methodology

Fine-Grained Kernel Group Pruning (FKGP)

The core innovation of SparseByteNN is its specialized pruning patterns tailored for different convolution types. Instead of arbitrary weight removal, the framework enforces specific structures:

  • Conv1x1 (Pointwise): Uses $4 \times 4$ connectivity blocks, matching the 128-bit vector length of ARM NEON instructions.
  • DwConv3x3 (Depthwise): Implements a 3:9 pattern, where only 3 out of 9 weights in a kernel are retained. This specific configuration allows the engine to reuse input data twice for every two output pixels, reducing memory bandwidth bottlenecks by 25%.
  • Conv3x3: Employs a 5:9 pattern group pruning strategy.
Visual representation of connectivity and pattern group pruning for different convolution types.

Whole Network Rearrangement

To minimize information loss during pruning, SparseByteNN reorders channels and filters across the entire network. By grouping high-magnitude, "important" weights into the same blocks, the framework ensures that pruned blocks contain primarily redundant information. This index change is mathematically propagated through the network graph to maintain functional consistency.

Co-optimized Inference Engine

The framework includes custom kernels written for ARM (NEON SIMD) and WebAssembly. These kernels are hand-optimized to handle the $4 \times 4$ and 3:9 patterns, utilizing up to 29 of the 32 available ARMv8 registers to minimize memory stalls and maximize throughput.

Experimental Results

Evaluation on standard benchmarks demonstrates the framework's efficacy:

  • MobileNet-v1 on Qualcomm 855: At 30% sparsity, SparseByteNN achieved a 1.27× speedup over the dense version and a 1.29× speedup over the state-of-the-art MNN engine, with a negligible accuracy drop of only 0.224%.
  • Depthwise Efficiency: Specific DwConv3x3 layers saw speedups of up to 49.6% at 33% sparsity.
  • WebAssembly: On a MacBook Pro running Chrome, the framework delivered speedups between 22.3% and 27.7%, proving its utility for web-based AI applications.

Conclusion

SparseByteNN demonstrates that fine-grained group sparsity is a viable path for accelerating mobile inference without sacrificing accuracy. By co-designing pruning patterns with hardware-aware kernels and network-wide weight rearrangement, the framework achieves significant real-world performance gains on commodity mobile hardware.

Summary updated

BibTeX
@misc{xu2023sparsebytenn,
  author = {Haitao Xu and Songwei Liu and Yuyang Xu and Shuai Wang and Jiashi Li and Chenqian Yan and Liangqiang Li and Lean Fu and Xin Pan and Fangmin Chen},
  title = {{SparseByteNN: A Novel Mobile Inference Acceleration Framework Based on Fine-Grained Group Sparsity}},
  year = {2023},
  eprint = {2310.19509},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.19509},
}
Figure