S2AP: Score-space Sharpness Minimization for Adversarial Pruning

Giorgio Piras, Qi Zhao, Fabio Brau, Maura Pintor, Christian Wressnegger, Battista Biggio

TL;DR

Adversarial pruning compresses neural networks while maintaining defense against malicious attacks, but optimizing weight importance scores often leads to sharp loss landscapes and highly unstable mask selection. This paper introduces S2AP, a plug-in method that minimizes sharpness directly within the score space rather than the weight space. This simple shift stabilizes mask selection during training and consistently boosts the adversarial robustness of the pruned models across various architectures and datasets.

What Problem Does This Paper Address?

Deploying deep neural networks on resource-constrained edge devices requires model compression techniques like network pruning. However, these models must also remain robust against adversarial attacks—subtle, engineered perturbations to inputs that cause misclassification. Adversarial Pruning (AP) attempts to solve both problems simultaneously by identifying and retaining only the weights most critical for robustness.

Modern AP methods (like HYDRA and HARP) achieve this by assigning a continuous "importance score" to each weight, optimizing these scores against a robust loss function, and keeping the top-$k$ highest-scoring weights to form a sparse binary mask.

The catch? This score-space optimization is highly volatile. Because mask selection relies on a hard top-$k$ cutoff, a tiny shift in importance scores can drastically alter which weights are kept or discarded. The authors discover that this volatility stems from sharp local minima in the score-space loss landscape. This instability ultimately degrades the final model's adversarial defense.

Methods

To smooth out this volatile landscape, the authors propose Score-space Sharpness-aware Adversarial Pruning (S2AP). Inspired by weight-space smoothing techniques like Sharpness-Aware Minimization (SAM), S2AP applies the concept of sharpness minimization directly to the importance scores during the mask search phase.

The algorithm follows a step-by-step approach during each pruning iteration:

  1. Score Perturbation: Before updating the scores, S2AP calculates a worst-case ascent step (a perturbation $z$) that maximizes the robust loss in the score space.
  2. Layer-wise Projection: To prevent numeric disparities across different layers, the perturbation is scaled and projected layer-by-layer relative to the norm of each layer's scores.
  3. Sharpness-Aware Update: The gradient of the robust loss is evaluated at this perturbed score location ($s + z$). The scores are then updated to minimize this worst-case loss, effectively flattening the landscape.
  4. Aligned Finetuning: Once the final pruning mask is locked in, S2AP applies an aligned weight-space Adversarial Weight Perturbation (AWP) during the final finetuning stage to polish the remaining sparse weights.

Crucially, S2AP acts as a generic "wrapper" or plug-in, meaning it can be seamlessly integrated into any existing score-based AP pipeline without changing its underlying loss formulation.

Datasets

The authors validated S2AP across several standard computer vision benchmarks:

  • CIFAR-10 and SVHN: Used for extensive evaluation across multiple architectures (ResNet18, VGG16, WideResNet28-4) and high sparsity levels (up to 99%).
  • ImageNet: Used to test scalability on a larger scale using a ResNet50 architecture.
  • CIFAR-10-C: Used to evaluate the model's out-of-distribution robustness against common image corruptions (e.g., blur, noise).

Key Insights and Ideas

  • The Importance of Score Space: Traditional sharpness-aware methods focus exclusively on smoothing the weight landscape. S2AP's core insight is that for pruning, the score space dictates the discrete, combinatorial mask selection process. Smoothing the score space is what actually prevents chaotic mask flipping.
  • Flatness Breeds Stability: By flattening the score-space loss landscape, the mask selection process becomes significantly less sensitive to minor gradient fluctuations. This concept is empirically proven using the Hamming distance of masks across training epochs.
  • Empirical Superiority Over Weight Perturbation: The authors experimented with perturbing weights instead of scores during the mask search phase. They found that score perturbation consistently yields superior robust accuracy, validating their intuition that stabilizing the selection variables directly is the right approach.

Key Results

S2AP consistently improves upon original AP baselines across all tested configurations:

  • Robustness Gains: On CIFAR-10, S2AP improves the robust accuracy of pruned models by up to 2 percentage points (p.p.) compared to standard HYDRA and HARP, with negligible or no drop in clean accuracy.
  • First ViT Demonstration: The authors provide the first demonstration of AP methods on a Vision Transformer (ViT), showing that S2AP successfully scales to attention-based architectures.
  • Quantifiable Landscape Smoothing: Using Hessian analysis, the authors show a clear reduction in the largest eigenvalue ($\lambda_{max}$), mathematically confirming a flatter loss landscape.
Figure 1: Effects of S2AP on a ResNet18 CIFAR10 model. (a) Improved robust accuracy of pruned models. (b) Enhanced mask stability (quantified as Hamming distance h, i.e., measuring how much each mask mt across pruning epochs changes compared to the first computed mask m0). We subtract and plot horig −hS2AP , thus yielding positive values where S2AP is more stable (green area), and negative values vice versa (red area). S2AP enhances mask stability, particularly after pruning epoch 5 when warm-up ends and explicit sharpness minimization begins. (c) Minimized sharpness in the robust loss landscape (where the largest eigenvalue λmax indicates more sharpness).

As illustrated in Figure 1b, right after the 5-epoch warm-up period ends and S2AP's sharpness minimization activates, there is an immediate spike in mask stability (positive Hamming difference) compared to the original volatile baseline.

Limitations and Future Work

The primary drawback of S2AP is computational overhead. Calculating the worst-case score perturbation requires an extra forward-backward pass, which introduces an average increase in pruning time of roughly 15% (Table 7 in the paper). While acceptable in many research or offline training scenarios, this could be a bottleneck for resource-constrained training pipelines.

For future work, the authors suggest exploring "cheaper" single-step sharpness approximation methods to mitigate this overhead. Additionally, they note that adapting AP methods to more complex, modern transformer architectures remains an open engineering challenge that requires a broader setup shift in the field.

Summary updated

BibTeX
@misc{piras2025s,
  author = {Giorgio Piras and Qi Zhao and Fabio Brau and Maura Pintor and Christian Wressnegger and Battista Biggio},
  title = {{S2AP: Score-space Sharpness Minimization for Adversarial Pruning}},
  year = {2025},
  eprint = {2510.18381},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.18381},
}
Figure