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

A Layer-wise Adversarial-aware Quantization Optimization for Improving Robustness

Chang Song, Riya Ranjan, Hai LiarXiv 2021

Introduction

Deep learning models are increasingly deployed on "the edge"—including smartphones, drones, and IoT sensors. To fit these models into memory-constrained hardware, engineers use quantization, a process that reduces the precision of weights (e.g., from 32-bit floating point to 3-bit integers). However, a significant security challenge exists: neural networks are notoriously vulnerable to adversarial attacks—tiny, calculated perturbations to input data that cause misclassification.

While "adversarial training" is the gold standard for making models robust to these attacks, it introduces a frustrating trade-off. Adversarially trained models are significantly more sensitive to quantization noise than standard models. When a robust model is quantized using standard uniform methods, its hard-won defense often collapses. This paper introduces a Layer-wise Adversarial-aware Quantization (LQ) method to bridge this gap, allowing models to be compressed without sacrificing their ability to withstand attacks.

The Challenge of Quantizing Robust Models

Standard models have weights that are generally easier to quantize. In contrast, adversarially trained models have weight distributions specifically tuned to resist input noise. Even slight changes to these weights via quantization can disrupt the delicate decision boundaries they have learned.

Figure 1: Accuracy vs. Quantization Bit for MNIST (a) and CIFAR-10 (b). Note the sharp decline in accuracy for adversarially trained models (Adv.) under uniform quantization compared to the proposed method (F.L./LQ).

As shown in Figure 1, quantization error is cumulative. A rounding error in early layers can be amplified by subsequent layers, eventually leading to a total "robustness meltdown" at the output. This "error amplification" trap is particularly severe for robust models at low bit-widths.

Methodology: Layer-wise Adversarial-aware Quantization (LQ)

The proposed LQ method treats each layer as a unique optimization problem rather than applying a uniform bit-width across the entire network. The core of this approach is the use of the Lipschitz constant (the spectral norm of the weight matrix) to mathematically bound error amplification.

Dual-Criteria Optimization

For each layer, the algorithm iteratively increases the bit-width until two specific conditions are met:

  1. Stability: The Lipschitz constant of the quantized weights remains below a defined threshold.
  2. Error Minimization: The Lipschitz constant of the quantization error (the difference between full-precision and quantized weights) is minimized.

Hybrid and Input-Independent Strategy

The algorithm automatically selects between linear and logarithmic quantization for each layer based on which yields a lower error bound. Crucially, this approach is based purely on weight matrices. Unlike methods that require passing thousands of images through the network for calibration, LQ is computationally efficient and input-independent.

Experimental Results

The researchers evaluated their approach on MNIST (using a four-layer CNN) and CIFAR-10 (using ResNet-32) against a battery of attacks, including FGSM, PGD, and Carlini-Wagner (CW-L2).

Figure 3: Performance comparison on CIFAR-10 (ResNet-32). Adv. (LQ) significantly recovers the robustness lost by uniform quantization (Adv. (Q)).

As detailed in Figure 3, the results demonstrate that careful quantization can almost entirely recover the robustness lost during compression:

  • MNIST: A uniform 3-bit quantized robust model saw its accuracy against attacks plummet to ~42%. The LQ method restored it to ~95%, nearly matching the full-precision model.
  • CIFAR-10: On the ResNet-32 architecture, uniform 3-bit quantization dropped accuracy to roughly 20-33% under attack. The LQ method brought this back up to ~81%.
  • Efficiency: By using a layer-wise greedy search based on matrix norms rather than full-dataset retraining, the method is significantly faster than traditional quantization-aware training.

Conclusion and Future Work

By using the Lipschitz constant to provide theoretical guarantees, the authors prove that minimizing this constant effectively minimizes the "mutual loss" between adversarial perturbations and quantization noise. While the method is highly effective, future work remains to be done in automating the selection of Lipschitz thresholds and extending the approach to activation quantization, which is often even more damaging to accuracy in real-world edge deployments. Additionally, testing the scalability of this layer-wise approach on massive foundation models or Vision Transformers (ViTs) is a key next step.

Summary updated

BibTeX
@misc{song2021layer,
  author = {Chang Song and Riya Ranjan and Hai Li},
  title = {{A Layer-wise Adversarial-aware Quantization Optimization for Improving Robustness}},
  year = {2021},
  eprint = {2110.12308},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2110.12308},
}
Figure