Source-linked AI summary
Pruning vs Quantization: Which is Better?
Andrey Kuzmin, Markus Nagel, Mart van Baalen, Arash Behboodi, Tijmen Blankevoort
TL;DR
The paper addresses limited direct evidence comparing pruning and quantization. It compares their errors across distributions, layers, and full models, and finds that quantization generally outperforms pruning.
Problem
The literature offers little insight into which of pruning or quantization is more accurate, despite their relevance to compression decisions.
Source: §1 · p. 2Method
The study compares pruning and quantization through distribution-level error analysis, post-training per-layer evaluation, and fine-tuned full-model experiments.
Source: §1 · p. 2Results
Quantization generally outperforms pruning; pruning is better only rarely, at 2- or 3-bit-equivalent compression in theoretical and real-layer analyses.
Source: §8 · p. 10Takeaways & Limitations
The authors recommend quantizing neural networks when efficiency is required before exploring pruning.
Source: §8 · p. 10The study does not extensively assess hardware implications, combinations of pruning and quantization, or quantization formats beyond uniform quantization.
Source: §6 · p. 9
Abstract
from arXiv · showhide
Neural network pruning and quantization techniques are almost as old as neural networks themselves. However, to date only ad-hoc comparisons between the two have been published. In this paper, we set out to answer the question on which is better: neural network quantization or pruning? By answering this question, we hope to inform design decisions made on neural network hardware going forward. We provide an extensive comparison between the two techniques for compressing deep neural networks. First, we give an analytical comparison of expected quantization and pruning error for general data distributions. Then, we provide lower bounds for the per-layer pruning and quantization error in trained networks, and compare these to empirical error after optimization. Finally, we provide an extensive experimental comparison for training 8 large-scale models on 3 tasks. Our results show that in most cases quantization outperforms pruning. Only in some scenarios with very high compression ratio, pruning might be beneficial from an accuracy standpoint.
1 Introduction
The introduction frames a gap in direct evidence comparing pruning and quantization, despite the importance of model efficiency. It outlines a comparison spanning error analysis, post-training layers, and fine-tuned full models.
1 Introduction
- Pruning can reduce memory and potentially computation by zeroing weights, while quantization reduces weight and computation bit-width for predictable memory and compute savings.Source: §1 · p. 1
- Methods include fine-tuning approaches such as QAT and pruning-in-the-loop, as well as post-training approaches such as PTQ.Some recent post-training pruning methods address settings where fine-tuning is undesirable, including large language models.Source: §1 · p. 1
- The literature offers little insight into which technique is more accurate, motivating the question of whether to focus on quantization or pruning for compression.Source: §1 · pp. 1–2
- The study compares pruning and quantization under equal settings through distribution analysis, real pretrained weights, post-training layer errors, and fine-tuned full models.Source: §1 · p. 2
- The comparison focuses on accuracy at similar theoretical compression ratios and does not evaluate hardware aspects.Source: §1 · p. 2
2 Assumptions
The assumptions establish FP16 as the compression baseline and use magnitude pruning and symmetric uniform quantization as the compared methods.
2 Assumptions
- FP16 is the baseline; 50% pruning is matched to INT8 quantization, 75% sparsity to INT4, and so forth, without accounting for pruning-mask storage overhead.Source: §2 · p. 2
- Pruning experiments use magnitude pruning with fine-tuning, a method the authors describe as difficult to improve upon consistently.The passage notes common use of fine-tuning after or during pruning [70] and cites independent supporting work [19].Source: §2 · p. 2
- Quantization experiments use symmetric uniform quantization, defined by a scale factor and bit-width, with the range estimator selected to minimize weight MSE by grid search.The scale is represented as a floating-point number and maps floating-point values to an integer grid.Source: §2 · p. 2
3 Comparison on statistical distributions
This section compares expected quantization and pruning errors analytically, then tests the comparison on real neural-network weight tensors. It examines how distribution shape and compression level affect which method has higher SNR.
3 Comparison on statistical distributions
- The section first uses theoretical error analysis on simple data distributions to clarify how quantization and pruning compare.Source: §3 · p. 2
3.1 Quantization error
- Symmetric uniform quantization rounds weights to a bit-width-and-scale grid; its expected MSE separates rounding error from clipping error.Source: §3.1 · p. 3
3.2 Pruning error
- Magnitude pruning sets weights near zero to zero, with threshold t controlling the amount pruned under a specified compression ratio.Source: §3.2 · p. 3
3.4 Experiments on real weight tensors
- Across real tensors from 46 PyTorch models and three LLMs, pruning grows more favorable at lower bit-widths, with kurtosis predicting which method has higher SNR.Source: Figure 3 · p. 4, §3.4 · pp. 4–5
3.3 Analytical comparison
- For roughly Gaussian weights, quantization reaches 19.1 dB INT4 SNR versus 5.6 dB for 75% pruning; under heavy tails, pruning wins only at very high compression (2–3 bits per value).Source: Figure 2 · p. 3, §3.3 · p. 4
4 Per-layer comparison
The per-layer comparison evaluates post-training pruning and quantization using output-activation error, with bounds intended to make their ranking less dependent on the optimizer. Quantization mostly outperforms pruning at moderate compression, while they become more comparable at higher compression.
4 Per-layer comparison
- The comparison uses output-activation error and theoretical bounds to avoid dependence on the optimization method chosen for either technique.The paper gives a tight lower bound for quantization and solves pruning exactly for moderate dimensionalities.Source: §4 · p. 5
4.1 Post-training quantization
- Quantized-layer output MSE is formulated as a mixed-integer quadratic program, solvable independently for each convolution output channel or fully connected weight row.The formulation uses input data in unfolded form, floating-point weights, a quantization scale, integer weights, and integer-range limits.Source: §4.1 · p. 5
4.2 Post-training pruning
- For pruning, the layer problem constrains the number of nonzero weights using a sparsity mask, then uses branch-and-bound to obtain a global solution.The mask is constrained by the L0 requirement; the stated implementation uses Gurobi.Source: §4.2 · p. 6
4.3 Experiments
- The experiments optimize layer weights on a batch to minimize the output-activation error, reporting a range from a heuristic result to an error bound or global solution.The comparison covers selected layers from MobileNet-V2, EfficientNet-lite, ResNet-18, and ViT; pruning layers were split into chunks for the global solution.Source: §4.3 · pp. 6–7
- Quantization mostly outperforms pruning at moderate compression, while the methods become more comparable at higher compression.Figure 4 ranges show heuristic-to-bound results; intersections with the diagonal mean the ranking can depend on the optimizer, while positions above or below guarantee a ranking regardless of optimizer.Source: §4.3 · p. 7, Figure 4 · p. 7
5 Full-model comparison
In full-model fine-tuning comparisons at equal compression, pruning almost never achieves higher accuracy than quantization. Pruned models generally benefit more from longer fine-tuning, and mild pruning can help when combined with quantization, although the latter comparison assumes no mask-storage overhead.
5 Full-model comparison
- The comparison uses competitive QAT and magnitude-pruning methods, with equal fine-tuning epochs across models spanning image classification, segmentation, detection, and language modeling.The experiments include ImageNet models, DeepLab-V3 on Pascal VOC, EfficientDet on MS COCO, and OPT-350 fine-tuned on WikiText-103.Source: §5 · p. 7
- At equal compression, pruning almost never achieves higher accuracy than quantization in the fine-tuned model comparison.Table 1 compares QAT and magnitude pruning at equal model size and equal fine-tuning epochs.Source: §5 · p. 7, Table 1 · p. 8
- With twice as much fine-tuning, pruned models generally benefit more; pruning becomes more beneficial for most compression ratios on ResNet-50, while quantization remains more beneficial on the other models.The longer-training ablation covers ResNet-50, EfficientNet, and ViT.Source: §5 · pp. 7–8
- Mild pruning can benefit quantized ImageNet models, but the comparison assumes no extra overhead for storing the pruning mask.Figure 5 plots expected bit-width as base bit-width multiplied by nonzero-weight density; crosses mark quantized models with natural sparsity and no extra pruning.Source: §5 · p. 8, Figure 5 · p. 8
6 Discussion
The discussion qualifies the pruning comparison by relating unstructured results to structured pruning, reporting sparsity in quantized tensors, and considering hardware implications. It also notes limitations in the study’s scope.
Other types of pruning
- Unstructured pruning is a strict superset of structured pruning, so quantization’s advantage over unstructured pruning also holds for structured pruning, but the reverse cannot be claimed.The authors leave open whether structured pruning is better in the few cases where unstructured pruning outperforms quantization.Source: §6 · p. 9
Natural sparsity in quantized tensors
- 8-bit PyTorch model-zoo tensors have 13% average sparsity, while 4-bit tensors have 35% average sparsity.The comparison uses a theoretical quantization compression ratio based on bit-width, while quantized tensors also contain zeros.Source: §6 · p. 9
Representations learned in the compressed models
- Fine-tuning after pruning tends to recover the original representation, whereas quantization-aware training leads to completely new representations.The authors studied representation changes during fine-tuning.Source: §6 · p. 9
Hardware implications
- Unstructured pruning on 16-bit weights requires at least 1 mask bit per weight, adding 6.25% storage overhead; quantization instead has a scaling-factor overhead per tensor or channel.The pruning estimate assumes an idealized case for memory size and data transfer.Source: §6 · p. 9
- Pruning requires decompression or dedicated hardware to exploit zeros, while INT8-to-INT4 quantization theoretically improves compute performance 4× but memory savings only 2×.The practical compute gain depends on memory overhead and the formats supported by the hardware compute unit.Source: §6 · p. 9
Limitations
- The study does not extensively examine hardware implications, combinations of pruning and quantization, or quantization formats beyond uniform quantization.The authors state that the omitted formats are not likely to change the reported results.Source: §6 · p. 9
7 Related work
The related work reviews quantization and pruning approaches, work combining them, and the limited literature directly comparing their accuracy.
Quantization
- Quantization methods include post-training optimization of quantized weights and quantization-aware fine-tuning, which uses a straight-through estimator for rounding gradients.The passage lists prior PTQ methods [6] and QAT methods [69] [35].Source: §7 · pp. 9–10
Pruning
- Pruning work spans binary gating, sensitivity-based selection, and magnitude pruning; magnitude methods have outperformed more intricate methods at scale, while Hessian-based methods have shown good post-training results for large language models.Most pruning methods require fine-tuning and have unsatisfactory post-training results, according to the passage.Source: §7 · p. 10
Comparing pruning and quantization
- Prior work studied combinations of pruning and quantization, but direct comparisons were scarce; the closest cited comparison used small models and offered only empirical results without further analysis.The passage identifies comparison studies and.Source: §7 · p. 10
8 Conclusion
The paper concludes that quantization generally outperforms pruning, with pruning favored only in rare, very-high-compression settings. The appendices describe analytical error computation and supplementary sparsity and correlation analyses.
8 Conclusion
- Quantization generally outperforms pruning; pruning is better only in rare cases, including theoretical and real-layer comparisons at compression equivalent to 2 or 3 bits per value.The authors say this degree of compression brings a performance drop that is rarely used in practice; their fine-tuning results also show quantization performing higher in many networks trained under the same conditions.Source: §8 · p. 10
A Expected quantization error computation
- Expected quantization error is decomposed into rounding and clipping error, which can be computed analytically given a quantization grid and probability density function.The passage gives Gaussian, Uniform, and Student’s t-distributions as examples.Source: A Expected quantization error… · p. 15
B Truncated Student’s-t distribution
- The appendix defines a symmetric truncated Student’s-t distribution and plots its kurtosis as a function of truncation range.The distribution has zero mean and unit variance, with truncation limits −l and l.Source: B Truncated Student’s-t distribution · pp. 15–16, Figure 6 · p. 16
D Correlation between model accuracy and per layer SNR
- Figure 7 relates per-layer SNR to full-model accuracy; single-layer pruning and quantization in ResNet-18 show strong correlation between activation SNR and accuracy drop.This section uses linear-scale SNR, a normalized MSE, unlike the log-scale SNR used in section 4.Source: Figure 7 · p. 16, D Correlation between model accuracy… · p. 17
C Sparsity in quantized tensors
- The appendix reports that sparsity in quantized PyTorch model-zoo tensors becomes significant, especially at low bit-widths, and provides average sparsity by bit-width.Source: C Sparsity in quantized tensors · p. 16, Table 2 · p. 16
E Details of PyTorch model zoo tensors experiments
The appendix records the model-zoo tensors used in compression experiments and the chunking and runtime details for per-layer experiments.
E Details of PyTorch model zoo tensors experiments
- The tensor experiments pruned and quantized convolutional and fully connected weights across 45 PyTorch model-zoo models.The appendix lists models from image classification, detection, segmentation, and video classification.Source: E Details of PyTorch model zoo tensors… · p. 17
F Details of per-layer experiments
- Per-layer experiments split layers into chunks, using 4 input channels across output channels for 3×3 convolutions and 36 input features across output features for linear layers and point-wise convolutions.Experiments took approximately one hour to six CPU weeks, depending on the layer.Source: F Details of per-layer experiments · p. 17
G Details of the full-model experiments
The full-model experiments specify the evaluated models and tasks, compression settings, and a comparison with longer fine-tuning.
G Details of the full-model experiments
- The experiments cover nine models across four tasks, including image classification, semantic segmentation, object detection, and language modeling.The listed models include ResNet, MobileNet, EfficientNet, ViT, DeepLab-V3, EfficientDet, and OPT-350m.Source: G Details of the full-model experiments · p. 17
- Pruning fine-tuning gradually increases sparsity before using the remaining epochs to recover accuracy at fixed sparsity.The schedule is 15 plus 5 epochs for most models and 150 plus 50 for DeepLab-V3.Source: G Details of the full-model experiments · p. 18
- Quantization uses per-tensor weight quantization and Adam optimization of quantization scales, without pruning or quantizing activations.The scale-optimization learning rate is 1.0e-5.Source: G Details of the full-model experiments · p. 18
H Full-model experiments with longer fine-tuning
- A further full-model comparison reports QAT and magnitude pruning with twice as long fine-tuning as the Table 4 experiments.Table 5 gives the comparison details, but the supplied passages do not include its results.Source: H Full-model experiments with longer… · p. 18, Table 5 · p. 18
I Analysis of representations learned during fine-tuning in QAT and pruning
The analysis tracks layer representations during fine-tuning after pruning or quantization, finding different trends for the two methods. The reported pattern also appears for ViT, with CKA used to confirm the observation.
I Analysis of representations learned during fine-tuning in QAT and pruning
- The analysis samples ResNet-18 and ViT activations after each fine-tuning epoch and immediately after compression, measuring log-scale SNR and CKA distance to original activations.Figure 8 plots layerwise distances during QAT and pruning fine-tuning; Figure 9 focuses on the last non-classification layer.Source: I Analysis of representations learned… · p. 19, Figure 8 · p. 20, Figure 9 · p. 21
- During fine-tuning, pruning representations tend to move closer to original activations, whereas QAT tends to learn representations different from the original.The authors characterize pruning as tending toward recovery of the original model's representations.Source: I Analysis of representations learned… · p. 19
- ViT shows qualitatively the same pattern; its SNR becomes rapidly negative for both methods, while CKA evolution follows the pattern and confirms the observation.The authors omit ViT SNR plots.Source: I Analysis of representations learned… · p. 19