NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Smallify: Learning Network Size while Training

Guillaume Leclerc, Manasi Vartak, Raul Castro Fernandez, Tim Kraska, Samuel MaddenarXiv 2018

Abstract

As neural networks become widely deployed in different applications and on different hardware, it has become increasingly important to optimize inference time and model size along with model accuracy. Most current techniques optimize model size, model accuracy and inference time in different stages, resulting in suboptimal results and computational inefficiency. In this work, we propose a new technique called Smallify that optimizes all three of these metrics at the same time. Specifically we present a new method to simultaneously optimize network size and model performance by neuron-level pruning during training. Neuron-level pruning not only produces much smaller networks but also produces dense weight matrices that are amenable to efficient inference. By applying our technique to convolutional as well as fully connected models, we show that Smallify can reduce network size by 35X with a 6X improvement in inference time with similar accuracy as models found by traditional training techniques.

Introduction

Deep learning practitioners often face a "Goldilocks" problem: choosing a network architecture that is just right. If a model is too large, it wastes memory and computation; if it’s too small, it lacks the capacity to learn complex patterns. Traditionally, this is addressed via manual search or post-processing pruning. However, manual search is computationally expensive, and standard pruning often results in sparse matrices that are surprisingly slow on modern hardware like GPUs, which are optimized for dense matrix math. Smallify is a novel training technique that automatically "shrinks" a neural network to its optimal size while it learns, producing compact, dense models that are up to 35x smaller and 6x faster at inference time without sacrificing accuracy.

Methodology

The core of the Smallify approach is the SwitchLayer, placed after standard convolutional or fully connected layers.

  • Mechanism: Each neuron is assigned a learnable parameter ($\beta$). During training, the neuron's output is multiplied by its $\beta$.
  • Penalty: An $L_1$ regularization term is added to these $\beta$ parameters, creating pressure to push unimportant values toward zero.
  • Sign Variance Strategy: To handle the fact that gradient descent rarely hits exactly zero, the authors track the stability of the sign of $\beta$. Neurons with oscillating outputs near zero are flagged for removal.
  • Neural Garbage Collection: Flagged neurons are physically removed during training, which actually speeds up the remaining training process as the model gets smaller.
  • Inference Optimization: For deployment, SwitchLayers are folded into preceding weights, resulting in a standard, dense network with no extra overhead.

Experimental Setup

The authors evaluated Smallify on two distinct tasks:

  1. CIFAR10: An image classification benchmark using a VGG16 architecture as the initial over-sized network.
  2. COVERTYPE: A forest cover type prediction dataset used to test Smallify on multi-layer perceptron (MLP) architectures.

Key Results

Smallify demonstrates that neuron-level pruning produces dense weight matrices amenable to efficient inference, unlike fine-grained pruning which creates sparse matrices. By removing entire neurons, the technique effectively removes entire rows or columns from weight matrices, maintaining peak GPU efficiency.

Distribution of models by size and accuracy on CIFAR10, showing the Smallify Pareto front achieving 35.8x compression.

On CIFAR10, Smallify reduced network size by 35x with only a 1% sacrifice in accuracy compared to full-sized models. Because the resulting models remain dense, this size reduction translated into a 6x improvement in inference time on real-world hardware.

Compression factors and inference speedups on CPU and GPU for CIFAR10 models.

The dynamic shrinking process consistently achieved equal or better accuracy than traditionally trained "static" networks of the same size. Furthermore, the discovered architectures often deviated from common heuristics (e.g., doubling channels after pooling), suggesting Smallify can discover data-driven architectural optimizations that manual tuning might miss.

Conclusion and Future Work

Smallify simplifies the model optimization pipeline into a single hyperparameter ($\lambda$) controlling the size-accuracy trade-off. While promising, future work may address the dependency on an initial over-sized network and explore the technique's scalability to more complex architectures like Transformers or highly branched Residual Networks.

Summary updated

BibTeX
@misc{leclerc2018smallify,
  author = {Guillaume Leclerc and Manasi Vartak and Raul Castro Fernandez and Tim Kraska and Samuel Madden},
  title = {{Smallify: Learning Network Size while Training}},
  year = {2018},
  eprint = {1806.03723},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1806.03723},
}
Figure