Research project · Adversarial ML · Edge deployment

Shrinking the model, not the guarantee

What happens to a certified defense against adversarial patches when the model is quantized, pruned or distilled for an edge device? We trained, compressed, attacked and certified 148 CNNs across four settings to find out.

Muhammad Abdullah Haroon, Abdul Rehman Antall, Muhammad Ali Hadi · FAST School of Computing, FAST NUCES, Lahore

How a patch attack and a certified defense work

These are the real universal patches our pipeline optimized against the baseline ResNet-18, one per target class. Drag the patch over the CIFAR-10 image, then run PatchCleanser's masks.

Double masking, in four steps

  1. The attack. A universal patch is a small square (here 8×8 px, 6% of the image) optimized so that, pasted anywhere on any image, the classifier predicts the target class. On the undefended baseline it cuts accuracy from % to %.
  2. The masks. PatchCleanser slides a set of masks over the image, chosen so that at least one mask fully covers a patch at any position (25 masks of 12 px for this patch size).
  3. The vote. The model classifies every masked image. If all predictions agree, the label cannot have been caused by the patch; if they disagree, a second round of masks resolves it.
  4. The certificate. If the prediction is the same under every pair of masks, no patch of that size anywhere can change it. That is a mathematical guarantee, not an empirical one, and it is what we test after compression.

The pipeline

Every model passes through the same stages; each stage writes JSON that feeds the statistics, the paper and this page.

01

Train

ResNet-18, MobileNetV2, ResNet-50 on CIFAR-10, GTSRB, ImageNette; 3 seeds

02

Defend

Mask-augmented retraining, so the model tolerates occlusion

03

Compress

FP16, INT8, INT4 · pruning 50–87.5% · dense-small · distillation

04

Attack

Universal and LaVAN patches; straight-through and BPDA gradients

05

Certify

PatchCleanser double masking on 1,000 images per model

06

Transfer

13×13 matrix: full → compressed and back

07

Explain

Occlusion accuracy, margin, gradients, CKA vs. outcomes

Explore the CIFAR-10 results

Mean over three training seeds. Weight-preserving compression (quantization, pruning) stays flat; retraining a smaller network drops.

Does it generalize?

Change in certified accuracy (5 px patch, defended models) of each 4× arm relative to its own baseline, with 95% intervals. Filled dots: interval excludes zero.

What we found

Four findings, each backed by paired statistics over seeds.

Engineering

Built end to end on a single lab GPU with frequent power cuts.

Resumable experiment queue

The final follow-up queue alone was 271 runs (about 70 GPU-hours on one RTX A4000). Each run is idempotent and skipped once its result exists, so the queue survives power losses and restarts.

Differentiable quantization

Fake-quant with a straight-through estimator and BN folding, plus a BPDA attack through the FP32 copy, so quantized models cannot hide behind gradient masking.

Statistics, not single runs

Three seeds with paired t-intervals and an image bootstrap for certification; a claim is made only when the interval excludes zero.

Certified defense

PatchCleanser implemented from the paper, with exhaustive checking that the mask set covers every patch position.

Paper generated from data

Every number in the paper and on this page is a macro generated from result files, with an automatic check that each one resolves.

Reproducible

Configs, logs and per-run JSON are in the repository; one command regenerates statistics, tables, figures and this page's data.

PyTorchPythonNumPyMatplotlibLaTeXChart.jsAdversarial MLModel compressionCertified robustness