A Theory of I/O-Efficient Sparse Neural Network Inference

Niels Gleinig, Tal Ben-Nun, Torsten HoeflerarXiv 2023 · DOI

Introduction

Sparse neural networks are increasingly favored for their computational efficiency. However, on modern hardware, the primary bottleneck is often not floating-point operations (FLOPs) but data movement (I/O) between slow DRAM and fast cache memory. For instance, on an NVIDIA V100, loading a value from global memory can take over 500 times longer than a single math operation. While dense networks have predictable access patterns, the unstructured nature of sparse networks often leads to inefficient "layer-by-layer" execution, forcing hardware to repeatedly evict and reload neuron values. This paper introduces a rigorous theoretical framework and a "Connection Reordering" algorithm to minimize these I/O costs.

Theoretical Framework and Connection Reordering

The authors propose shifting the paradigm of neural network inference from traditional node-based, layer-by-layer processing to an edge-based approach.

Traditional node-based numbering (left) vs. proposed edge-based connection ordering (right).

The core of this approach lies in three main components:

  1. Theoretical Bounds: The paper proves that for any sparse Feed-Forward Neural Network (FFNN), the optimal number of I/Os is bounded within a factor of 2 by basic network properties like the number of connections and neurons.
  2. Connection Reordering via Simulated Annealing: Instead of processing layers, the algorithm finds a "topological order" of individual connections. By using simulated annealing, it maximizes data reuse—ensuring that connections sharing a neuron are processed close together in time to keep that neuron in cache.
  3. Compact Growth: A constructive algorithm that builds networks from scratch to be mathematically guaranteed as I/O-optimal for a specific fast-memory size ($M$).

Experimental Evaluation and Key Results

The methods were evaluated using both synthetic randomly-sparse FFNNs (varying density from 0.1% to 100%) and a real-world pruned $BERT_{LARGE}$ model.

Total I/O reductions across varying (a) width, (b) depth, (c) connection density, and (d) fast memory size.

The results demonstrate significant improvements over standard execution:

  • Massive Speedups: Reordered inference achieved up to 45x speedup on an Intel Xeon CPU compared to standard sparse matrix-matrix multiplication (MKL's CSRMM) at 0.1% density.
  • I/O Reduction: Simulated annealing reduced total I/Os by up to 43.5% compared to a naive ordering, reaching within 97.4% of the theoretical lower bound.
  • Scalability: Performance gains scale linearly with network depth and breadth, making the method increasingly valuable for larger models.

Discussion and Future Work

While this framework provides a strong foundation for I/O-efficient inference, several areas remain for future exploration. The current theory focuses on static sparsity patterns and does not yet account for dynamic sparsity or the training phase. Additionally, real-world hardware often features complex multi-level cache hierarchies, which may require extending the reordering logic. Finally, there is an ongoing challenge in balancing irregular sparse access patterns with the hardware's preference for contiguous data in SIMD (vector) instructions.

Summary updated

Abstract

As the accuracy of machine learning models increases at a fast rate, so does their demand for energy and compute resources. On a low level, the major part of these resources is consumed by data movement between different memory units. Modern hardware architectures contain a form of fast memory (e.g., cache, registers), which is small, and a slow memory (e.g., DRAM), which is larger but expensive to access. We can only process data that is stored in fast memory, which incurs data movement (input/output-operations, or I/Os) between the two units. In this paper, we provide a rigorous theoretical analysis of the I/Os needed in sparse feedforward neural network (FFNN) inference. We establish bounds that determine the optimal number of I/Os up to a factor of 2 and present a method that uses a number of I/Os within that range. Much of the I/O-complexity is determined by a few high-level properties of the FFNN (number of inputs, outputs, neurons, and connections), but if we want to get closer to the exact lower bound, the instance-specific sparsity patterns need to be considered. Departing from the 2-optimal computation strategy, we show how to reduce the number of I/Os further with simulated annealing. Complementing this result, we provide an algorithm that constructively generates networks with maximum I/O-efficiency for inference. We test the algorithms and empirically verify our theoretical and algorithmic contributions. In our experiments on real hardware we observe speedups of up to 45$\times$ relative to the standard way of performing inference.
BibTeX
@misc{gleinig2023theory,
  author = {Niels Gleinig and Tal Ben-Nun and Torsten Hoefler},
  title = {{A Theory of I/O-Efficient Sparse Neural Network Inference}},
  year = {2023},
  eprint = {2301.01048},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.01048},
}
Figure