Evaluate the defense that is actually deployed
Include preprocessing, rejection, randomness, and state in the attacked computation and validate candidates through its real forward path.
On this page
The question for today
What you’ll understand
- Specify a complete defended forward computation.
- Distinguish backward approximations from altered forward models.
- Estimate stochastic attack objectives and validate success with fresh randomness.
A denoising defense appears strong when an attack is run against the original classifier and its outputs are cleaned afterward. That experiment measures a particular nonadaptive candidate generator. It does not test an attacker who knows the denoising step and optimizes against the defended system. Adaptive evaluation begins by drawing the full prediction path, including detection, rejection, randomized transforms, and state. The evaluator then chooses objectives and estimators suited to that path while preserving the original threat constraints. The key question is whether valid candidates fail under the real deployed computation.
Keep the defended forward path intact
If the service predicts with a classifier after a transform, every candidate must be evaluated after that transform. If it rejects suspicious inputs, define whether rejection is a permitted safe outcome and include that rule in the success predicate. Optimizing only the classifier loss may find candidates that the detector rejects, while optimizing only detector acceptance may leave classification correct. A useful adaptive objective must address the actual conjunction of conditions required by the declared failure event.
A nondifferentiable operation may require a backward-pass differentiable approximation to obtain a search direction. Preserve the genuine operation in the forward pass and substitute only a justified derivative approximation during candidate generation. Replacing the transform in both directions evaluates a different system. The approximation is a heuristic, so inspect several surrogate choices and always verify final candidates through the original forward path. A successful feasible counterexample remains valid regardless of whether its search derivative was exact.
Attack a distribution rather than one lucky seed
For randomized preprocessing, a fixed-seed gradient can optimize one realization that does not represent the service’s output distribution. An expectation-over-transformation estimator averages loss gradients over independently drawn transformations when the relevant derivatives and differentiation-under-expectation assumptions hold. The expected surrogate loss is still different from misclassification probability. Use it to search, then separately estimate the declared failure probability or aggregated-output failure on fresh random draws.
Count every transformation sample in the attack’s resource budget. Twenty iterations with eight sampled forward-backward pairs per iteration use 160 such pairs, before candidate validation. Compare estimator variance across sample counts and investigate unstable directions. Reusing random draws can reduce variance in some comparisons but changes dependence and must be documented. Do not tune a candidate on a set of seeds and then present its performance on those same seeds as an unbiased estimate of future randomized behavior.
Adapt methodology without changing the threat
Read the defense’s claimed mechanism and identify why ordinary attacks might fail computationally. Optimization loops, hard quantization, randomization, or unusual logits each suggest different diagnostic experiments. Adapt losses, estimators, and initialization to that mechanism. Keep norm, epsilon, attacker access, and success policy fixed unless a separate experiment explicitly changes them. Showing failure under a larger threat does not refute a smaller stated guarantee, while using an artificially weaker attacker can inflate apparent robustness.
Separate development cases for attack design from the held-out report set. Save the selected adaptive protocol and its exact budgets before the final evaluation. Preserve intermediate evidence when a defense-aware search improves on a generic suite, including candidate feasibility, true forward outputs, and the role of the approximation. An automated suite provides a reproducible baseline, but a novel defense may need additional analysis. No finite collection of adaptive attack failures converts the search into a proof of the universal robustness property.
Work it through
Average gradients and account for their cost
Two independent transformation samples produce local surrogate gradients (2,0) and (0,4) at one feasible input. Use their mean for an infinity-budget sign direction with ε=0.1, assuming no domain clipping. Also count forward-backward sample pairs for 20 iterations with 8 transformations per iteration.
The two-sample gradient mean is ((2+0)/2,(0+4)/2)=(1,2). The infinity-budget sign direction therefore proposes δ=(0.1,0.1).
The averaged first-order surrogate increase is (1,2)·(0.1,0.1)=0.3 loss units. This is a local expected-loss estimate, not a claim that either or both transformed decisions are incorrect.
The larger run uses 20×8=160 sampled forward-backward pairs. Any extra repeated forward evaluations used to measure the final failure event must be counted separately.
The estimator, feasible direction, and validation statistic have different roles. Averaging gradients supplies a search direction while the real stochastic forward path determines whether the attack succeeds.
The living notebook
Explore the model
Interactive lab · reliability
A decision rule changes what counts as success
Reset, set Replica count n to 5 and Unavailable replicas k to 2. Predict 3 available, majority threshold 3, and majority available before Step. Reset, explicitly set n=5 and k=3, then Step: predict 2 available and no majority. This fixed replica-count instrument illustrates an explicit decision threshold. It does not model randomized model votes, classifier confidence, consensus correctness, or an adaptive attack.
- Available replicas
- 4 of 5
- Majority needed
- 3
- Majority available?
- Yes
A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA test must use the system’s complete output rule rather than an intermediate score.
Pause & reason
Check your understanding
Your turn
Try it yourself
Three sampled gradients are (1,−2), (3,0), and (−1,2). Compute their mean and its sign step for ε=0.05 with sign(0)=0. How many sampled gradient evaluations do five such iterations require before validation?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Average each coordinate and count every sampled transformation in every iteration.
Compare with the solution
The mean is (1,0), so the proposed sign step is (0.05,0) before projection. Five iterations with three samples each require 15 sampled gradient evaluations. These arithmetic results do not estimate a failure probability; evaluate the resulting candidate with the real output rule and fresh randomness according to the declared protocol.
Keep the idea
Take it with you
- Adapt attacks to the complete defended computation.
- Derivative approximations do not replace the true validation forward path.
- Stochastic search and stochastic success measurement require separate budgets.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.