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

Do Cheap Robustness Adapters Survive a Change of Dataset?

Adversarial training makes a classifier resist small, deliberately chosen input perturbations. It does this by attacking the model during every training step, which multiplies training cost many times over and is impractical for large pretrained vision models. Two recent lines of work avoid most of that cost. Both keep the large backbone frozen and train only a tiny add-on: either ten extra input tokens or low-rank adapters with their own normalization layers. Both report strong robustness, but only on the same dataset they were trained on.

Separately, the robustness literature shows that robustness transfers across datasets much worse than ordinary accuracy does. A model made robust on one digit dataset can keep moderate clean accuracy on another while its robust accuracy collapses to single digits. This note asks the obvious deployment question that nobody in the file has answered: when a cheap robustness add-on is trained on one set of image domains, how much of its robustness survives on a domain it has never seen? It then proposes a specific, compute-neutral change to how the add-on is trained, aimed at closing that gap.

Core Claim

The proposed change exploits a fact about cost that is easy to miss. Attacks that are shared across many images are cheaper to compute than per-image attacks, and they also generalize across datasets better. A per-image attack must be re-optimized for every example with several gradient steps. A shared perturbation can be kept in memory and nudged by one gradient step per batch, reusing the backward pass already paid for. Improving Out-of-Distribution Generalization by Adversarial Training with Structured Priors supplies the second half of the argument. It showed that per-image adversarial training does not help on held-out domains (60.6% average DomainBed accuracy against 61.3% for plain training), whereas a small per-domain dictionary of shared perturbations reaches 71.6%. However, it backpropagates through the whole network in every inner step.

Our claim is that training robustness tokens on a frozen foundation model with a mixture of two attacks, a persistent per-domain low-rank perturbation bank and a very short per-image attack, shrinks the source-to-target robust-accuracy gap. "Robustness tokens" here means a handful of learnable vectors appended to the image patch sequence, as in Robustness Tokens: Towards Adversarial Robustness of Transformers. The comparison is against tokens trained with per-image attacks alone, at the same number of forward-backward passes. If the claim holds, the result is robustness that travels across datasets at a cost similar to the cheapest existing defenses. If it fails, the experiments will still deliver the first measurement of how much parameter-efficient robustness degrades under cross-dataset validation.

Background and Positioning

The method side comes from two parameter-efficient defenses.

  • Robustness tokens. The tokens are trained so that, on clean images, the frozen model's features are unchanged, and on attacked images the features are pulled back toward the clean ones. On DINOv2-Giant this recovers white-box ImageNet accuracy from 0.3% to 63.1% within 200 optimization steps. The authors note that the defense relies partly on the tokens staying secret.
  • FullLoRA-AT. It shows that plain low-rank adaptation fails at adversarial robustness because layer-normalization parameters must shift substantially. It fixes this with adapters that include a learnable normalization layer. The result uses about 5% of the trainable parameters, about 75% of the training time of full adversarial fine-tuning on CIFAR-10, and is often only 1–2% behind full fine-tuning in robustness.

Neither paper evaluates on a dataset unlike its training data, and that missing evaluation is the gap this proposal addresses.

The motivation comes from On the Hardness of Robustness Transfer. It proves that the complexity term governing robust transfer exceeds the one governing standard transfer, and it reports that a model adversarially trained on MNIST reaches 49.9% clean accuracy on USPS while robust accuracy on SVHN falls to 5.9%. Its experiments use small convolutional networks only. Our frozen-backbone regime tests whether the collapse is a property of adversarial training in general or of networks small enough to overfit the source domain.

Probing Out-of-Distribution Robustness of Language Models with Parameter-Efficient Transfer Learning gives a reason for optimism. In language models, adapters beat full fine-tuning on out-of-distribution detection (95.83 against 93.73 AUROC on Banking77 with GPT-J), seemingly because a frozen backbone keeps its general features. Whether the same holds for adversarial robustness is open.

The main constraint comes from Adversarially Robust Models may not Transfer Better. It argues that adversarial training's apparent transfer benefit is really a regularization effect, finds robustness and transferability can be negatively correlated (Pearson down to −0.9), and shows Jacobian regularization and weight decay match adversarial training for clean target accuracy. We take this seriously by separating two targets. On held-out clean accuracy, cheap regularizers are a serious competitor and may win. On held-out robust accuracy, they have no mechanism to help, and the hardness result predicts they will not.

