Provable Adversarial Detection: Prime Quantization meets Gromov--Wasserstein
Abstract
Adversarial vulnerability persists across modern vision architectures from CNNs to vision language models (VLMs), yet existing detection methods rely on heuristics without theoretical guarantees. We address the fundamental question of when adversarial perturbations can be provably detected from a geometric perspective. Our key insight is that adversarial perturbations cannot simultaneously preserve geometric structure across spaces with fundamentally different properties. Accordingly, we construct two such complementary metric spaces. First, we use a standard CNN embedding space , where adversarial samples exhibit significant displacement patterns. Second, we build a novel prime-quantized space , that absorbs small perturbations through number-theoretic discretization, resulting in minimal displacement, while preserving discriminability. We then leverage the geometric discrepancies across spaces and to detect adversarial samples. To the best of our knowledge, we establish the first rigorous separation theory for adversarial detection, proving that adversarial samples create unavoidable geometric inconsistencies across both spaces. Our framework provides theoretical guarantees including pixel-level absorption bounds, neighborhood diameter concentration, Gromov-Wasserstein (GW) separation theorems, and practical risk control. Extensive experiments validate our theoretical predictions and achieve consistently strong detection performance across a wide range of attack types and model families.
Figures & tables
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | 97.9 | 68.9 | 82.7 | 52.0 | 74.1 |
| CW | 97.0 | 73.6 | 86.0 | 51.4 | 56.7 |
| PT | 98.0 | 86.4 | 67.8 | 50.7 | 57.3 |
| PGD | 97.8 | 91.3 | 74.4 | 51.1 | 81.0 |
| SA | 96.8 | 78.1 | 74.4 | 41.1 | 54.9 |
| SQ | 97.6 | 89.2 | 88.5 | 51.0 | 44.4 |
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.97 | 0.91 | 0.71 | 0.25 | 0.78 | 0.96 | 0.70 |
| ViT | 0.95 | 0.65 | 0.75 | 0.57 | 0.01 | 0.95 | 0.80 | |
| SQ | ResNet-18 | 0.96 | 0.89 | 0.85 | 0.24 | 0.01 | 0.90 | 0.57 |
| ViT | 0.95 | 0.66 | 0.86 | 0.56 | 0.02 | 0.89 | 0.61 | |
| PT | ResNet-18 | 0.98 | 0.86 | 0.54 | 0.26 | 0.03 | 0.89 | 0.80 |
| ViT | 0.95 | 0.66 | 0.67 | 0.54 | 0.01 | 0.89 | 0.81 |
Appendix figures & tables36 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
|---|---|
| Data & embeddings | |
| Dataset of images (dimension ). | |
| Label set and label of . | |
| CNN feature extractor. | |
| Embedding of . | |
| Prime quantization map with key and resolution . | |
| Attack Method | Parameter Values |
|---|---|
| AutoAttack (AA) | |
| C&W (CW) | |
| Patch Attack (PT) | |
| PGD | |
| Spatial Attack (SA) | max rotation: , max translation: of the image size |
| Square Attack (SQ) |
| Detection Method | Parameters |
|---|---|
| Mahalanobis Detector | |
| Feature Squeezing | distance metric: , squeezer: median smoothing (2 2), train_fpr=0.2 |
| MetaDetect | num_support = 1, num_query = 15, arch = conv3 |
| MagNet | norm reconstruction error, |
| Hyperparameter | Candidate Values | Optimal Value | Description |
|---|---|---|---|
| Local Gromov-Wasserstein features | |||
| Global Gromov-Wasserstein features | |||
| Entropic regularization strength |
| Hyperparameter | Candidate Values | Optimal Value | Description |
|---|---|---|---|
| Kernel | {linear, rbf, poly} | rbf | Choice of kernel function |
| {0.1, 1, 10, 100} | 1 | Regularization parameter | |
| {scale, auto, 0.01, 0.001} | scale | Kernel Coeff. for RBF |
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 97.8 | 91.7 | 74.4 | 46.3 | 81.9 | 97.5 | 69.5 |
| ViT | 95.7 | 49.8 | 70.3 | 57.5 | 49.4 | 93.2 | 77.5 | |
| SQ | ResNet-18 | 97.6 | 89.1 | 88.5 | 45.8 | 91.9 | 91.9 | 59.5 |
| ViT | 96.2 | 51.0 | 87.3 | 56.3 | 49.7 | 90.5 | 62.5 | |
| PT | ResNet-18 | 98.0 | 86.4 | 67.3 | 46.5 | 50.1 | 90.1 | 78.0 |
| ViT | 95.4 | 51.3 | 71.2 | 54.9 | 49.3 | 89.5 | 78.5 |
| Attack | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.99 | 0.81 | 0.69 | 0.49 | 0.51 | 0.99 | 0.72 |
| ViT | 0.99 | 0.72 | 0.72 | 0.57 | 0.49 | 0.96 | 0.89 | |
| SQ | ResNet-18 | 0.99 | 0.55 | 0.87 | 0.48 | 0.49 | 0.95 | 0.54 |
| ViT | 0.99 | 0.40 | 0.88 | 0.56 | 0.50 | 0.95 | 0.60 | |
| PT | ResNet-18 | 0.99 | 0.93 | 0.52 | 0.50 | 0.54 | 0.95 | 0.89 |
| ViT | 0.99 | 0.47 | 0.63 | 0.54 | 0.52 | 0.94 | 0.90 |
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.97/0.98 | 0.89/0.95 | 0.71/0.72 | 0.17/0.54 | 0.97/0.65 | 0.98/0.95 | 0.67/0.74 |
| ViT | 1.00/0.90 | 0.49/0.95 | 0.73/0.78 | 0.57/0.57 | 0.25/0.01 | 0.98/0.93 | 0.72/0.90 | |
| SQ | ResNet-18 | 0.96/0.97 | 0.88/0.89 | 0.83/0.88 | 0.16/0.52 | 0.22/0.01 | 0.89/0.92 | 0.60/0.54 |
| ViT | 0.95/0.94 | 0.50/0.98 | 0.93/0.80 | 0.56/0.57 | 0.40/0.01 | 0.88/0.90 | 0.63/0.60 | |
| PT | ResNet-18 | 0.97/0.98 | 0.87/0.84 | 0.62/0.49 | 0.17/0.57 | 0.55/0.01 | 0.91/0.88 | 0.72/0.91 |
| ViT | 0.99/0.93 | 0.50/0.98 | 0.75/0.61 | 0.53/0.56 | 0.25/0.01 | 0.89/0.87 | 0.72/0.92 |
| Ours | MD | FS | MAD | MN | |
|---|---|---|---|---|---|
| AA | 94.9 | 67.2 | 82.0 | 48.3 | 71.6 |
| CW | 93.8 | 72.1 | 85.3 | 48.9 | 54.2 |
| PT | 94.4 | 84.9 | 67.1 | 49.5 | 54.8 |
| PGD | 94.8 | 90.0 | 73.7 | 49.0 | 78.5 |
| SA | 93.4 | 76.7 | 73.7 | 39.2 | 52.5 |
| SQ | 93.4 | 87.7 | 87.8 | 48.5 | 41.9 |
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 95.6 | 50.00 | 68.9 | 45.8 | 91.00 | 94.9 | – |
| SQ | ResNet-18 | 96.7 | 50.00 | 84.2 | 45.5 | 49.00 | 89.6 | – |
| PT | ResNet-18 | 96.2 | 50.00 | 73.7 | 45.0 | 50.50 | 88.2 | – |
| AAD | ResNet-18 | 97.6 | 50.00 | 55.9 | 49.6 | 59.38 | 95.4 | – |
| PGN | ResNet-18 | 96.3 | 50.00 | 63.2 | 46.3 | 49.06 | 93.2 | – |
| BSR | ResNet-18 | 97.8 | 50.00 | 59.4 | 46.35 | 50.31 | 93.6 | – |
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.98 | 0.53 | 0.73 | 0.503 | 0.68 | 0.98 | – |
| SQ | ResNet-18 | 0.97 | 0.55 | 0.79 | 0.489 | 0.49 | 0.94 | – |
| PT | ResNet-18 | 0.99 | 0.52 | 0.71 | 0.45 | 0.50 | 0.95 | – |
| AAD | ResNet-18 | 0.99 | 0.49 | 0.55 | 0.495 | 0.45 | 0.96 | – |
| PGN | ResNet-18 | 0.98 | 0.50 | 0.66 | 0.488 | 0.44 | 0.95 | – |
| BSR | ResNet-18 | 0.99 | 0.50 | 0.62 | 0.488 | 0.43 | 0.95 | – |
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 1/0.93 | 0.50/1.00 | 0.65/0.82 | 0.05/0.55 | 0.92/1.00 | 0.98/0.97 | – |
| SQ | ResNet-18 | 0.98/0.96 | 0.50/1.00 | 0.84/0.76 | 0.05/0.52 | 0.42/0.06 | 0.89/0.91 | – |
| PT | ResNet-18 | 0.96/0.95 | 0.50/1.00 | 0.82/0.65 | 0.04/0.45 | 0.52/0.09 | 0.87/0.89 | – |
| AAD | ResNet-18 | 0.99/0.96 | 0.50/1.00 | 0.51/0.55 | 0.49/0.54 | 0.87/0.21 | 0.93/0.96 | – |
| PGN | ResNet-18 | 0.94/0.97 | 0.50/1.00 | 0.61/0.68 | 0.16/0.52 | 0.28/0.01 | 0.95/0.92 | – |
| BSR | ResNet-18 | 0.97/0.96 | 0.50/1.00 | 0.50/0.73 | 0.16/0.52 | 0.54/0.03 | 0.96/0.91 | – |
| Attacks | Model | Ours | MD | FS | MAD | MN | EA | BY |
|---|---|---|---|---|---|---|---|---|
| PGD | ResNet-18 | 0.96 | 0.66 | 0.72 | 0.10 | 0.96 | 0.97 | - |
| SQ | ResNet-18 | 0.96 | 0.66 | 0.79 | 0.09 | 0.10 | 0.90 | - |
| PT | ResNet-18 | 0.95 | 0.66 | 0.72 | 0.08 | 0.15 | 0.88 | - |
| AAD | ResNet-18 | 0.97 | 0.66 | 0.52 | 0.51 | 0.35 | 0.95 | - |
| PGN | ResNet-18 | 0.95 | 0.66 | 0.64 | 0.24 | 0.02 | 0.93 | - |
| BSR | ResNet-18 | 0.96 | 0.66 | 0.59 | 0.24 | 0.07 | 0.93 | - |
| Quantization | Seed | Mean Std | ||||
|---|---|---|---|---|---|---|
| 1 | 3 | 5 | 21 | 42 | ||
| Ours | 0.94 | 0.92 | 0.95 | 0.94 | 0.96 | 0.94 0.01 |
| Fibonacci | 0.62 | 0.61 | 0.55 | 0.60 | 0.68 | 0.61 0.04 |
| Logarithmic | 0.70 | 0.61 | 0.61 | 0.56 | 0.58 | 0.62 0.05 |
| Uniform | 0.65 | 0.65 | 0.60 | 0.56 | 0.65 | 0.62 0.03 |
| Accuracy 8 97.90 10 86.15 12 92.57 15 93.24 | Accuracy 3 97.90 5 95.60 7 83.45 10 85.35 |
| Corruption Type | Detection Accuracy | AUROC | Precision / Recall / F1 |
|---|---|---|---|
| Gaussian Noise | 96.43% | 0.99 | 0.97 / 0.96 / 0.96 |
| Method | Runtime (s) | CPU (GB) | GPU (GB) |
|---|---|---|---|
| BY | 0.152 | 2.00 | 0.60 |
| EA | 0.115 | 0.20 | 11.80 |
| MD | 0.141 | 0.68 | 0.10 |
| FS | 0.005 | 0.25 | 0.17 |
| MAD | 0.105 | 3.30 | 0.00 |
| MN | 0.012 | 0.78 | 0.10 |
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| CW | |||||
| SQ | |||||
| SP | |||||
| PT |
| Attack | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| CW | |||||
| SQ | |||||
| SP | |||||
| PT | |||||
| FG | |||||
| PGD |
| Attack / Method | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | |||||
| CW | |||||
| PT | |||||
| PGD | |||||
| SA | |||||
| SQ |
| Attack | Ours | MD | MN |
|---|---|---|---|
| AA | |||
| AA | |||
| CW | |||
| PT | |||
| PT | |||
| PGD |
| Attack | Ours | MD | MN |
|---|---|---|---|
| AA | |||
| AA | |||
| PT | |||
| PT | |||
| PGD | |||
| PGD |
| Attack | Dataset | Detection Accuracy / AUC | Precision / Recall / F1 | ||
|---|---|---|---|---|---|
| LLaVA-1.5 | Qwen-2.7B-VL | LLaVA-1.5 | Qwen-2.7B-VL | ||
| APGD | CalTech-101 | 89.50 / 0.99 | 89.63 / 0.99 | 0.89 / 0.89 / 0.89 | 0.89 / 0.89 / 0.89 |
| Food-101 | 90.44 / 0.99 | 87.72 / 0.99 | 0.90 / 0.90 / 0.90 | 0.87 / 0.87 / 0.87 | |
| CalTech-256 | 88.60 / 0.95 | 87.83 / 0.99 | 0.88 / 0.88 / 0.88 | 0.87 / 0.87 / 0.87 | |
| PGD | CalTech-101 | 89.50 / 0.99 | 87.13 / 0.99 | 0.89 / 0.89 / 0.89 | 0.87 / 0.87 / 0.86 |
| Food-101 | 87.13 / 0.99 | 88.42 / 0.99 | 0.87 / 0.87 / 0.87 | 0.88 / 0.88 / 0.88 | |
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | |||||
| CW | |||||
| PT | |||||
| PGD | |||||
| SQ | |||||
| UP |
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | |||||
| CW | |||||
| PT | |||||
| PGD | |||||
| SQ | |||||
| UP |
| Attack / Metric | Ours | MD | FS | MAD | MN |
|---|---|---|---|---|---|
| AA | |||||
| CW | |||||
| PT | |||||
| PGD | |||||
| SQ | |||||
| UP |
| Fraction of known | Detection rate (CIFAR-10) |
|---|---|
| 0% | 86.7% |
| 25% | 81.23% |
| 50% | 76.22% |
| 75% | 65.31% |
| 100% | 55.17% |
Adversarial Example Detection
Adversarial example detection identifies inputs crafted to exploit machine-learning models before they cause unreliable predictions.
See all 49 papers