Introduction
Neural network pruning is a critical technique for deploying large-scale models on resource-constrained edge devices. However, traditional structured pruning methods often suffer from three primary forms of "siloing": architecture dependency due to layer coupling, framework lock-in (e.g., PyTorch-only tools), and timing constraints regarding when pruning can occur (pre-training vs. post-training).
Structurally Prune Anything (SPA) addresses these challenges by providing a universal framework that automates structured pruning across diverse architectures and deep learning frameworks. By utilizing ONNX as a standardized intermediate representation and introducing the OBSPA algorithm, SPA enables high-efficiency model compression even in data-constrained environments.
The SPA Pipeline
The SPA framework operates through a standardized four-step process designed to decouple pruning logic from the source framework and specific architecture details.
- Standardized Computational Graph: Models from PyTorch, TensorFlow, MXNet, or Jax are first converted into the ONNX (Open Neural Network Exchange) format. This provides a uniform, static trace of the model's operations.
- Mask Propagation: To resolve channel coupling (e.g., in residual connections), SPA employs "mask propagation." Starting from a target channel, it follows rules for over 150 ONNX operators to identify all mathematically linked channels across the network.
- Group-Level Importance Estimation: Rather than evaluating individual weights, SPA groups coupled parameters and calculates a single importance score for the group (using metrics like L1-norm or SNIP). This ensures pruning does not disrupt the model's connectivity.
- Optimal Brain SPA (OBSPA): For scenarios without fine-tuning, OBSPA adapts "Optimal Brain Surgeon" theory to a layer-wise approach, minimizing reconstruction error to maintain accuracy immediately after pruning.
Experimental Results
The authors evaluated SPA across 11 different architectures, including CNNs (MobileNet, ResNet, VGG) and Transformers (ViT, DistilBERT), using datasets like ImageNet-1k and SST-2.
As shown in the results above, SPA successfully prunes models trained in PyTorch, TensorFlow, MXNet, and Jax with negligible accuracy loss. For instance, on ResNet-50 (ImageNet), OBSPA achieved 76.59% top-1 accuracy at a 2.22x FLOP reduction without any fine-tuning. Furthermore, SPA demonstrates a 6x speedup in pruning operations compared to previous state-of-the-art methods like DFPC.
Key Insights and Limitations
A significant finding of this work is that data-free pruning is viable; OBSPA can perform effective Hessian-based pruning using only Out-of-Distribution (OOD) data or uniform noise, which is crucial for privacy-sensitive applications where original training data cannot be shared.
However, some limitations remain. While the pruning analysis is framework-agnostic via ONNX, fine-tuning still requires converting models back to a framework like PyTorch because ONNX does not natively support the backward pass. Additionally, while structured pruning is theoretically hardware-friendly, actual wall-clock speedups depend heavily on specific GPU/CPU kernel implementations for the pruned dimensions.
Summary updated