Towards Out-of-Distribution Adversarial Robustness treats different attack types as different domains and penalizes loss variance across them. That is a different axis of shift (attack type, not data source), and it compounds training cost rather than reducing it. We hold the attack type fixed and vary the data source.

Method

Let $g(x;t)$ be the frozen encoder's feature for image $x$ with tokens $t$ appended, and let $g(x;\varnothing)$ be the original feature without tokens. Let $h$ be a linear head trained on source domains, and $d$ the source domain of example $x$. Each source domain has a dictionary $D_d$ of $k$ shared perturbation images. A sample's structured perturbation is $D_d c_x$, where the coefficient vector $c_x$ is chosen by one ascent step and projected to the threshold-model budget. The training objective is

$$\min_{t,h}\ \mathbb{E}_{(x,y,d)}\Big[\ell\big(h(g(x;t)),y\big) + \lambda\,\big\|g(x+\delta_x;t)-g(x;\varnothing)\big\| + \mu\,\big\|g(x+D_d c_x;t)-g(x;\varnothing)\big\|\Big],$$

where:

  • $\delta_x$ is a per-image perturbation from a one- or two-step attack;
  • $\lambda$ and $\mu$ weight the two correction terms;
  • $\ell$ is cross-entropy.

The dictionaries are persistent. After each batch they take a single gradient-ascent step using the input gradient already computed for the token update, so they add almost no compute.

The intuition follows the structured-priors paper. Domain-shared perturbations are pushed toward directions that exploit whatever a whole domain has in common, such as background, sensor, or style. Correcting those directions should matter on a new domain, whereas correcting idiosyncratic per-image directions may not. Because the backbone is frozen, all of this capacity lives in about ten tokens, limiting how much the defense can memorize the source domains.

Rank sensitivity is the known weakness of the structured-priors method: too low a rank gives too little attack capacity, while too high a rank turns the dictionary back into per-image attacks. We sweep $k$ explicitly and report the full curve rather than a tuned point.

Evaluation follows leave-one-domain-out cross-dataset validation:

  1. Train on all but one domain.
  2. Measure on the held-out domain.
  3. Report four numbers: source clean accuracy, source robust accuracy, target clean accuracy, and target robust accuracy.

All robust numbers use AutoAttack as standardized by RobustBench, which found that published robustness was sometimes overstated by more than 10 points. We run it in two settings: attacking the frozen model unaware of the tokens, and a fully adaptive setting in which the attacker differentiates through the tokens. The adaptive number is the headline, because robustness that depends on keeping the tokens secret is not robustness against an attacker who obtains them.

Proposed Experiments

Main suite: DomainBed. We run all five datasets used by the structured-priors paper (PACS, OfficeHome, VLCS, NICO, Colored MNIST) so that average clean target accuracy is directly comparable to its reported numbers. The backbone is frozen DINOv2 at two sizes (Small and Base, with Giant if compute allows), plus OpenCLIP's image encoder. The threat model is $\ell_\infty$ at 4/255, with $\ell_2$ as a secondary check.

Bridge: Digits. We use the same five domains and the same 7,438-image subsampling as the hardness paper. Inputs are upsampled for the transformer, so we can see whether its MNIST-to-SVHN robust collapse reappears under a frozen backbone. The architectures differ, so we will compare the gap (source robust accuracy minus target robust accuracy), not raw numbers.

Compositional shift: OfficeHome and DomainNet subsets of CG-Bench. This tests whether robustness transfers to unseen class-domain combinations, using the protocol of Enhancing Compositional Generalization via Compositional Feature Alignment.

Compute accounting. Every method is reported in total forward-backward passes through the backbone and in GPU-hours on the same hardware. Wherever a comparison claims "same compute," methods are matched on passes.

Baselines

Undefended reference. The naive reference point is the frozen backbone with a linear head trained by ordinary cross-entropy on source domains, with no defense. It fixes the clean-accuracy ceiling the defenses should not fall far below, and the robust-accuracy floor they must rise above on every held-out domain. Beating it on target robust accuracy is trivial. The bar is beating it on target robust accuracy while losing no more than one point of target clean accuracy.

