Keep the Object, Sample the Background: Self-Supervised Salience as a Token Budget for Fast Adversarial Training of Vision Transformers

Adversarial training makes an image classifier robust to small, deliberately crafted pixel perturbations. It does this by repeatedly attacking the model during training and learning from the attacked images. That inner attack loop is why it costs many times more than ordinary training. For vision transformers (ViTs), models that cut an image into a grid of patches and let every patch exchange information with every other, the cost grows with the number of patches processed in every attack step and every weight update. This suggests an obvious saving: process fewer patches. But which patches can a robust model afford never to see during training?

We propose answering that question with a signal computed once per image. A frozen self-supervised ViT such as DINOv2 produces attention maps that cover whole objects without ever being told where objects are. We cache those maps, apply the same crops and flips to them as to the images, and train the robust model only on the salient object patches plus a small random sample of background patches. Both the attack steps and the weight updates use this reduced set, starting at the very first layer. At test time the full image is restored. The claim is concrete and falsifiable. At aggressive token budgets of 25–50% of patches, a whole-object salience prior plus sampled background gives a better trade-off between robustness and training compute than three alternatives: random patch dropping, attention-guided dropping inside the model being trained, and simply training at lower resolution.

Core Claim

The closest existing work is Attention Guided Adversarial Training (AGAT), Towards Efficient Adversarial Training on Vision Transformers. AGAT ranks patches by summing attention scores from the very model being adversarially trained, then drops low-ranked patches progressively across layers. On ImageNet ViT-Base it reports 35% less wall-clock time, over 40% fewer FLOPs, and 51.23% robust accuracy under a 20-step projected gradient attack (PGD-20), against 50.55% for single-step fast adversarial training.

Our proposal differs from AGAT in three ways that matter.

First, the importance signal is external and fixed. It comes from a self-supervised model whose attention is known to cover whole objects. AGAT's signal comes from a classifier trained with labels, and Distilling Self-Supervised Vision Transformers for Weakly-Supervised Few-Shot Classification & Segmentation shows that such attention collapses onto narrow discriminative parts, such as a bird's beak. Pyramid Adversarial Training Improves ViT Performance adds that pixel-level adversarial training itself pushes attention toward object centers. A self-ranking signal can therefore feed its own collapse: the model drops the context it has stopped attending to.

Second, because the signal exists before the network runs, we can drop patches at the input. Every layer then sees the shorter sequence. AGAT must keep early layers at full length, because its ranking is only meaningful in deeper layers.

Third, we deliberately keep a random sample of background patches. What Makes Pre-Trained Visual Representations Successful for Robust Manipulation? finds that failures under visual shift are driven by attention drifting onto background distractors. Improving the Robustness of Transformer-based Large Language Models with Dynamic Attention finds that text attacks work by redirecting attention to irrelevant tokens. Together these say that a model never trained against perturbed background is likely to leave exactly the hole an attacker would use.

One honest point on compute. At 224-pixel input, ViT-B/16 has 196 patches with width 768, so the per-layer cost of the feed-forward and projection layers (proportional to $rNd^2$) dominates the attention term (proportional to $r^2N^2d$). Here $r$ is the fraction of patches kept, $N$ the patch count and $d$ the width. Savings at standard resolution are therefore roughly proportional to $r$. The quadratic benefit only appears at higher resolution, which we test separately rather than assume.

Research Program

Salience maps. We compute salience once per training image with a frozen DINOv2-Small, using last-layer attention from the classification token to the patches. This costs one small forward pass per image and is cached. When training applies a random crop or flip, the same transform is applied to the cached map, which is then resampled to the 14×14 patch grid. The paper behind FOCUS and Leopart supplies the method here: both use DINO-family attention as a zero-cost foreground prior. Neither touches robustness or training cost.

Keep set and training step. For each image the keep set has two parts. The first is the smallest group of patches covering a target fraction of salience mass, capped at a foreground budget $r_f$. The second is a uniform random draw of background patches at rate $r_b$, so the total kept fraction is $r = r_f + r_b$. Positional embeddings are retained for every kept patch. The attack is single-step with random start, following Fast is better than free: Revisiting adversarial training. The perturbation, the attack's backward pass and the weight update all operate on kept patches only. An optional final short phase trains on full sequences to close the gap between training and test inputs; it is reported as an ablation.

Questions we will answer. The program answers four empirical questions:

  1. Does a fixed, whole-object prior beat a learned in-model prior and a random prior when compute is matched?
  2. How does the gain scale with the token budget $r$?
  3. Does sampling background ($r_b > 0$) close the vulnerability to attacks on background that we expect at $r_b = 0$?
  4. Does input-level dropping stabilize fast training against catastrophic overfitting, the sudden collapse to zero robust accuracy that single-step training suffers? AGAT reports exactly this stabilizing effect for its own dropping on large ViTs.

We also measure each trained model's emergent segmentation, the overlap (Jaccard index) between its attention maps and object masks, following Burns et al. This tests whether salience-guided training avoids the attention collapse that PyramidAT attributes to pixel-level adversarial training.

Baselines

Full-sequence fast adversarial training. The naive reference is single-step adversarial training with random start on full sequences (Wong et al.), run on the same ViT-B/16, epochs, augmentation and perturbation size. Wong et al. report 43% robust accuracy on ImageNet in 12 hours. The file does not pair that figure with a ViT. The relevant ViT-Base number is AGAT's report of 50.55% PGD-20 accuracy for fast adversarial training. We count our method as matching this baseline if it stays within one point of its AutoAttack robust accuracy at no more than half the training FLOPs.