Robustness tokens as published. This is ten tokens trained with the invariance and correction losses under multi-step per-image attacks. It is the closest existing method and the most direct competitor, since our proposal changes only the attack distribution the tokens see. We run it with the same backbone, tokens, head, and number of backbone passes as ours, and tune its step count and step size on the same validation split (source-domain held-out images only, never the target domain). The paper reports 63.1% white-box ImageNet accuracy for DINOv2-Giant. That is in-distribution and likely non-adaptive, so it is a sanity check for our reimplementation rather than a cross-dataset reference. We count ourselves as beating this baseline if the adaptive-attack target robust accuracy, averaged over held-out domains, is higher at equal passes, with the source-target gap smaller across at least four of the five DomainBed datasets.

FullLoRA-AT. These are normalization-aware low-rank adapters trained with per-image adversarial training. They are the strongest parameter-efficient competitor with more capacity than tokens, and they test whether extra adapter capacity overfits source domains or helps transfer. They receive the same pass budget and tuning grid. Note that FullLoRA-AT's reported 75% of full fine-tuning time already implies a much larger budget than tokens, so we also report it at its native budget. No reported cross-dataset result for FullLoRA-AT or robustness tokens was found on Lacuna.

Strongest cross-dataset method. This is the structured-priors paper's multiple-perturbation adversarial training, with full backbone updates. It reports 71.6% average clean held-out accuracy on the five DomainBed datasets, though not on a frozen foundation model and without robust target accuracy. We rerun it on our backbones at its native cost. This tells us how much of its clean-transfer benefit survives when the structured perturbation is moved into a tiny add-on at a fraction of the compute. A clean target accuracy within two points of it at under a tenth of the passes, together with higher target robust accuracy, would count as a win. Full adversarial fine-tuning of the backbone with per-image attacks is included as the expensive upper reference.

Ablations. These isolate the key ingredient. We train tokens:

  • with the dictionary term only;
  • with the per-image term only, at matched passes;
  • with a single dictionary shared across all domains instead of one per domain, to test whether domain labels matter;
  • across a sweep of dictionary rank $k$.

If per-domain structure is not what helps, the single-dictionary and per-image-only variants will match the full method.

Why not just…?

Why not just evaluate robustness tokens and FullLoRA-AT cross-dataset and stop there? That evaluation is the first deliverable of this proposal, and it might turn out to be the whole story. If the frozen backbone alone keeps the source-target robust gap small, the dictionary adds nothing. The ablation comparing per-image-only tokens with the full method at equal passes settles this directly, and we will report a null result plainly. The reason to expect a gap is the hardness paper's theory, which does not depend on architecture size. The language-model adapter results, however, point the other way, so this is a real open question rather than a straw man.

Why not just regularize with Jacobian penalties or weight decay, which the transferability paper shows match adversarial training for transfer at far lower cost? For clean target accuracy this is a real threat, and we include Jacobian-regularized tokens and adapters at equal passes expecting them to be competitive. For target robust accuracy, nothing in that paper or elsewhere in the file shows such regularizers produce resistance to worst-case attacks. The hardness paper shows clean and robust accuracy transfer very differently. The experiment that decides this is the target robust accuracy column. If regularized tokens come within two points of ours there, the adversarial ingredient is unnecessary and we will say so.

Why not just use plain LoRA or compositional feature alignment, which already improve out-of-distribution accuracy? FullLoRA-AT documents that plain LoRA leaves vision transformers non-robust because it cannot make the needed normalization shifts. Compositional feature alignment trains against natural domain variation, not gradient-directed attacks, and it unfreezes the encoder in its second stage, which costs what we are trying to avoid. Both are run as clean-accuracy baselines on CG-Bench and DomainBed. Their robust accuracy under AutoAttack is expected to stay near the undefended floor, and a measured value contradicting that would be reported.

Decisive Checks

The proposal stands or falls on three measurements:

  1. Does the gap exist? Under adaptive AutoAttack with leave-one-domain-out validation, the drop from source to target robust accuracy for published-style robustness tokens should be clearly larger than their drop in clean accuracy. If it is not, the motivating gap does not exist for frozen backbones, which is itself a useful finding that contradicts small-network extrapolations of the hardness result.
  2. Does the dictionary help at equal cost? At matched backbone passes, adding per-domain dictionary perturbations should shrink that robust gap on most held-out domains. The single-dictionary and per-image-only ablations show whether domain structure is responsible.
  3. Does the defense survive an informed attacker? The improvement must hold when the attacker differentiates through the tokens. A defense whose transfer advantage vanishes under adaptive attack would be recorded as a negative result about the secrecy assumption rather than a method.