AGAT. The strongest existing method is AGAT itself, reported at 51.23% PGD-20 robust accuracy on ImageNet ViT-Base with over 40% FLOP savings. It is the strongest competitor because it already exploits patch dropping during adversarial training and already reports stability against catastrophic overfitting. We reimplement it with the paper's layer-wise exponential dropping schedule in our pipeline. We tune its dropping rate to hit the same total training FLOPs as each of our budgets, and give each method the same hyperparameter search budget over learning rate and step size.

All methods are evaluated with AutoAttack under the RobustBench protocol (RobustBench: a standardized adversarial robustness benchmark) at $\ell_\infty$ radius 4/255, rather than PGD-20 alone. RobustBench documents overestimates of more than 10 points from weaker attacks. Beating AGAT means higher AutoAttack robust accuracy at equal measured FLOPs and wall-clock time, by more than the seed-to-seed spread across three seeds.

Isolating ablations. Two ablations isolate the key ingredients. The first swaps AGAT's self-attention ranking for our cached DINOv2 ranking while keeping AGAT's progressive schedule. This separates the effect of the salience source from the effect of dropping at the input. The second sets $r_b = 0$, keeping salient patches only. This isolates the role of sampled background.

External reference points. For calibration we also cite the large-scale recipe of Revisiting Adversarial Training for ImageNet. It reports 50.2% robust accuracy at radius 4/255 for ConvNeXt-T with a convolutional stem, and roughly 20,000 single-GPU hours for its experimental suite. This shows how much compute the field currently pays for this accuracy; it is not a matched comparison.

Why not just…?

Why not just drop patches at random? This is the real threat. Random patch dropping is free, unbiased toward foreground or background, and acts as a regularizer in its own right. No reported result found on Lacuna for random token dropping during adversarial training of ViTs, so we cannot dismiss it from the literature. Our prediction is narrow. At generous budgets ($r \geq 0.7$) random dropping should roughly tie, because the object almost always survives. At aggressive budgets ($r \leq 0.4$), random dropping often removes most of the object, so both the clean label signal and the useful attack directions degrade. The salience prior should then win by a growing margin.

If random dropping matches us across every budget, the honest conclusion is that ViT adversarial training cost is reducible by token count alone and salience is unnecessary. We would report that as the finding.

Why not just train at lower resolution? Downsampling images to reach the same token count is the simplest compute-matched alternative. It keeps every region of the image, but blurs the fine detail a high-resolution attacker can target. We train at the resolution whose token count equals each budget and evaluate at full resolution, after brief fine-tuning at full resolution. If this matches our method, salience adds nothing over simple coarsening.

Why not just use AGAT, perhaps with better attention? The swap ablation answers this directly. If AGAT's schedule with DINOv2 rankings recovers all of our gain, the contribution is only the signal and not input-level dropping. That would still answer AGAT's own open question about supervised attention, but it would narrow our claim.

Why not skip retraining with Robustness Tokens? Robustness Tokens restores DINOv2-Giant accuracy under white-box attack from 0.3% to 63.1% after 200 steps. However, the authors frame the tokens as a private key, and the benefit is concentrated in giant models. That answers a different question, deploying a frozen model whose tokens stay secret, than producing ViT-B weights that stay robust when everything is public. We do not compete with it, and we note that the two approaches could be combined.

Proposed Experiments

Pilot sweeps. Short sweeps on CIFAR-10 with small-patch ViTs set step sizes and screen budgets of $r \in \{0.25, 0.4, 0.55, 0.7\}$ with $r_b \in \{0, 0.1, 0.2\}$. We record catastrophic overfitting incidence across five seeds and three step sizes for each method. The prediction is that input-level salience dropping reduces collapse at least as much as AGAT does.

Main experiment. The main experiment trains ViT-S/16 and ViT-B/16 on ImageNet-1K and plots AutoAttack robust accuracy against measured training FLOPs and GPU hours. The plot covers full-sequence fast training, AGAT, random dropping, resolution reduction and our method, with clean accuracy reported alongside. The decisive check is whether, at $r \leq 0.4$ and matched FLOPs, our method beats both random dropping and AGAT on AutoAttack accuracy beyond seed spread.

Restricted attacks. A second check uses attacks confined to the foreground or to the background, defined by object masks at test time. The prediction is that the $r_b = 0$ variant shows a measurable drop under background-only attacks, and that $r_b > 0$ closes it. If no gap appears even at $r_b = 0$, the background-drift argument does not apply to $\ell_\infty$ attacks, and we would say so.

Higher resolution. A third check repeats the frontier at higher input resolution, where the attention term grows relative to the feed-forward term. This tests whether savings grow faster than linearly in $r$, as the cost analysis predicts.

Secondary measures. Finally, we report emergent-segmentation Jaccard scores for every trained model. We also report ImageNet-C, ImageNet-R and ImageNet-Sketch accuracy, where PyramidAT reports 41.42 mCE, 53.92% and 41.04% respectively for ViT-B/16. These test whether keeping the whole object during training also preserves the broad object attention that PyramidAT links to robustness under natural distribution shift, at a fraction of its cost.