Manuscript Offprint
arXiv:2611.00585Conic Certification of Transformer Attention
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Attention is the computational core of large language models, yet the verifiers that bound how far an attention head's output can move under input perturbations give no guarantee on how loose their bounds are. A weak certificate therefore cannot be told apart from a fragile model. We develop a conic programming theory of attention certification that supplies this guarantee. We prove that the difficulty lies not in the softmax but in the bilinear interaction of a varying query with the keys. This interaction makes certification NP-hard over boxes and inapproximable once the attention logits can move by a constant amount. A fixed query or listed token substitutions, by contrast, make the exact worst case efficiently computable. An exponential cone moment relaxation then certifies a head with an error bounded quadratically in the perturbation radius by computable quantities, an order that cannot be improved. We also show that relaxations that treat a network one operation at a time, linear bound propagation among them, pay on second-order terms a sum of per-operation maxima instead of one coupled maximum. Computational results on GPT-2 indicate that the theory carries over to a trained model. Against exact worst cases with the query fixed, the certificate attains the predicted second-order accuracy. It is tighter than linear bound propagation on every head, and the looseness of bound propagation tracks the predicted per-operation excess.
Keywords: certified robustness, transformers, self-attention, conic programming, exponential cone, semidefinite relaxation, linear bound propagation, neural network verification, computational complexity, trustworthy artificial intelligence
1 Introduction
Transformers [1] have become the computational substrate of modern artificial intelligence, and how their behaviour can change under a change of their inputs has become a central question of trustworthy artificial intelligence. Adversarial examples [2, 3], and their counterparts for language models [4], show that small and deliberately chosen changes can redirect what a model computes. A certificate answers the question for all inputs at once. Given a set of admissible inputs and a quantity read linearly from the model, such as a logit margin, it returns a number that the quantity provably cannot exceed anywhere in the set. A certificate is sound when it never underestimates the worst case, and it is useful only to the extent that it does not overestimate it by much.
For networks of piecewise-linear units, certification is mature. Complete methods solve the problem exactly by satisfiability modulo theories, mixed-integer programming or branch-and-bound [5–7]. Incomplete methods relax it by linear programming, bound propagation, abstract interpretation or semidefinite programming [8–13], and the limits of relaxing one neuron at a time are relatively well understood [14]. Attention is different. It couples a bilinear interaction between tokens with the softmax normalization. The verifiers built for it propagate linear bounds or zonotopes through the two operations separately [15–17], with convex bounds on the softmax itself [18], or work at the level of the text [19, 20], and randomized smoothing [21] offers probabilistic guarantees of another kind. For sparsemax attention, mixed-integer programming finds the exact worst case [22], and Rezazadeh and Gholami Davoodi [23] compute the tightest bound on the softmax that score intervals alone allow. These verifiers are sound and can be fast. None of them, however, comes with a guarantee on how far its bound lies from the true worst case or on how that distance scales with the perturbation, and the complexity of the underlying problem has not been mapped. A loose certificate therefore cannot be attributed either to the method or to the model.
This paper develops a theory of attention certification based on conic programming. Its object is the central primitive of a transformer, namely one attention head with fixed weights, input tokens varying in convex sets, and a linear functional of the head's output. The construction rests on one observation. The softmax, usually regarded as the obstacle, has a rigid structure. The exponential cone represents the exponential in it exactly from below, and a secant bounds it from above with a slack known in closed form. The difficulty lies instead in the bilinear score between a query and a key. Lifting the problem into a moment matrix meets this difficulty by coupling where a head attends with what it reads.
The ingredients are classical, and the novelty lies in what is proved about them. They are moment relaxations of nonconvex quadratic problems [24–26], the exponential cone of relative entropy programming [27], the hardness of the cut norm [28] and Dinkelbach's method of fractional programming [29]. Semidefinite certificates for ReLU networks [12], curvature-based certificates for smooth networks [30] and Lipschitz analyses of attention [31] neither relax the softmax nor establish an order of accuracy in the perturbation radius. What this paper contributes is an accuracy theory for the coupled problem. It proves that the moment relaxation is accurate to second order in the perturbation radius, with constants that do not depend explicitly on the sequence length or the dimension, and that this order is attained, so it cannot be improved. It also identifies the computable quantity at the core of the error. Semidefinite relaxations of quadratic problems that are exact at a nominal instance can remain exact under small changes of the data [32]. Here, the admissible set grows from a point, and the gap of the relaxation is of exact second order. The paper also maps the complexity of the problem, with exact algorithms against which certificates are measured. Moreover, in the spirit of the convex barrier of Salman et al. [14] but at second order, it identifies the loss that relaxations treating one operation at a time cannot avoid.
The results form three strata. The first locates the difficulty. The softmax does not make certification hard. Its Lipschitz and interval bounds do not grow with the context or the dimension, and relaxed attention patterns obey an exact identity that weights their slack by the values the head reads. Hardness comes from the bilinear score alone. With a varying query and tokens in boxes, certification is NP-hard already for two tokens, and inapproximable once the attention logits can move by a constant amount. With a fixed query, the exact worst case is the root of a separable scalar equation, computed in polynomial time for boxes and ellipsoids, and listed token substitutions are solved exactly for any query.
The second stratum constructs the certificates. A linear program over the admissible attention patterns is solved greedily, with a first-order gap that does not depend explicitly on the dimension. Its solution exhibits a worst admissible attention pattern, and its sensitivities show how the bound responds to the values of the keys and to the attention bounds. A level-one exponential cone moment relaxation has a gap bounded by a value-weighted secant slack. This slack vanishes quadratically in the score width and hence in the perturbation radius. The gap of the relaxation is of exact second order already for a head with two keys and a fixed query, in which one key varies in a disc. The radius certified to a given accuracy therefore grows like the square root of the tolerance. Safe dual bounds with an explicit rounding allowance, and an exact reduction to each head's subspace, make the certificate robust to solver inaccuracy and affordable on a trained model.
The third stratum explains the looseness of bound propagation. Relaxations that bound one operation at a time include linear bound propagation with any choice of slopes. On second-order parts and remainders, they pay a sum of per-operation second-order maxima, whereas the exact term is one coupled maximum. The excess grows with the effective rank of the coupled term.
The theory is tested on synthetic heads and on all heads of GPT-2 small [33], with perturbations of the normalized tokens that each head reads. Against exact worst cases with the query fixed, the gap of the second-order certificate grows quadratically in the perturbation radius, as predicted. The certificate is tighter than the linear bound propagation methods CROWN [9] and -CROWN [34] on every head, typically by a factor of four to twenty. On the remainders of GPT-2 blocks, the looseness of CROWN tracks the predicted per-operation excess and exceeds it only by a small factor. The code and the exact worst cases are publicly available.
https://github.com/chimera1001/conic-attention-cert
The paper is organized as follows. Section 2 sets up the problem, the quantities that control it and the structure of the softmax, and Section 3 maps the complexity of certification. Section 4 constructs the two certificates and Section 5 describes how they are computed. Section 6 analyses per-operation relaxations, Section 7 reports the computational results and Section 8 concludes. Proofs are collected in Appendix A, and the relaxation is written out in Appendix B.
A transformer processes a sequence of tokens , the residual stream. In the pre-normalization architecture of GPT-2, each block adds to the stream the outputs of attention heads and then of a multilayer perceptron, so that
where LN denotes layer normalization [35], defined by
where is the centring projection and and are a learned gain and bias. The perceptron applies the Gaussian error linear unit [36] between two affine maps. A head maps the normalized tokens to queries, keys and values through matrices and and biases , and writes back through . At a query position with a causal mask, it attends to the positions with scores and weights
and its output is
In the language of mechanistic interpretability [37], the head composes a query-key circuit, which decides where to attend, with an output-value circuit, which decides what is written. Without biases the two circuits are, respectively, a bilinear and a linear map of the tokens, namely
Biases are absorbed by appending a unit coordinate to every token, so every statement below is made for the bias-free form (5) and holds verbatim for affine scores and values, with all norms and constants computed in the extended coordinates. GPT-2 small has 12 blocks of heads, and [33].
The certification problem concerns one head with fixed matrices and , a query position and the keys , , that it attends to; in a causal transformer the query is itself one of the keys. Each token varies in a compact convex set, written in base coordinates as
where is the nominal token, and is a ball , a box or the point of a fixed token. A ball makes an ellipsoid, and the radius of a box is its circumradius . For an input , the scores, the pattern and the output are, respectively,
A specification is a vector , and the quantity to be certified is . It is the projection of the head's output on a probe or steering direction or, with the difference of two rows of the unembedding matrix, the direct contribution of the head to a logit margin, with the scale of the final layer normalization frozen.
Definition 1 (Head certification problem) The worst case of the specification over the admissible inputs is
A certificate is a number computed by a procedure that is valid for every instance, and its gap is .
Lower bounds come from the same problem with -c. Problem (8) is nonconvex for two reasons that the rest of the paper separates. The scores are bilinear in the tokens whenever the query varies, and the pattern is a nonlinear function of the scores that multiplies the values. Because the residual connection adds the output of each head linearly, the contribution of one head to the residual stream, or to a quantity read linearly from it, is an instance of the head certification problem (8).
Accuracy is measured by how the gap behaves as the perturbation shrinks. When the sets are scaled by a radius , a certificate is of first order if its gap is and of second order if it is . The output moves by , so a first-order certificate overestimates the worst case by a fixed fraction of the output's range of motion however small the perturbation. A second-order certificate, by contrast, becomes exact relative to that range as . Equivalently, the largest radius at which a certificate is within a tolerance of the truth grows like for the first and like for the second. Interval bounds are of first order for attention, and for the linear bound propagation and zonotope verifiers of transformers no order of accuracy has been established.
The certificates are values of conic programs. Given a proper cone and data and of compatible sizes, the primal and dual programs are, respectively,
with dual cone . They satisfy weak duality without assumptions, so any dual feasible point certifies an upper bound [38]. Four cones are used, namely the nonnegative orthant, the second-order cone , the cone of positive semidefinite matrices and the exponential cone
which interior-point methods handle in polynomial time [27, 39]. The constraint states . This is why the exponential inside the softmax can be represented exactly in a conic relaxation. Nonconvex quadratic problems in a vector are relaxed by lifting, in which a symmetric matrix replaces the products in the moment matrix
so that every quadratic expression becomes linear in X. This is the Shor relaxation [24], the first level of the moment hierarchy [25]. Products of valid constraints expressed in X tighten it, as in the reformulation-linearization technique [26]. For a quadratic objective over one ball the Shor relaxation is exact by the S-lemma [40], and for bilinear objectives over boxes it is exact up to the Grothendieck constant [28].
The accuracy of every certificate below is governed by a few quantities computed from the instance before any optimization, collected in Table 1. The first step bounds each score over the whole admissible set by certified intervals
Their widths and the score width measure how far the attention logits can swing. The midpoints define the midpoint pattern . Its dispersion and the margin are, respectively,
The dispersion lies in for , small when is close to one-hot and largest when it is uniform. It enters none of the bounds and serves to describe how concentrated the attention of a head is. The margin, when positive, certifies that one key dominates all others on the whole set.
From the score intervals follow certified intervals for the attention weights in closed form. They also give an interval for the normalizer and intervals for the log-attention , namely
of widths and maximal width , the secant width. Since and , the widths satisfy
The second-order certificate represents exactly and by the secant of the exponential on . The slack of this representation is measured by the exact secant gap, the weighted secant slack and the slack budget, defined respectively by
The values enter through their projection on the specification. Let be the value of token along and its gradient in base coordinates. Let and be, respectively, the maximum and the minimum of over , let , the directional value width, which equals for a ball, and let . The directional value radius
is the half-range of the values along . It is at most times the Chebyshev radius of the union of the value sets , and much smaller when the values spread in directions orthogonal to , as they do in trained heads. The bilinear part of the score of key is bounded by the score covariance
which vanishes for a fixed query and is of order in general. The last quantity combines the slack of the softmax with the values. Let be any certified lower bound on , for instance , since the output is a convex combination of the values. The value-weighted secant slack is the value of a fractional knapsack, namely
(19)
Table 1 Controlling quantities of a head certification instance, all computed in closed form or by small convex programs before the certificate is solved, with their orders as for balls of radius .
| symbol | meaning | order |
|---|---|---|
| score width, | ||
| secant width, | ||
| dispersion of the midpoint pattern, margin of the dominant key | 1 | |
| attention intervals | ||
| weighted secant slack, exact secant gap (16) | ||
| directional value radius and width | 1, | |
| score covariance, the bilinear part of the scores (18) | ||
| KN | value-weighted secant slack (19) |
obtained by filling the keys in decreasing order of . It measures how much attention mass a relaxation can misplace, weighted by how far the value of each key can exceed the output. It is the central quantity of the paper.
Gaps are reported on two scales. The relative gap divides the gap by the output's range of motion over the admissible set, in practice by a certified or attained lower bound on it. It compares the certificate with what the perturbation can do. The range-normalized gap divides by the nominal spread of the values along and compares the certificate with the scale of the head's output.
The softmax is often regarded as what makes attention hard to certify. It has, on the contrary, a rigid structure. Its constants do not depend on the number of keys or the dimension, its interval bounds are explicit, and the patterns produced by an exponential cone relaxation obey an exact identity. Adding a constant to all scores leaves the softmax unchanged, so the natural measure of a change of scores is its range.
Lemma 1 (Lipschitz bound) For all ,
and the constant cannot be lowered.
The proof (Appendix A) rests on one fact. The Jacobian of the softmax maps a change of the scores to a vector whose norm is the mean absolute deviation of under the pattern, and this deviation is at most half the range of . The total variation distance between two patterns is thus at most a quarter of the largest change in the difference of two logits. The bound implies the case of the bound of Nair [41], since , and its range form is the one that certified score intervals control directly. These intervals determine the attention intervals.
Lemma 2 (Attention intervals) Let the scores lie in , with maximal width and midpoint pattern . Then, the following hold.
(i) For every , with
(ii) For every , and for the sums over the keys,
(22)
(iii) If a key has margin , then for every ,
No key can gain or lose more than a factor of its midpoint attention, so the total uncertainty of the pattern is of order . With a margin, the pattern is within an amount exponentially small in of one-hot. The slack of the secant representation of the exponential is known exactly.
Lemma 3 (Exact secant gap) Let be the secant of the exponential on an interval of width , and put
Then, , with
and, as ,
The classical interpolation bound is accurate for narrow intervals, but for wide ones the exact gap saturates at . Since , the lemma gives , so . The weighted slack is the transparent quantity, of order , and the sharp one.
The structural fact on which the second-order certificate rests concerns relaxed patterns. A convex relaxation cannot enforce ; it enforces only the sandwich together with . How such a relaxed pattern can differ from a genuine softmax pattern in its effect on the objective is described by an exact identity.
Proposition 4 (Value-weighted sandwich identity) Let for all , , and . Then, for every ,
(27) where is the average of under , and . If moreover and for all , then
The relaxation can inflate the attention of key above the value that the exponential dictates by at most , and the normalization removes the inflated mass from all keys in proportion to the genuine pattern . The net effect on the objective is the inflation of each key times the excess of its value over the average . Only keys whose values lie above that average can therefore increase the objective, however much slack they carry. The knapsack bound (28) needs no smallness condition and saturates automatically, since and . A key whose value lies below contributes nothing to it. This is why a measure of slack that ignores the values, such as alone, cannot predict the accuracy of the certificate on trained heads, where most of the slack sits on keys with small attention and low values.
3 Complexity
The softmax by itself is not a source of difficulty. Its Lipschitz and interval bounds do not depend on the number of keys, and with scores in a box its worst case is found by sorting. This section locates the difficulty of computing the worst case of the head certification problem (8). The problem is NP-hard as soon as the query and a key vary jointly in boxes, already for two tokens. It cannot be approximated within a constant fraction of the output range when the attention logits can move by a constant amount. With a fixed query it reduces to a scalar root-finding problem, solved exactly in polynomial time for boxes, zonotopes, convex hulls of listed points and ellipsoids. Listed token substitutions are solved exactly for any query. Together, these results determine which guarantees a polynomial-time certificate can and cannot offer.
The bilinear score alone carries the hardness. The construction uses fixed values, no multilayer perceptron and only two tokens, one of which is the query.
Theorem 5 (NP-hardness with two tokens) For one head with two tokens varying in boxes, one of them the query, and values that do not depend on the tokens, deciding whether is NP-hard.
The reduction encodes the infinity-to-one norm of a matrix Q, namely
into the score between the two tokens, so that the output is a strictly increasing function of . For a matrix built from the edges of a graph, this norm equals four times the maximum cut of the graph [28], so deciding a threshold for it is NP-hard. The full construction is given in Appendix A. When the scores themselves, instead of the tokens, range over a box, the problem is easy.
Remark 1 (Scores in a box) For fixed values and scores in a box, the maximum of is attained at one of the vertices obtained by sorting and raising the scores of a top segment, as also observed by Rezazadeh and Gholami Davoodi [23]. At a maximizer, every key whose value exceeds the maximum has its score at the upper end, and every key whose value falls below it has its score at the lower end. This holds because the derivative of the objective in the score of key is times the difference between and the objective, and the scores of keys whose value equals the maximum do not affect it. The maximum is computed in time.
The hardness is therefore created by the map from tokens to scores, not by the soft-max. Since the infinity-to-one norm is also hard to approximate, the reduction transfers inapproximability. The error is measured relative to the range of the output over the admissible set. In the reduction, the score between the two tokens is divided by an estimate of that the semidefinite relaxation of Grothendieck's inequality computes in polynomial time to within a factor 1.785 (Appendix A). The score then ranges over an interval of length between and 2, so the attention logits move by a constant amount, neither small nor large.
Theorem 6 (Inapproximability at constant score width) Consider heads with two tokens varying in boxes, one of them the query, and values that do not depend on the tokens. Unless P = NP, no polynomial-time algorithm returns, for every such head whose score between the two tokens ranges over an interval of length in [1.12, 2], a number with
The theorem concerns every polynomial-time method, not a particular relaxation. Second-order guarantees become vacuous when the score width is of order one, and over boxes no efficient method can extend them to that regime. When the query varies and the logits can swing by a constant while several keys compete, certificates are necessarily loose on some instances. The constant , which is not optimized, is small enough that an algorithm meeting it would approximate the maximum cut beyond Håstad's threshold of 16/17 [42], as the proof in Appendix A shows.
Remark 2 Under the Unique Games Conjecture, cannot be approximated in polynomial time within any factor below the Grothendieck constant [43–46]. Even the largest score that two tokens can produce therefore cannot be estimated better than by the semidefinite relaxation of Grothendieck's inequality.
The two reductions rely on boxes, whose vertices encode the cuts of a graph. For two tokens in centred balls with fixed values, as in the reductions, the largest score is the spectral norm scaled by the two radii, so the worst case is computed in polynomial time. The complexity of certification over balls with more keys or with varying values is not settled here.
Both hardness results need the query to vary together with a key. When the query token is fixed, as it is for a head whose reading position is not perturbed, every score depends on one token only, and the problem becomes separable. For each varying key , the pair formed by its score and its value along the specification ranges over the planar set
while for a fixed key the pair is a constant. Let .
Theorem 7 (Exact worst case with a fixed query) Let the query be fixed, and let the keys vary independently in compact sets while the keys , which include the query position, are fixed. Then, the following hold.
(i) The function
is convex and strictly decreasing from to , its unique root is , and tokens attaining the maxima attain the worst case.
(ii) If each is a box or zonotope with generators, or the convex hull of points, then is a polygon with or vertices, respectively. It is constructed from the projected generators or points in or operations, respectively. After this construction each evaluation of costs operations, and is computed to accuracy with evaluations.
(iii) If each is an ellipsoid, then is a filled ellipse, possibly degenerate. The maximum is then the largest value of at no more than five points of the boundary of , given by the real roots of a polynomial of degree at most four and one further point. Each evaluation of then costs operations, and is computed to accuracy with evaluations.
This is Dinkelbach's parametric approach to fractional programming [29] made exact by separability. The output of the head is a ratio of two sums, and asking whether it can exceed is asking whether a sum of independent terms can be made nonnegative, which decouples over the keys. The theorem gives the exact worst case together with an input that attains it, so it serves at once as an exact certificate and as an exact attack. Dinkelbach's iteration, Newton's method on started from the output of any input, produces outputs that increase monotonically and superlinearly to [47]. Values of with certify upper bounds. In the polygonal case is attained at a vertex of or at a stationary point, in closed form, of the concave function on an edge. For an ellipse the stationary points on the boundary are the roots of a polynomial of degree at most four. The cost is therefore linear in the number of keys up to logarithmic factors. On GPT-2, where each head reads its tokens through a subspace of dimension , in which the token sets are ellipsoids, the theorem provides exact worst cases against which the convex certificates are measured at every layer. Discreteness is not a source of hardness either.
Remark 3 (Listed substitutions) Let each token be restricted to an explicit list of candidates, such as the synonyms of a word. The worst case is the maximum, over the candidates of the query, of fixed query problems with finite key sets. Each of them is solved as the root
Table 2 Complexity of certifying one attention head. “Exact” means that the worst case is computed to any prescribed accuracy with certified bounds.
| setting | status | result |
|---|---|---|
| scores in a box, values fixed | exact, | Remark 1 |
| fixed query, boxes, zonotopes, point hulls | exact, polynomial | Thm. 7(ii) |
| fixed query, ellipsoids | exact, polynomial | Thm. 7(iii) |
| listed candidates, any query | exact, polynomial | Remark 3 |
| varying query, two tokens in boxes | NP-hard | Thm. 5 |
| same, score range in [1.12, 2] | inapproximable within of the range | Thm. 6 |
of the separable equation of Theorem 7(i), with a maximum of affine functions of . Once the candidate scores have been formed, is computed to accuracy in operations, although there are admissible inputs. The NP-hardness of Theorem 5 thus comes from the bilinear coupling of a varying query with a key over sets described implicitly, such as boxes, and not from discreteness.
Table 2 summarizes the map. Convex certificates occupy the remaining territory, a varying query over convex sets. They are polynomial in every case, and they can be exact up to second order when the softmax slack weighted by the values is small. The inapproximability of Theorem 6 shows that, over boxes, nothing efficient can be uniformly better when this slack is not small.
4 Certificates
This section constructs two certificates. The first replaces the dependence of the attention pattern on the tokens by the set of patterns that the score intervals allow, and it lets the values move independently within their sets. It is a linear program solved greedily, with a first-order gap whose constant does not depend explicitly on the sequence length or the dimension. Its only source of error is that it decouples where a head attends from what it reads. The second removes this decoupling by lifting. It is a level-one moment relaxation in which the softmax is represented by exponential cones and secants, and its gap is bounded by the value-weighted secant slack and is therefore of second order.
The pattern of attention is controlled by a certified pair , a reference pattern and a radius with for every admissible input. The width pair takes the midpoint pattern and , which is certified by the Lipschitz bound of Lemma 1 because each score lies within of its midpoint. The margin pair, available when , takes the one-hot pattern of the dominant key and the radius of the margin bound (23).
Definition 2 (Pattern polytope certificate) For a certified pair , the pattern polytope is
(32) and the pattern polytope certificate is
The certificate is valid. For every admissible input , the pattern lies in and
It is also the value of the convex relaxation of the head certification problem (8) in which each product becomes a variable constrained to the scaled set . It is computed by a two-phase transfer of attention mass. Let be the projection of onto the box and the remaining budget. The first phase restores . It adds the missing mass to the keys with the largest , or removes the excess from those with the smallest, each within its interval, at a cost of one unit of budget per unit of mass. The second phase transfers mass from the keys with the smallest to those with the largest, within the same intervals and at a cost of two units of budget per unit of mass. It stops when the budget is exhausted or no transfer increases the objective.
Proposition 8 (Greedy solution) The two-phase transfer solves the linear program (33) exactly, so is computed in time from the support values .
The proof (Appendix A) writes the transfer as two fractional knapsacks, one filling the keys with the largest support values and one emptying those with the smallest. The support values are in closed form for balls, ellipsoids and boxes. For the width pair the first phase is void, because lies in the box and on the simplex. The algorithm then transfers a mass of at most from the keys with the lowest support values to those with the highest. The greedy algorithm makes the first-order certificate applicable to arbitrarily long contexts. Once the score intervals and the support values are known, it solves the linear program for keys in 1.4 seconds. The accuracy of the certificate is controlled by a gap bound of first order.
Theorem 9 (Gap of the first-order certificate) For every certified pair,
which for the width pair reads . If a key has margin , the certificate with the width pair also satisfies
The gap bound (34) is independent of the sequence length, the token dimension and the head dimension, which enter only through the score width and the directional value radius. It is of first order, because is proportional to the perturbation radius. And it is directional, since it involves the spread of the values along the specification rather than their spread in norm. On the trained heads of GPT-2, the latter is larger by a median factor 2.4. In the margin regime the gap is exponentially small in the margin, so heads that attend decisively to one key are certified essentially exactly. The margin gap bound (35) holds for the width pair, without the cut of the margin pair, because the attention intervals imply that cut. The order of the theorem cannot be improved.
Proposition 10 (Sharpness) For every and there is a two-key instance with a fixed query and one token varying on a segment of half-length , with score width and directional value radius , on which
The first-order gap is thus of exact order while the values have a spread of order one, and the first-order gap bound of Theorem 9 is sharp up to a factor two. In the instance, which is written out in Appendix A, one key moves along a segment that raises its score while it lowers its value. The worst case pairs the most favourable value of the key with the attention that this value actually induces, which is the least attention. The pattern polytope instead pairs the most favourable value with the most favourable attention, a combination that no input realizes.
No bound computed from the score intervals and the ranges of the values along alone can do better on this instance. If the key varies instead in the box , with its score read from one coordinate and its value from the other, the score interval and the range of the value stay the same. The worst case then puts the score at its upper end and the value at its maximum, and it equals . A bound that uses only this information and is valid for every instance must hold for both, so on the segment its gap is at least that of . This applies in particular to the maximum of Remark 1 over a box of scores with each value at its largest, which Rezazadeh and Gholami Davoodi show to be the tightest bound that score intervals allow for fixed values [23]. A certificate of higher order must therefore couple the scores with the values.
The greedy solution also explains the certificate. Its pattern is a worst admissible attention pattern, and the sensitivities of the linear program (33) to its data show which keys and which quantities the bound depends on. Call the last key to receive mass in the transfer the last receiver , and the last key to give mass the last donor .
Proposition 11 (Sensitivity of the certificate) For the width pair, suppose that the greedy solution is the unique optimal solution of the linear program (33), that it exhausts the budget, and that and lie strictly inside their attention intervals. As a function of the data , and of the linear program, then has the following derivatives.
(i) For every key , .
(ii) With respect to the radius of the pair, .
(iii) For every receiver at its upper bound, .
The certificate thus reads as a worst admissible pattern, the value that each key contributes along the specification, the marginal value of the stability of the pattern, and the keys whose attention bounds are binding.
To couple where a head attends with what it reads, a relaxation must carry the products of attention weights with token perturbations as variables and relate them to the perturbations themselves. Collect the base coordinates of all tokens and the attention weights in one vector, , where is the base coordinate of the query. Let be the moment matrix (11) of , which collects its first and second moments, with first moments , and blocks . In the moment matrix, the score of key and the output along the specification are, respectively, the linear functions
and
in which stands for the product of the attention weight of key with its perturbation.
Definition 3 (Level-one exponential cone relaxation) For balls and ellipsoids in base coordinates, the relaxation is the conic program
where and range over , and is a certified pair.
The seven groups of constraints have the following roles. The lifted sets (R1) keep the first moments in the balls and bound the second moments by the trace that the rank-one moment matrix of an input attains. The scores and log-attention (R2) keep the lifted scores in their certified intervals and define the log-attention through the normalizer . The softmax sandwich (R3) imposes exactly through the exponential cone, bounds from above by the secant , and keeps the weights in their intervals and on the simplex. The interval diagonal (R4) is the product of the two interval constraints of a weight, . It bounds the variance of the lifted weight, which second-order accuracy requires. In computations, replacing it by the weaker leaves gaps of first order. The products with the sets (R5) are products of the simplex and of the set constraints with each other. They do not enter the accuracy bound, but they tighten the relaxation and imply for the same certified pair. They bound the product of each weight with its perturbation by the weight times the radius, so the lifted objective never exceeds the objective of the pattern polytope at the first moments (Appendix A). The pattern cut (R6) restricts the lifted pattern in the same way as the pattern polytope (32). The moment conditions (R7) require to be positive semidefinite with a unit constant entry, as the moment matrix of every input is. The moment matrix of an input also has rank one, which is not imposed because it is not a convex constraint.
The relaxation is valid, because for every admissible input the rank-one moment matrix of , together with and , satisfies all constraints. Boxes are treated analogously (Appendix B). The relaxation has one positive semidefinite cone of side , exponential cones and a number of second-order cones linear in . The main result of the paper bounds its gap by the value-weighted secant slack, plus two terms that account for the second moments.
Theorem 12 (Second-order accuracy) For every instance with ball, ellipsoid or box token sets,
where, for boxes, is computed from the circumradii.
The three terms correspond to the three ways in which a moment matrix can differ from the moment matrix of an input. The proof (Appendix A) splits the objective of a feasible moment matrix at its first moments, which form an admissible input, and bounds each of the three deviations in turn. The first is the slack of the softmax sandwich, weighted as in the value-weighted sandwich identity of Proposition 4. The relaxation can inflate the attention of key by at most , and this helps only if the value of key can exceed the output. The second is the covariance between the query and key perturbations. It shifts the lifted scores by at most and hence, by the Lipschitz bound of Lemma 1, the pattern by at most in norm. The third is the covariance between an attention weight and the perturbation of its own token, which the interval diagonal bounds by the product of the attention uncertainty and the directional value width. Every term is computable before the relaxation is solved, so the bound can decide whether the semidefinite program is worth solving and where to branch.
The value weighting is what makes the bound informative on trained heads. Bounding the total variation of the relaxed pattern instead of its value-weighted effect leads to the same structure, with the first term replaced by times a measure of the total slack such as . That measure blows up as and charges every key at the full range of the values. With , which may be assumed because does not depend on , the first term of the second-order bound (39) is at most . This bound vanishes quadratically in the score width, and the knapsack term itself can be far smaller, because keys whose values cannot exceed rad carry no weight. To state the orders explicitly, scale the radii as with and . Let , and the half-range of the nominal values , let be the largest radius with , and define
(40)
For a certificate and a tolerance , the tightness radius is the largest such that for all .
Corollary 13 (Orders of accuracy) For every instance with ball, ellipsoid or box token sets, with computed from the circumradii for boxes, the following hold.
(i) The gap of the second-order certificate satisfies
(41)
(ii) If the radii are with and , then and for , with the constants and defined in (40), so the tightness radii satisfy
and on the two-key instances of Proposition 10 the first-order tightness radius is .
Second-order certification thus halves the exponent of the tightness radius in the tolerance, so halving the tolerance shrinks the certifiable radius by a factor instead of 2. The constants follow from the order bound (41) once the score intervals are bounded by the Cauchy–Schwarz inequality (Appendix A). They depend on the head only through , , the largest nominal token norm and the nominal spread of the values along c. The length of the context and the dimension of the tokens therefore enter only through these norms. For layer-normalized tokens, for instance, the largest nominal norm grows like the square root of the dimension times the gain of the normalization. The accuracy also depends on the temperature of the head, through , and on its gain along the specification. As a function of the weights, is locally Lipschitz and differentiable almost everywhere, which makes it a natural regularizer for training heads that are certifiable at a prescribed radius. The tightness radius measures the accuracy of the certificate, not the sensitivity of the model. The largest radius at which the certified worst case stays within of the nominal output is of first order for every certificate, because the output itself moves by .
The order two of these bounds cannot be improved. The sharpness instance of Proposition 10 does not show this. Its worst case puts the score at an end of its interval, where the secant slack vanishes, and solving on it returns to solver precision. Letting the key move in a disc separates the second-order certificate from the truth at second order.
Proposition 14 (The second order is attained) For every there is a two-key instance with a fixed query and one token varying in a disc of radius , with score width , on which
On this instance, with from the first-order certificate for , the value-weighted secant slack equals .
The score of the key moves along one axis of the disc and its value along the other. The proof (Appendix A) takes a worst-case input and raises the attention of the key, whose value exceeds the output, by the slack that the secant leaves at its score. The moment matrix of this input, with the raised attention in place of the softmax, is feasible for . The first term of the second-order bound (39) is thus attained up to the factor . The third term, , bounds a covariance between the weight and the perturbation of the key that this rank-one moment matrix does not have. The tightness radius of the second-order certificate is of exact order on this instance. Solving with , with Clarabel [48] through CVXPY [49] at a tolerance of , gives between 0.0080 and 0.0122 for from 0.0125 to 0.2, against the limit of the lower bound (43).
The attained second order of Proposition 14 does not contradict the local stability of semidefinite relaxations. Cifuentes, Agarwal, Parrilo and Thomas [32] consider parametric families of quadratically constrained quadratic programs whose semidefinite relaxation is exact at a nominal parameter. Under regularity conditions, they show that the relaxation remains exact in a neighbourhood of that parameter. Here, the nominal problem, with , is solved exactly by the relaxation, since every token set is a point, yet on the instance of Proposition 14 the gap is of exact order for all small . Their regularity conditions fail at , and enlarging the sets from a point produces gaps of second order even for quadratic problems. By homogeneity, for instance, the Shor relaxation of
has the gap , where is the value of the relaxation at . For attention, the gap is created by the secant representation of the exponential, since the feasible point in the proof of Proposition 14 has a moment matrix of rank one. The second order of Theorem 12 is thus the exact order of the level-one relaxation, not an artefact of its analysis.
The first-order gap bound of Theorem 9 and the second-order bound of Theorem 12 delimit three regimes. When the score width is small, so are the value-weighted secant slack, the score covariance and the attention uncertainty, and the second-order certificate is accurate to second order. When one key dominates with a margin , the first-order certificate is exact up to a term exponentially small in , whatever the score width. When the query varies and the score width is of order one with several keys competing, the slack is of order one. For tokens in boxes, the inapproximability result of Theorem 6 shows that no efficient method can then do uniformly better. In this regime, which on synthetic heads appears as a band of intermediate widths, all methods are loose, and branching over the scores is the remedy. For a deployed model this gives a design rule. A head is certified to accuracy when its attention logits cannot swing by more than a fixed fraction of under the admissible perturbations and the remaining terms of the order bound (41) together stay below . It is also certified when one key dominates by a margin .
5 Implementation
A certificate is only as good as its computation. Interior-point solvers return approximate primal and dual solutions in floating point, and a value that is slightly too small is not a certificate at all. The token dimension of a trained model is large, and the score intervals that feed every bound must themselves be certified. This section resolves each of these issues and describes how branching over the scores tightens the certificate where it is loose. Algorithm 1 summarizes the procedure.
A head reads each token only through its queries, keys and values. With biases, the scores and values are affine functions of , where and . For GPT-2 small, against . Certificates can be computed in coordinates of dimension at most without any loss.
Proposition 15 (Exact reduction) Let the token sets be balls in and let the columns of form an orthonormal basis of the row space of . Replacing each base coordinate by changes neither , nor , nor the value of , nor the semidefinite score intervals.
The reason is that the scores, the values along and every lifted expression depend on a base coordinate only through its projection (Appendix A). In the reduced coordinates each ball becomes
with the biases absorbed into the centres. For GPT-2 the reduction shrinks the semidefinite variable of a head at query position from side to , by a factor of about sixteen in the number of entries. It is what makes the second-order certificate affordable for trained models.
Every bound depends on the certified score intervals (12). The score of key is a constant plus a linear function of the query and key perturbations plus the bilinear term , . Its extreme values over two balls are bounded by the Shor relaxation, and the endpoints of the resulting interval are widened by a relative to cover the solver's tolerance. The bound is exact for the self-score of the query, a quadratic function of one ball, by the S-lemma. It is also exact for the bilinear term over two centred balls, with value , because the off-diagonal block of a positive semidefinite matrix whose diagonal blocks have traces at most and has nuclear norm at most . Over two centred boxes it is within the factor of the maximum [28]. With the linear terms present the problem is a generalized two-ball trust-region problem, for which the bound can be loose. On offset synthetic instances its ratio to the exact maximum reached 1.40 on balls and 1.23 on boxes. At the radii used for GPT-2 the linear terms dominate, and the semidefinite intervals are a median factor 3.3 narrower than those of the Cauchy–Schwarz inequality. Each interval is computed in coordinates of dimension , by the argument of the exact reduction of Proposition 15, in a fraction of a second per key (Appendix B).
An interior-point solver returns an approximate dual solution whose objective may lie slightly below the optimal value of the relaxation. Taken at face value, such a number can fall below the true worst case. In a preliminary run on synthetic heads, the solver's objective fell below a feasible value on 230 of 60,154 semidefinite instances, by up to . The remedy is a bound that is valid for any dual point. Write the relaxation as
with linear maps and cones . Suppose that every feasible point satisfies a priori bounds and , together with group budgets . For these follow from the interval constraints, the trace constraints of the balls and the interval diagonal. For multipliers , let
where and are the adjoints of the parts of acting on and . Finally, let be the number of groups plus the number of ungrouped indices with .
Proposition 16 (Safe dual bound) For any multipliers , the optimal value of problem (44) is at most
The bound is weak duality with the residual of the dual constraints absorbed by the a priori bounds, in the spirit of the rigorous error bounds of Jansson et al. and of Neumaier and Shcherbina [50, 51]. The multipliers are the solver's dual solution projected onto the dual cones, and an explicit allowance covers the rounding errors of the evaluation (Appendix B). The resulting safe value replaces the solver's objective everywhere. Because it is valid for any dual point, the solver can be stopped at moderate tolerances. On GPT-2, feasibility tolerances of reduce the solve time by a factor five, and the safe value exceeds the solver's dual objective by a median . Strict feasibility is not needed either. This matters because has no strictly feasible point, since the equalities in (R3), (R5) and (R7) give for the vector with entry -1 at the constant, zeros at the token coordinates and ones at the attention weights. Eliminating one weight through removes this particular kernel and is advisable for solvers that rely on interior points.
Definition 4 (Certificate) The certificate of a head instance is
Both members of the minimum are valid upper bounds. The optimal value of never exceeds , but its safe value can, which is one reason for the minimum. The others are that is computed in time, is essentially exact in the margin regime, and serves as a fallback when the semidefinite program is not solved.
When the certificate is loose, it can be tightened by partitioning the admissible set in score space. Splitting the interval of key at its midpoint divides the inputs into those with below and above the midpoint. Each part is certified by with the lifted score (37) constrained to the half interval and the controls recomputed. The maximum over the leaves of a partition is a certificate. Leaves whose certificate does not exceed a known feasible value are discarded, and a leaf whose relaxation is infeasible contains no input. The second-order bound of Theorem 12 applies to each leaf with the controls of the leaf and with the global worst case in place of the leaf's own. Only must remain a lower bound over the whole admissible set. The reason is that the first moments of a leaf's relaxation are admissible inputs of the whole problem but not necessarily of the leaf. As the score intervals shrink, the first and third terms of the second-order bound (39) vanish, while does not depend on them. Score branching therefore drives the gap to at most , which is zero for a fixed query. The bound also chooses the split. The bound-lookahead rule computes the controls of both children of every candidate key in closed form, evaluates the second-order bound (39) on each, and splits the key whose larger child bound is smallest. It costs closed form evaluations per node. Splitting the key with the largest raw slack is often ineffective. The largest slack often sits on keys whose values cannot exceed the output, and by the value-weighted sandwich identity of Proposition 4 the slack of such keys does not raise the bound.
The cost is dominated by the semidefinite solves. For a head at query position the reduced lifted vector has dimension , that is 965, 1,737 and 2,509 for , 8 and 12, respectively, on GPT-2. With the task interface of MOSEK [52], the GPT-2 solves with a varying query take a median 22, 115 and 382 seconds, respectively, on four threads, with memory below 18 gigabytes. A modelling layer that dualizes the relaxation before passing it to the solver turns every entry of the moment matrix into an equality constraint. A single instance at then exhausted 186 gigabytes, so the direct formulation is essential. The greedy certificate and all controls cost milliseconds to seconds. The exact fixed query solver of Theorem 7 costs a median 0.13 seconds per GPT-2 head, prompt, query position and radius, and grows linearly with the number of keys, from 0.11 seconds at ten keys to 115 seconds at ten thousand in dimension eight.
The single positive semidefinite cone grows with the context, with side at query position i. The proof of the second-order bound of Theorem 12 uses the moment matrix only through its principal submatrices indexed by the constant, the query, one key and its weight (Appendix A). Requiring only these n submatrices to be positive semidefinite therefore gives a weaker relaxation to which the second-order bound (39) still applies. It keeps (R1)–(R4), (R6) and the norm constraints of
Algorithm 1 Certificate for one head, one query position and one specification
Require: weights of the head, token sets , specification , tolerance
1: reduce the base coordinates to the head subspace (Proposition 15)
2: compute the score intervals by the semidefinite bounds
3: compute the controls of Table 1, with from the greedy certificate for
4: greedy solution of the pattern polytope linear program (33) (Proposition 8)
5: if the margin gap bound (35) is at most then
6: return
7: end if
8: solve by an interior-point method; compute its safe value (Proposition 16)
9: cert
10: while cert minus the best feasible value exceeds and the budget allows do
11: split the open leaf with the largest bound by the bound-lookahead rule; certify both children
12: cert maximum of the open leaves' certificates; improve the feasible value from the leaves' first moments
13: end while
14: return cert
(R5) and drops the sums and sign constraints of (R5). Its cones have side at most , so its size grows linearly with the number of keys. How much accuracy it gives up against is not measured here.
6 Per-Operation Relaxations
Linear bound propagation, its optimized variants and polyhedral abstract domains relax a network one operation at a time. Each nonlinear operation is replaced by affine bounds that are valid on the interval, or the box, of its operands, and the bounds are composed by back-substitution. The second-order certificate of Section 4, a moment relaxation of the whole head, does the opposite. It couples the second-order terms of all keys through one moment matrix. This section shows what the per-operation approach costs at second order. On a function whose value and gradient vanish at the nominal point, a per-operation relaxation pays the sum of the operations' individual second-order maxima, whereas the true second-order term is one coupled maximum. This is a second-order counterpart of the convex barrier of Salman et al. [14].
Such functions arise as second-order parts and remainders. Linearizing a transformer block at its nominal input leaves the remainder
which vanishes with its gradient at , and so does every linear functional of it. Certifying a computation through several blocks requires bounds on such remainders, and bound propagation applied to the network that computes the remainder is the natural source of them. Consider a symmetric compact convex input set and operations with operands affine in the perturbation, . Given twice continuously differentiable functions and weights , the second-order part of their weighted sum is
Let collect the half-widths of the operands and let be the operand box, namely
A per-operation relaxation bound is a number
in which each is affine and satisfies on a box containing . For one layer of operations, an affine upper bound of on the box differs from such an by an affine function. The bounds of linear bound propagation [9, 13], of its optimized variant with any choice of slopes [34] and of DeepPoly-type domains [11] are therefore of the form (51). Part (iii) of the next proposition covers composed networks.
Proposition 17 (Per-operation relaxations pay a sum of maxima) The following three statements hold.
(i) Every per-operation relaxation bound satisfies
(ii) If on for every , then , where , with equality when every is quadratic and .
(iii) If , with , is computed by a graph whose operands may depend nonlinearly on , and is obtained by back-substituting affine bounds valid on intervals , then the lower bound (52) holds with the back-substitution multipliers in place of and any with for all .
For a unary operation the term of the lower bound (52) is at least , where is the minimum of on the operand interval. For a product it is . On a ball of radius , part (ii) gives . The mechanism of part (i) is elementary. An affine function that dominates a remainder at two opposite corners of a box is, at the centre, at least the average of the remainder's two corner values, although the remainder vanishes there. The nominal input is the centre of every operand box at once. In a composed network the multipliers depend on the slopes chosen downstream. If the slopes tend to the derivatives at the nominal point as the radius tends to zero, then tends to the adjoint and the admissible half-widths to the linearized ones, , where is the gradient in of a scalar operand. The right side of the lower bound (52) evaluated with these is then the leading-order lower bound for such relaxations. Over a ball, the comparison with the exact term reduces to a comparison between a trace and an eigenvalue.
Corollary 18 (The effective rank factor) Let be a ball of radius and let every operation be unary with constant curvature and row , so that . If , then
and the level-one Shor relaxation of attains .
Every per-operation relaxation thus overestimates the second-order term by at least the factor , the effective rank, which lies between one and rank , while a moment relaxation does not. The variance inside a layer normalization over a ball of radius is the simplest instance. Its exact second-order term is , while a coordinate-wise relaxation pays , a factor in GPT-2 small. Two consequences follow. First, optimizing the slopes of linear bound propagation cannot remove the effect. For one layer the lower bound (52) does not depend on the slopes, and for composed networks, under the condition above, its leading term does not. Second, the lifted relaxation of a single head applies the coupling of Corollary 18, an eigenvalue in place of a trace, at the scale of a head, which is consistent with its advantage over bound propagation on single heads. This is an interpretation rather than a consequence of the proposition, because the output of a head has a linear part, whereas the proposition concerns second-order parts and remainders.
The two sides can be evaluated on a trained model at the nominal point. For a function computed by a graph of affine maps, unary operations and products, with and , let be the adjoint of operation and , or , the gradients of its operands in , all at , and let . Write for the positive semidefinite part of a symmetric matrix .
Lemma 19 (Spectral and per-operation second-order terms) The Hessian of at the nominal point is
and on a ball of radius , with ,
The quantity is the exact second-order maximum of , and is, to leading order in , the right side of the lower bound (52) with the adjoints and the linearized half-widths. It is the size that Proposition 17 predicts for a per-operation bound. The ratio is therefore the predicted looseness of bound propagation on a second-order part. It factors into the effective rank and the loss from bounding each operation without cancellation. The second inequality of the bound (55) replaces each product term by two rank-one terms, through a matrix form of the arithmetic-geometric mean inequality (Appendix A).
7 Computational Results
The theory makes predictions that experiments can test. The gaps should have the orders in the perturbation radius that the theorems predict, and the value-weighted secant slack, rather than the score width or the raw slack, should govern the accuracy of the certificate. Bound propagation should be loose by at least the factor that the per-operation analysis predicts. This section tests these predictions on synthetic heads, where the regimes of the theory can be probed one at a time, and on every head of GPT-2 small, against exact worst cases and against linear bound propagation.
All computations are in double precision. The semidefinite relaxations are solved with MOSEK 11 [52] and the exact references on synthetic heads with Gurobi 13 [53] as nonconvex programs (Appendix B). The transformer weights are read with PyTorch and the Hugging Face library [54, 55]. Interval bound propagation (IBP), CROWN and -CROWN are those of auto_LiRPA 0.8.0 [9, 13, 34], run in double precision with the default options of the library. These bound the softmax as one operation, by the convex bounds of Wei et al. [18]. The experiments ran on one workstation with an Intel Xeon w5-2465X processor (16 cores, 3.1 GHz) and 256 gigabytes of memory, without graphics processors. Gaps are measured against exact worst cases where available and otherwise against the best feasible value from multistart local ascent, whose starting points are listed in Appendix B. Every semidefinite value reported for GPT-2 is the safe dual bound of Proposition 16.
The synthetic heads have , and keys, with balls or boxes of common radius around nominal tokens, of norm in the random and rank-one families. Five families probe the regimes of the theory. The first consists of random heads at attention temperatures , and the second of heads with a dominant key of margin 1 to 8. In the ambiguous heads of the third family, two keys tie in score but differ strongly in value along the specification. The fourth family has a rank-one query-key matrix. The fifth is a two-key family of the type of the sharpness instances of Proposition 10, in which one key raises its score while it lowers its value. Its values are proportional to the displacement, so that the slopes of all its gaps in the perturbation radius are larger by one. This gives 8,100 instances, each certified by every method. The reference is a global solve with a time limit of 300 seconds for and 90 seconds for larger radii, except on 40 three-key instances of the rank-one family at , whose reference is the best feasible value. The synthetic runs use the wider log-attention intervals , which contain the log-attention intervals (14), and report the solver's primal value, which differs from the safe value by at most . A smaller rerun with the intervals (14) gives the same slopes. The interval pattern bounds combine interval bounds on the pattern with the exact support of each value.
The orders of accuracy are confirmed first. Figure 1 and Table 3 report the slope of against on . The first-order certificate and the interval pattern bounds have slopes between 0.99 and 1.04 on the four families of the table, and the level-one relaxation between 2.00 and 2.02, on balls and on boxes alike. This is what the first- and second-order gap bounds of Theorems 9 and 12 predict. With the unit diagonal in place of (R4), the slopes fall to between 1.10 and 1.35. The gaps are then essentially of first order and eventually exceed any bound of second

Fig. 1 Gap of the interval pattern bounds, the first-order certificate and the level-one relaxation with and without its interval diagonal (R4) against the perturbation radius, on random and ambiguous synthetic heads with ball token sets (; medians and interquartile ranges over 10 seeds and all configurations).
Table 3 Slope of the certified gap in the perturbation radius on synthetic heads with ball token sets, (medians of per-series least-squares fits, with interquartile ranges).
| method | random | ambiguous | margin | rank-one |
|---|---|---|---|---|
| interval pattern bounds | 1.02 [1.00, 1.06] | 1.01 [0.98, 1.02] | 1.04 [0.96, 1.09] | 1.01 [0.98, 1.06] |
| first order, | 1.00 [0.94, 1.01] | 0.99 [0.98, 0.99] | 1.02 [0.86, 1.12] | 1.00 [0.96, 1.03] |
| level one, unit diagonal | 1.10 [1.03, 1.33] | 1.35 [1.24, 1.54] | 1.28 [1.18, 1.44] | 1.14 [1.03, 1.41] |
| level one, | 2.01 [1.93, 2.01] | 2.00 [1.99, 2.01] | 2.02 [1.80, 2.05] | 2.00 [2.00, 2.02] |
order, consistent with the role of (R4) in the proof. At fixed radius the gap of the level-one relaxation has order 1.97 to 2.03 in the temperature on random heads.
The regimes appear as the secant width grows with the temperature at fixed radius. On random heads with three keys, the level-one certificate is 125 times tighter than the first-order one at , six times at and still 1.6 times at . All methods are loose in the band , where several keys compete with comparable scores. On half of the seeds, one key dominates at every width. Its certified attention weight grows with and exceeds 0.9 on all five of these seeds from on. On them the first-order certificate becomes essentially exact at large widths. The interval pattern bounds are 9.5 to 28 times looser than the level-one certificate, depending on the family and the number of keys. Taking the minimum of the two certificates, as the certificate of Definition 4 does, costs a median 0.2 seconds per synthetic instance.
The test on a trained model uses every head of GPT-2 small on five plain text prompts of 19 to 22 tokens, listed in Appendix B. The query positions are and the last position, counted from zero so that position attends to keys. The token sets are balls in the post-normalization space around the actual inputs of
Table 4 Certificate accuracy on GPT-2 small by relative radius, with the relative and range-normalized gaps of Section 2.
| units | median | median relative gap | range-norm. gap certificate | share of units | |||
|---|---|---|---|---|---|---|---|
| certificate | first order | ||||||
| 0.001 | 720 | 0.24 | 0.0093 | 0.205 | 54% | 100% | |
| 0.002 | 720 | 0.48 | 0.019 | 0.213 | 32% | 100% | |
| 0.005 | 720 | 1.21 | 0.048 | 0.233 | 16% | 88% | |
| 0.01 | 2,160 | 2.65 | 0.135 | 0.322 | 0.030 | 7% | 37% |
| 0.02 | 2,160 | 5.24 | 0.212 | 0.349 | 0.097 | 7% | 24% |
the head, with radius proportional to each token's norm, for relative radii between 0.001 and 0.05. Every token in the context, including the query, is perturbed. The specification is the direction of the head's nominal output. A head at a given prompt, position and radius is a unit. Slopes in the radius are fitted for each head, prompt and position and are called per-unit slopes. The level-one certificate was computed on 6,480 units at the positions 4, 8 and 12, and the last position enters the exact computations with a fixed query.
The attention logits of GPT-2 are sensitive to perturbations of the normalized tokens, and this places trained heads in a regime of their own. The median secant width is 240 to 265 times (Table 4), so the second-order regime corresponds to perturbations of less than about 0.4% of a token's norm. At , 94% of the units lie in the band in which all methods are loose on synthetic heads, and only two of the 6,480 units have a certified dominant key.
Table 4 summarizes the accuracy by radius. Radii up to 0.005 use query position four, and the radii 0.01 and 0.02 use positions four, eight and twelve. In the second-order regime, , every unit is certified within 10% of its range of motion, and at more than half within 1%. In the band, the level-one certificate remains a median factor two tighter than the first-order one and is strictly tighter on 99.5% of units. At it pins the worst case to 3% of the nominal spread of the head's output.
The decisive test of the orders of accuracy of Corollary 13 is the dependence of the gap on the radius within each unit. For all 144 heads and five prompts at position four, each head and prompt was certified at the same five radii from 0.001 to 0.02 (Figure 2). On the three smallest radii, the median per-unit slope of the certificate's gap is 2.04 (interquartile range 1.99 to 2.08), against 1.06 for the first-order certificate and 1.00 for the output's range of motion, as the theory predicts. The slopes of the certificate are taken over the 716 units with at least two gaps above the numerical floor. The slopes between consecutive radii stay near two up to and fall to 1.83 between 0.01 and 0.02, where the units enter the band. Measured through tightness radii at two tolerances on three heads per layer, the exponent of the certificate is 0.52 and that of the first-order certificate 0.87, against the predictions 1/2 and 1, respectively. A tightness radius beyond the largest radius tested enters these medians at that radius. The measured gaps are the certificate's own. Stronger ascents, including one that alternates the exact maximization over the keys of Theorem 7 with local ascent over the query, improve the feasible value by at most of the spread. Where the

Fig. 2 The order of accuracy on GPT-2 small (all heads, five prompts, query position four). Left: gaps of the two certificates and the output's range of motion against the relative radius (medians and interquartile ranges over 720 units). Right: per-unit slopes on .


Fig. 3 The gap of the certificate on GPT-2 small against the weighted secant slack S (left) and against the value-weighted slack (right), coloured by the dispersion of the nominal pattern; 6,442 units.
band leaves a gap, branching closes most of it. The relative bracket is the certificate minus the best feasible value, divided by the range of motion. On prompt zero at position four, with 24 semidefinite solves per head and the search rules of Appendix B, the median relative bracket falls from 0.087 to 0.020 on the 144 heads at . On the 24 hardest heads at , it falls from 0.037 to 0.0049. Its lower end stays fixed, so the whole decrease removes slack of the root relaxation. These runs split the key with the largest weighted secant slack . On 72 of the heads at , the bound-lookahead rule reaches a median bracket of 0.013 instead of 0.029.
Table 5 Exact relative gaps with a fixed query on GPT-2 small (all 144 heads, five prompts, query position four; 720 units per radius).
| certificate | first order median | share of units within 1% | ||
|---|---|---|---|---|
| median [IQR] | max | |||
| 0.002 | 0.0039 [0.0012, 0.0070] | 0.020 | 0.172 | 89% |
| 0.005 | 0.010 [0.003, 0.018] | 0.056 | 0.181 | 50% |
| 0.01 | 0.022 [0.008, 0.039] | 0.13 | 0.193 | 32% |
| 0.02 | 0.048 [0.018, 0.084] | 0.28 | 0.215 | 15% |
| slope | 2.04 [2.01, 2.07] | 1.04 | ||
The second-order bound of Theorem 12 predicts that the gap is governed by the value-weighted secant slack, not by the score width or the raw slack. Figure 3 tests this on the 6,442 level-one units whose gap exceeds the numerical floor. In the raw plot, units with concentrated attention lie several orders of magnitude below units with dispersed attention at the same slack. The right panel replaces by the value-weighted slack
with the smallest output found by local search, and colours each unit by the dispersion of its nominal pattern. After value weighting, the structure disappears on the units with , because the slack of concentrated heads sits on keys with small attention whose values cannot exceed the output. The gap lies below the diagonal on 97% of the units. The rank correlation of the gap with is 0.76, and with the value-weighted slack of the figure it is 0.91. The knapsack term of the second-order bound (39) itself uses the exact secant gaps, the slack budget and the certified lower bound . Its rank correlation with the gap is 0.93 overall, 0.99 on the units with and 0.74 on those with . The gap is a median 21% and at most 56% of the second-order bound.
Where it applies, namely for a head whose reading position is protected, the exact fixed query solution of Theorem 7 removes the remaining caveat that the reference is only a feasible value. Every head of GPT-2 small at the four query positions, five prompts and six relative radii was solved exactly with the query fixed. These are 17,280 units, with certified brackets narrower than of the nominal spread of the values along the specification, a median of the output's range of motion. The computation bounds each by a certified subdivision of the boundary angle of its ellipse, in place of the closed form of Theorem 7(iii). Measured against the truth, the order of accuracy is the predicted one (Table 5). There the relative gap divides the gap against the exact worst case by the exact range of motion, and the slopes are per-unit slopes of the logarithm of the gap against that of between 0.002 and 0.005. On the 2,880 units at position four, the relative gap of the certificate is 0.004 at and 0.048 at 0.02. Its per-unit slope is 2.04, against 1.04 for the first-order certificate and 1.00 for the exact range of motion. The gap is at most 0.78 of the second-order bound (39). Multistart ascent finds the exact worst case to of the nominal spread of the values on every one of these units, so with a fixed query the
Table 6 Relative gaps of linear bound propagation and of our certificates on the same GPT-2 units (all 144 heads, five prompts, query position four; 720 units per row; medians). The last two columns are median per-unit ratios to the gap of the certificate.
| query | IBP | CROWN | -CROWN | first order | certificate | ratio to cert. | ||
|---|---|---|---|---|---|---|---|---|
| CROWN | ||||||||
| fixed | 0.002 | 5.7 | 0.020 | 0.016 | 0.172 | 0.0039 | 4.4 | 3.9 |
| 0.005 | 7.4 | 0.053 | 0.042 | 0.181 | 0.010 | 4.5 | 3.9 | |
| 0.01 | 11.2 | 0.113 | 0.090 | 0.193 | 0.022 | 4.5 | 3.8 | |
| 0.02 | 16.8 | 0.255 | 0.199 | 0.215 | 0.048 | 4.7 | 4.0 | |
| varying | 0.001 | 7.2 | 0.083 | 0.072 | 0.205 | 0.0093 | 7.8 | 6.7 |
| 0.002 | 9.1 | 0.186 | 0.159 | 0.213 | 0.019 | 8.6 | 7.5 | |
| 0.005 | 15.3 | 0.636 | 0.527 | 0.233 | 0.048 | 11.8 | 9.8 | |
| 0.01 | 19.2 | 2.17 | 1.72 | 0.269 | 0.098 | 22.2 | 17.5 | |

Fig. 4 Relative gaps of CROWN, -CROWN, the first-order certificate and the certificate on the same GPT-2 units (720 units per radius; medians and interquartile ranges).
whole gap is the relaxation's. Letting the reading position move more than doubles the swing of the logits, since the secant width with a varying query is a median 2.36 to 2.42 times that with a fixed query, depending on the radius.
Linear bound propagation comes with no order of accuracy, and the comparison with it is made on exactly the same footing. It uses the same heads, sets and specifications, with 2,880 fixed query units measured against the exact worst case and 2,880 varying query units measured against the best feasible value. The head is given to the bound propagation library in the same reduced coordinates, with each perturbed token as a separate input in its own ball. Table 6 and Figure 4 give the result. Interval bound propagation is vacuous, with relative gaps between 5.7 and 19, and is omitted from Figure 4. CROWN and -CROWN are empirically of second order, with a per-unit slope of 2.11 with a fixed query, the same as the certificate, and 2.39 with a varying one, against 2.05 for the certificate. These slopes are fitted over the four radii of each query type, and over 0.002-0.005 alone the certificate's slope is the 2.04 of the exact comparison in Table 5. The constant of bound propagation is larger. With a fixed query their gap is 3.8 to 4.7 times the certificate's at every radius, and with a varying query the ratio grows from 7.8 (6.7 for -CROWN) at to 22 (17.5) at 0.01. The certificate is tighter on every one of the 5,760 units, by at least a factor two on 96% of them. Bound propagation is fast, 0.01 to 0.02 seconds per unit for CROWN and 0.2 to 0.7 seconds for -CROWN, against a median of 10 seconds for the semidefinite certificate with a fixed query and 22 seconds with a varying one. At the smallest radii it is tighter than the first-order certificate, so it is the better fast bound there. More optimization does not change the picture. On the 1,152 units of one prompt, 20 to 500 iterations of -CROWN at two learning rates move the median ratio of its gap to the certificate's by less than 0.1%. This is what the per-operation lower bound of Proposition 17 leads one to expect.
The last test asks whether the looseness of bound propagation is the sum of per-operation maxima that Proposition 17 predicts, on a function where both sides can be computed. For a block of GPT-2 and a head of block , let one token at the input of block be perturbed in a ball of relative radius . Let map the residual stream at the input of block to the normalized tokens read by the head, and let be the remainder of read along the direction to which the head is sensitive. Namely, is the inner product of the remainders of the head's queries, keys and values with the gradient, with respect to them, of the head's nominal output along the specification. The function vanishes with its gradient at the nominal input, and its maximum is, to first order in the head, the amount by which the second-order part of the block can move the head's output. On 132 units (blocks 0–1, 3–4, 6–7 and 9–10, the 12 downstream heads, , without blocks 0–1 at the largest radius), CROWN was run on the network that computes , and the attained maximum of was found by multistart ascent. The Hessian of was computed with its decomposition (54) over the unary operations and products of the block, with the softmax written through exponentials, a sum, a reciprocal and products.
Three predictions, stated before the computation, were confirmed at . The attained maximum of equals the exact second-order term to within 0.04% to 1.5%, so the remainder is quadratic at these radii. CROWN's bound is 1.26 to 2.34 times the per-operation sum (median 1.63). It is 1.11 to 1.54 times the per-operation terms of the lower bound (52) evaluated on CROWN's own operations and intervals, which after the attention exceed their linearized widths. And the rank correlation of CROWN's looseness with the predicted looseness is 0.98 on the 96 units with (Figure 5), and 0.90 over all 132 units. CROWN bounds the softmax as one operation, whereas writes it through exponentials, a sum, a reciprocal and products. Counting the softmax as one operation multiplies by a factor between 0.75 and 1.01 and leaves the rank correlation at 0.98. Over all 132 units the predicted looseness is large, a median 140 (between 33 and 722), and its sources can be named. The effective rank is a median 11 (between 2.4 and 50). The per-operation sum exceeds the trace by a further factor of about 14, because terms of opposite sign do not cancel and the two operands of a product are

Fig. 5 Looseness of CROWN on the remainder of a GPT-2 block, its bound on max divided by the attained maximum, against the looseness predicted by Lemma 19 (132 units).
not aligned. With the softmax counted as one operation, the operations of the tanh-approximated activation of the multilayer perceptron and the products of attention weights and values carry 79% to 92% of the per-operation sum. At the radii where the remainder is quadratic, bound propagation is thus loose on these computations by at least the per-operation excess that the analysis predicts, and by at most 2.34 times the excess of Lemma 19. Its single-head looseness of Table 6 is consistent with the same phenomenon at a smaller scale.
8 Conclusion
Attention is certifiable to second order, and the theory of this paper says when. The difficulty lies not in the softmax but in the bilinear interaction of a varying query with the keys, which over boxes makes certification NP-hard and, once the attention logits can move by a constant, inapproximable. A fixed query or listed substitutions reduce the worst case to a separable equation. Elsewhere, a greedy linear program certifies to first order, and an exponential cone moment relaxation certifies to second order, an order that cannot be improved, with a gap bounded through the value-weighted secant slack. Relaxations that treat one operation at a time pay a sum of second-order terms instead of one coupled term. On GPT-2 small, the certificate attains the predicted order against exact worst cases with the query fixed and is tighter than linear bound propagation on every head. The looseness of bound propagation on block remainders tracks the predicted excess.
The analysis concerns one head, with continuous perturbations of the tokens it reads and a specification read linearly from its output, and three directions extend it. The first is certification through depth, with bounds that couple the second-order terms of a block's operations as the moment relaxation does within a head. The per-operation excess measured on GPT-2 blocks, two orders of magnitude, marks what such bounds could recover. The second is scale. A sparser relaxation keeps the second-order bound while its size grows only linearly with the number of keys. The third turns the analysis into design. The constant that controls the second-order accuracy of a head is explicit and differentiable almost everywhere, so certifiability at a prescribed radius can be imposed during training. The accuracy that a model must give up to be certified then becomes a well-posed question.
Code and data availability. The implementation of the certificates is available at https://github.com/chimera1001/conic-attention-cert. The repository also contains the exact worst cases with a fixed query computed for all heads of GPT-2 small.
References
[1] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., Polosukhin, I.: Attention is all you need. In: Advances in Neural Information Processing Systems, vol. 30, pp. 5998–6008 (2017)
[2] Szegedy, C., Zaremba, W., Sutskever, I., Bruna, J., Erhan, D., Goodfellow, I., Fergus, R.: Intriguing properties of neural networks. In: International Conference on Learning Representations (2014)
[3] Goodfellow, I., Shlens, J., Szegedy, C.: Explaining and harnessing adversarial examples. In: International Conference on Learning Representations (2015)
[4] Zou, A., Wang, Z., Carlini, N., Nasr, M., Kolter, J.Z., Fredrikson, M.: Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043 (2023)
[5] Katz, G., Barrett, C., Dill, D.L., Julian, K., Kochenderfer, M.J.: Reluplex: An efficient SMT solver for verifying deep neural networks. In: Computer Aided Verification (CAV 2017). Lecture Notes in Computer Science, vol. 10426, pp. 97–117. Springer, Cham (2017)
[6] Tjeng, V., Xiao, K.Y., Tedrake, R.: Evaluating robustness of neural networks with mixed integer programming. In: International Conference on Learning Representations (2019)
[7] Wang, S., Zhang, H., Xu, K., Lin, X., Jana, S., Hsieh, C.-J., Kolter, J.Z.: Beta-CROWN: Efficient bound propagation with per-neuron split constraints for neural network robustness verification. In: Advances in Neural Information Processing Systems, vol. 34, pp. 29909–29921 (2021)
[8] Wong, E., Kolter, J.Z.: Provable defenses against adversarial examples via the convex outer adversarial polytope. In: Proceedings of the 35th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 80, pp. 5286–5295 (2018)
[9] Zhang, H., Weng, T.-W., Chen, P.-Y., Hsieh, C.-J., Daniel, L.: Efficient neural network robustness certification with general activation functions. In: Advances in Neural Information Processing Systems, vol. 31, pp. 4939–4948 (2018)
[10] Gowal, S., Dvijotham, K., Stanforth, R., Bunel, R., Qin, C., Uesato, J., Arandjelovic, R., Mann, T., Kohli, P.: Scalable verified training for provably robust image classification. In: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 4842–4851 (2019)
[11] Singh, G., Gehr, T., Püschel, M., Vechev, M.: An abstract domain for certifying neural networks. Proceedings of the ACM on Programming Languages 3(POPL),
1-30 (2019)
[12] Raghunathan, A., Steinhardt, J., Liang, P.: Semidefinite relaxations for certifying robustness to adversarial examples. In: Advances in Neural Information Processing Systems, vol. 31, pp. 10877–10887 (2018)
[13] Xu, K., Shi, Z., Zhang, H., Wang, Y., Chang, K.-W., Huang, M., Kailkhura, B., Lin, X., Hsieh, C.-J.: Automatic perturbation analysis for scalable certified robustness and beyond. In: Advances in Neural Information Processing Systems, vol. 33, pp. 1129–1141 (2020)
[14] Salman, H., Yang, G., Zhang, H., Hsieh, C.-J., Zhang, P.: A convex relaxation barrier to tight robustness verification of neural networks. In: Advances in Neural Information Processing Systems, vol. 32, pp. 9835–9846 (2019)
[15] Shi, Z., Zhang, H., Chang, K.-W., Huang, M., Hsieh, C.-J.: Robustness verification for transformers. In: International Conference on Learning Representations (2020)
[16] Bonaert, G., Dimitrov, D.I., Baader, M., Vechev, M.: Fast and precise certification of transformers. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI '21), pp. 466–481 (2021)
[17] Huang, P., Wei, D., Isac, O., Wu, H., Wu, M., Barrett, C.: Parameterized abstract interpretation for transformer verification. In: Proceedings of the Fortieth AAAI Conference on Artificial Intelligence, pp. 35500–35508. AAAI Press, Washington, DC (2026)
[18] Wei, D., Wu, H., Wu, M., Chen, P.-Y., Barrett, C., Farchi, E.: Convex bounds on the softmax function with applications to robustness verification. In: Proceedings of The 26th International Conference on Artificial Intelligence and Statistics. Proceedings of Machine Learning Research, vol. 206, pp. 6853–6878 (2023)
[19] Jia, R., Raghunathan, A., Göksel, K., Liang, P.: Certified robustness to adversarial word substitutions. In: Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 4129–4142. Association for Computational Linguistics, Hong Kong, China (2019)
[20] Kumar, A., Agarwal, C., Srinivas, S., Li, A.J., Feizi, S., Lakkaraju, H.: Certifying LLM safety against adversarial prompting. In: Conference on Language Modeling (COLM) (2024)
[21] Cohen, J., Rosenfeld, E., Kolter, J.Z.: Certified adversarial robustness via randomized smoothing. In: Proceedings of the 36th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 97, pp.
1310–1320 (2019)
[22] Liao, B.H.-C., Cheng, C.-H., Esen, H., Knoll, A.: Are transformers more robust? Towards exact robustness verification for transformers. In: International Conference on Computer Safety, Reliability, and Security, pp. 89–103. Springer, Cham (2023)
[23] Rezazadeh, N., Gholami Davoodi, A.: Vertex-Softmax: Tight transformer verification via exact softmax optimization. arXiv preprint arXiv:2605.10974 (2026)
[24] Shor, N.Z.: Quadratic optimization problems. Soviet Journal of Computer and Systems Sciences 25, 1–11 (1987)
[25] Lasserre, J.B.: Global optimization with polynomials and the problem of moments. SIAM Journal on Optimization 11, 796–817 (2001)
[26] Sherali, H.D., Adams, W.P.: A hierarchy of relaxations between the continuous and convex hull representations for zero-one programming problems. SIAM Journal on Discrete Mathematics 3, 411–430 (1990)
[27] Chandrasekaran, V., Shah, P.: Relative entropy optimization and its applications. Mathematical Programming 161(1–2), 1–32 (2017)
[28] Alon, N., Naor, A.: Approximating the cut-norm via Grothendieck's inequality. SIAM Journal on Computing 35(4), 787–803 (2006)
[29] Dinkelbach, W.: On nonlinear fractional programming. Management Science 13(7), 492–498 (1967)
[30] Singla, S., Feizi, S.: Second-order provable defenses against adversarial attacks. In: Proceedings of the 37th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 119, pp. 8981–8991 (2020)
[31] Kim, H., Papamakarios, G., Mnih, A.: The Lipschitz constant of self-attention. In: Proceedings of the 38th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 139, pp. 5562–5571 (2021)
[32] Cifuentes, D., Agarwal, S., Parrilo, P.A., Thomas, R.R.: On the local stability of semidefinite relaxations. Mathematical Programming 193(2), 629–663 (2022)
[33] Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., Sutskever, I.: Language models are unsupervised multitask learners. Technical report, OpenAI (2019)
[34] Xu, K., Zhang, H., Wang, S., Wang, Y., Jana, S., Lin, X., Hsieh, C.-J.: Fast and complete: Enabling complete neural network verification with rapid and massively parallel incomplete verifiers. In: International Conference on Learning Representations (2021)
[35] Ba, J.L., Kiros, J.R., Hinton, G.E.: Layer normalization. arXiv preprint arXiv:1607.06450 (2016)
[36] Hendrycks, D., Gimpel, K.: Gaussian error linear units (GELUs). arXiv preprint arXiv:1606.08415 (2016)
[37] Elhage, N., Nanda, N., Olsson, C., Henighan, T., Joseph, N., Mann, B., Askell, A., Bai, Y., Chen, A., Conerly, T., DasSarma, N., Drain, D., Ganguli, D., Hatfield-Dodds, Z., Hernandez, D., Jones, A., Kernion, J., Lovitt, L., Ndousse, K., Amodei, D., Brown, T., Clark, J., Kaplan, J., McCandlish, S., Olah, C.: A mathematical framework for transformer circuits. Transformer Circuits Thread (2021)
[38] Ben-Tal, A., Nemirovski, A.: Lectures on Modern Convex Optimization: Analysis, Algorithms, and Engineering Applications. MPS/SIAM Series on Optimization. Society for Industrial and Applied Mathematics, Philadelphia (2001)
[39] Dahl, J., Andersen, E.D.: A primal-dual interior-point algorithm for nonsymmetric exponential-cone optimization. Mathematical Programming 194(1), 341–370 (2022)
[40] Pólik, I., Terlaky, T.: A survey of the S-lemma. SIAM Review 49(3), 371–418 (2007)
[41] Nair, P.: Softmax is 1/2-Lipschitz: A tight bound across all norms. Transactions on Machine Learning Research (2026)
[42] Håstad, J.: Some optimal inapproximability results. Journal of the ACM 48(4), 798–859 (2001)
[43] Raghavendra, P., Steurer, D.: Towards computing the Grothendieck constant. In: Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2009), pp. 525–534 (2009)
[44] Davie, A.M.: Lower bound for . Unpublished note (1984)
[45] Reeds, J.A.: A new lower bound on the real Grothendieck constant. Unpublished manuscript (1991)
[46] Krivine, J.-L.: Constantes de Grothendieck et fonctions de type positif sur les sphères. Advances in Mathematics 31, 16–30 (1979)
[47] Schaible, S.: Fractional programming. II, on Dinkelbach's algorithm. Management Science 22(8), 868–873 (1976)
[48] Goulart, P.J., Chen, Y.: Clarabel: An interior-point solver for conic programs with quadratic objectives. arXiv preprint arXiv:2405.12762 (2024)
[49] Diamond, S., Boyd, S.: CVXPY: A Python-embedded modeling language for convex optimization. Journal of Machine Learning Research 17(83), 1–5 (2016)
[50] Jansson, C., Chaykin, D., Keil, C.: Rigorous error bounds for the optimal value in semidefinite programming. SIAM Journal on Numerical Analysis 46(1), 180–200 (2007)
[51] Neumaier, A., Shcherbina, O.: Safe bounds in linear and mixed-integer linear programming. Mathematical Programming 99(2), 283–296 (2004)
[52] MOSEK ApS: MOSEK Optimizer API for Python, Version 11. (2026)
[53] Gurobi Optimization, LLC: Gurobi Optimizer Reference Manual, Version 13.0. (2026)
[54] Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Kopf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., Chintala, S.: PyTorch: An imperative style, high-performance deep learning library. In: Advances in Neural Information Processing Systems, vol. 32, pp. 8024–8035 (2019)
[55] Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., Funtowicz, M., Davison, J., Shleifer, S., Platen, P., Ma, C., Jernite, Y., Plu, J., Xu, C., Le Scao, T., Gugger, S., Drame, M., Lhoest, Q., Rush, A.: Transformers: State-of-the-art natural language processing. In: Liu, Q., Schlangen, D. (eds.) Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 38–45. Association for Computational Linguistics, Online (2020)
[56] Crescenzi, P., Silvestri, R., Trevisan, L.: On weighted vs unweighted versions of combinatorial optimization problems. Information and Computation 167(1), 10–26 (2001)
[57] Griewank, A., Walther, A.: Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, 2nd edn. Society for Industrial and Applied Mathematics, Philadelphia (2008)
Appendix A Proofs
This appendix proves the results of the body in the order in which they appear. Throughout, for a probability vector and a vector we write , and denotes the logistic function, namely
Proof of Lemma 1
Let and let be the Jacobian of the softmax. For the components of are , so
the mean absolute deviation of u under a. Put
Since the deviations have mean zero,
The minimum of and is largest when they are equal, so
where the second inequality is . Integrating along the segment from to s,
and applying the bound (A3) with for every gives the first inequality of the Lipschitz bound (20), namely . The second holds because . The constant cannot be lowered. For , and ,
so the ratio of to tends to as , although it never equals .
Proof of Lemma 2
The three parts are proved in turn.
(i) Each weight can be written as
which is increasing in and decreasing in every , . Its extreme values over the box are therefore attained at the two corners that appear in the attention intervals (21). The largest value has at its upper end and the other scores at their lower ends, and the smallest value has the reverse.
(ii) For ,
With , so that ,
because . The bound follows in the same way from . Summing over the keys,
(iii) Let , so that . Then,
which is increasing in . With this gives the margin bound (23), namely
□
Proof of Lemma 3
The function is concave and vanishes at both endpoints, so it is nonnegative on the interval and its maximum is attained where its derivative , with the slope of , vanishes, at . By the mean value theorem, for some , so lies in the interval. Writing with ,
which is the closed form of the exact secant gap (24). The bound by is the classical interpolation error of a convex function whose second derivative is at most on the interval, and the bound by holds because and there. Finally,
which gives the expansion (26), namely .
Proof of Proposition 4
Put and . Since and ,
and therefore
Under the secant bounds, the exact secant gap of Lemma 3 gives
Since , the right side of the identity (A7) is at most , and satisfies the constraints and of the knapsack (19), here with the weights .
The reductions for the complexity results use the infinity-to-one norm of a matrix , namely
where the maximum over the boxes equals the maximum over their vertices because the form is affine in each argument. Alon and Naor construct in polynomial time, from a graph with edge set , a matrix with rows and entries in satisfying [28, Proposition 3.2]
Two facts follow. First, deciding whether for an integer matrix and an integer is NP-hard, because deciding whether is. Second, Håstad proved that the maximum cut cannot be approximated in polynomial time within a ratio exceeding 16/17 unless [42], and the same threshold holds for unweighted graphs [56], to which the construction applies. Hence, no polynomial-time algorithm returns, for every integer matrix , a number with
unless P = NP, since would approximate MAXCUT(G) within the ratio . For a nonzero integer matrix we also have
Proof of Theorem 5
Let be nonzero and let be an integer with ; for other the question is trivial. Let and split the coordinates into a first block of coordinates, a second block of coordinates and two flags . The first token and the second token, which is the query, are, respectively,
so both vary in boxes. Let M be the matrix with
let map to its -coordinate times a fixed unit vector , and let . Then,
(A9) so the values do not depend on the varying coordinates, and
Because is strictly increasing, . Since is an integer, holds if and only if for any in the interval
This interval lies in , where , so its length is at least , and a rational in it with bits is computed in polynomial time. The instance and have a size polynomial in that of , which proves the theorem.
Proof of Theorem 6
Let be a nonzero integer matrix and let be the value of the semidefinite relaxation of the norm (A8) in which and are replaced by unit vectors. By Grothendieck's inequality with Krivine's bound on its constant [46],
where . Since , a number with is computed in polynomial time, and . In the two-token instance of the proof of Theorem 5, use in place of . The score of the first token is then , which ranges over , an interval of length between and 2, so the instance is of the type considered in the theorem. Its worst case and the range of its output are, respectively,
(A11)
Suppose that an algorithm returns r with , where
Then,
so lies in , and since on ,
The number , computed in polynomial time, therefore satisfies
an approximation of within a factor 1.038 < 17/16. By the second fact stated before the proof of Theorem 5, the inapproximability of the maximum cut, this is impossible unless P = NP.
Proof of Theorem 7
The three parts are proved in turn.
(i) With the query fixed, the score and the value of each varying key are affine functions of its own token, and the pairs range over the sets independently of each other. Each is compact, as a continuous image of . Every function is affine with slope , so , a maximum of such functions over a compact set, is convex, continuous and strictly decreasing with slopes at most . The fixed terms are affine and strictly decreasing, and is nonempty because it contains the query position. Hence, is convex, continuous and strictly decreasing, and it tends to and at and , respectively, so it has a unique root . For every admissible input and every , separability gives
with equality for tokens realizing maximizers of the . Since the denominator is positive, whenever the left side of inequality (A13) is nonpositive. At the right side is zero, so for every input, and the maximizing tokens give equality. Therefore, , and it is attained.
(ii) The set is the image of a polytope under an affine map into the plane, hence a polygon. For a box or zonotope with generators it is a zonogon generated by segments, with at most vertices obtained by sorting the generators by angle. For the hull of points it is the planar convex hull of their images, with at most vertices. From the projected generators or points, the constructions cost and operations, respectively. Let . If , the maximum of is positive and attained in , where
is concave with a gradient whose first component equals one. It has no stationary point, so the maximum lies on the boundary of . On an edge parametrized as , , the concave function is maximized at an endpoint or at the stationary point
If , then , and maximizing means minimizing , whose logarithm is concave where . The minimum of a concave function over a polygon is attained at a vertex, and the value zero is attained if somewhere. Each is therefore computed by one pass over the vertices and edges of , and each evaluation of costs operations. Since and is strictly decreasing, bisection on with the sign of computes to accuracy in evaluations.
(iii) The same case analysis applies to a filled ellipse . If , the maximum lies on the boundary because has no stationary point. If , then , attained where is largest, which includes a boundary point. Otherwise, on , and is minus the minimum of , whose logarithm is concave. A concave function attains its minimum over a compact convex set at an extreme point, which here lies on the boundary. Write the boundary as with , which covers degenerate ellipses as well. Then,
and the bracket is a trigonometric polynomial of degree at most two. Unless it vanishes identically, in which case f is constant on the boundary, it has at most four zeros in a period. The substitution turns them into the real roots of a polynomial of degree at most four, and is checked separately. Hence, is the largest value of at no more than five angles, computed in a constant number of operations, and the costs of evaluating and of computing follow as in part (ii).
Proof of Proposition 8
For a in the box, every coordinate satisfies
because is the point of closest to ; on the box the cut therefore reads . The polytope is nonempty, since it contains the pattern of every admissible input. Write with , let and suppose , the other case being symmetric. Then,
for some when and have disjoint supports. For a fixed , the best fills the keys in decreasing order of up to their capacities with a total mass , and the best empties the keys in increasing order of down to their floors with a total mass . These are two fractional knapsacks, with values and , concave and convex. If the two solutions overlap on a key, the net transfer is still feasible, with the same objective and a smaller cost, so
The function maximized in the expression (A14) for is concave and piecewise linear, with right derivative equal to the difference of between the next receiver and the next donor, which is nonincreasing in m. It is maximized by increasing m from zero until or the derivative becomes nonpositive, which is the two-phase rule. Sorting costs operations and each phase .
Proof of Theorem 9
Validity was shown after the definition of the pattern polytope certificate, Definition 2. Let be optimal in the linear program (33), which maximizes over the pattern polytope , and choose with for every key, the query being one of them; is an admissible input. Its pattern satisfies because is certified, and
The midpoint of the range of the values satisfies for every . Since ,
(A15)
The width form follows with . For the margin gap bound (35), let be the dominant key and the radius in the margin bound (23). By the attention intervals (21), , and every exponent is at most by the definition of the margin, so
and hence every a in the box and the simplex satisfies
The cut of the margin pair is therefore implied by the attention intervals, and the pattern polytope of the width pair is contained in that of the margin pair. The gap bound (34) applied to the margin pair gives the margin gap bound (35) for the certificate with the width pair.
Proof of Proposition 10
Take , the fixed query , which is also the second key, and the first key with , so that and . Let
so that the value of a token along is . Then, , , and , and the output is
Its derivative,
is negative for and , so
The score intervals of the two keys are, respectively, and , so , the midpoint pattern is uniform, and . The interval bound is tighter than the width cut , so
Since and , the gap formula (36) follows.
Proof of Proposition 11
For the width pair the first phase of the greedy transfer is void, because lies in the box and on the simplex. The second phase moves mass from donors to receivers at a cost of two units of budget per unit of mass. By the greedy solution of Proposition 8, the transfer is optimal for all data. The order in which it visits the keys depends only on . After a small change of or of it therefore performs the same transfers, with the same saturated keys and the same last receiver and donor, which lie strictly inside their intervals by assumption. The three parts are proved in turn.
(i) On the fixed polytope , is a maximum of functions linear in . Such a maximum is convex, and it is differentiable where its maximizer is unique, with gradient equal to that maximizer.
(ii) A change of changes the mass moved from to by , which is feasible for small of either sign because both keys lie strictly inside their intervals, so
(iii) A change of moves a mass between and . The budget is unchanged, because the deviations of and from change by in opposite directions, and the move is feasible for small because lies strictly inside its interval. Receivers are filled in decreasing order of , so and
Validity of and
For an admissible input with base coordinates and pattern , let be the moment matrix of , and let and . Then, (R1) holds because , and (R2) holds because lies in the log-attention interval (14), , by the attention intervals of Lemma 2(i). Constraint (R3) holds because and , and (R4) because . Constraint (R5) holds because
(R6) because the pair is certified, and (R7) because the moment matrix of a single point is the rank-one matrix . Moreover, . For the comparison with the first-order certificate, (R5) gives , so that
while (R3) and (R6) place in the pattern polytope.
Proof of Theorem 12
Let and be feasible for , with first moments , and let be the covariance matrix of . It is the Schur complement of the entry in the moment matrix (11), whose first row is and whose lower right block is , and hence positive semidefinite by the moment conditions (R7). Write for the value of key along at the base coordinate , so that . The proof has four steps.
Step 1: the objective at the first moments. The objective (38) is
Splitting in it gives
By the Cauchy–Schwarz inequality for the positive semidefinite matrix ,
By (R4) and (R3), and by (R1),
Hence,
Step 2: the softmax sandwich. Let , which equals the softmax of the lifted scores because . By (R2), (R3) and the value-weighted sandwich identity of Proposition 4 applied with ,
where and .
Step 3: the lifted scores. By the expression (37), the lifted score differs from the score of the first moments by a covariance term, namely
For a positive semidefinite block matrix, the nuclear norm of an off-diagonal block is at most the geometric mean of the traces of the diagonal blocks, so
and the same bound holds for . By the Lipschitz bound of Lemma 1, . The first moments form an admissible input by (R1), with output . Centring the values at the midpoint of their range, so that ,
Step 4: assembly. From inequality (A23),
Since , every factor in the identity (A21) satisfies , and since the sum in that identity is at most . Combining with inequality (A20),
Taking the supremum over feasible points gives the second-order bound (39).
For boxes , (R1) is replaced by the constraints
The first moments are again admissible. The diagonal constraints give , so Step 3 holds with the circumradii, and since for a positive semidefinite matrix,
so Step 1 holds with the directional value width of the box.
Every step uses the moment matrix only through its first moments and its principal submatrices indexed by the constant, the query, key and the weight of key , together with (R1)–(R4). The bound therefore also holds for the relaxation in which only these submatrices are required to be positive semidefinite.
Proof of Corollary 13
The second-order bound (39) of Theorem 12 states that
The two parts are proved in turn.
(i) The output is a convex combination of values, so is itself a certified lower bound on , and the first-order certificate for never returns a smaller one; one may therefore assume . Since , this gives , and by the exact secant gap of Lemma 3
The last term of the second-order bound is at most , with , which gives the first inequality of the order bound (41). For the second, by the width bound (15), so that, by the multiplicative interval bounds of Lemma 2(ii),
(ii) The argument is in exact arithmetic. By the Cauchy-Schwarz inequality, each score satisfies
so the score intervals, whether computed by this inequality or by the semidefinite bounds, which are never wider, have width
Moreover,
Substituting into the second inequality of the order bound (41), namely
the inequalities
gives
(A26)
For the first-order certificate, the gap bound of Theorem 9 gives
The bounds on the tightness radii follow, since a certificate whose gap is at most on is within of the truth for all . On the two-key instances of Proposition 10, the gap of the first-order certificate is at least , because for , so it exceeds as soon as .
Proof of Proposition 14
Take , the fixed query , which is also the second key, and the first key with , so that . Let
Then, , , and , and the output is
The score of the first key ranges over . Both attention weights therefore have the interval , and both log-attention intervals have the width , since . The width pair is and , and because the query is fixed.
Let be a worst-case input, and its pattern. For , let , let be the moment matrix of the point , and let and . Since is the moment matrix of a single point with and on the simplex, (R1), (R5) and (R7) hold, and (R4) holds when lies in its intervals. The lifted scores are the scores of , and , while
The secant constraint of the second key holds because the secant lies above the exponential. That of the first key, , is equivalent to
because . The remaining constraints, the intervals of , and and the pattern cut (R6), hold for of order and small , because stays below by a margin of order , as shown next. The objective is
Since uniformly for , every maximizer satisfies . As , therefore, , the direction of the gradient of at the origin. Hence, , and for small . At the log-attention lies at a relative position , measured from the centre of its interval in units of the half-width, with , and for the relative position moves by . Since the second derivative of the exponential is at least on the interval, the secant gap at relative position satisfies
Fix and choose
which is of order . For small it satisfies the condition (A27) and the remaining constraints, so that
Letting and using gives the lower bound (43).
For the value-weighted secant slack, the first-order certificate for gives by the first-order gap bound of Theorem 9. Hence, and for small . By the expansion (26) of the exact secant gap, , , while is of order . The knapsack therefore puts the mass on the first key, and .
Proof of Proposition 15
Let be the orthogonal projection onto the row space of , which is spanned by the columns of , and . Then,
so every score, every value along and every lifted expression in the lifted score (37) and the lifted objective (38) depends on a base coordinate only through , and on a second moment block only through . The map sends the ball of radius in onto the ball of radius in the reduced space, because and with . The sets of reachable query, key and value vectors, and hence and the support values , are therefore the same in both coordinate systems. For the relaxations, let
Let be feasible in the original coordinates. Then, is positive semidefinite, its first moments have norm at most , and its diagonal blocks satisfy because . The norms in (R5) do not increase, and the linear constraints and the objective, which involve the base coordinates only through , are unchanged, so the reduced relaxation has at least the same value. Conversely, if is feasible in the reduced coordinates, is feasible in the original ones with the same objective, because has orthonormal columns and preserves traces and norms. The same two maps apply to the semidefinite score bounds.
Proof of Proposition 16
For a feasible point and multipliers in the dual cones, every is nonnegative, so
The linear term is at most . For the matrix term, indices with have , hence a zero row and column, and the remaining part of can be written as with and by the group budgets. Then,
Proof of Proposition 17
The three parts are proved in turn.
(i) Fix an operation and a sign vector . The two points are opposite corners of , where ; since is affine,
which is at least the bracket in the lower bound (52). Also, . Since and for every , is at least the value of its objective at , which is . For a unary operation, Taylor's theorem gives
for a product, , so the bracket equals , whose maximum over the signs is .
(ii) For the segment from to lies in , so Taylor's theorem with Lagrange remainder along it gives
Summing over gives , and the maximum of a quadratic form over a ball of radius is . If every is quadratic and , Taylor's formula is exact and .
(iii) Back-substitution starts from the output , written as a linear function of the outputs of the last operations, and replaces each output , with its current multiplier , by an affine function valid on . It ends with an affine function of the inputs. Each replacement changes the expression, evaluated at the true values of all intermediate quantities, by exactly , so that
At , where and every operand is nominal, the right side is with
an affine function with on . The argument of part (i) applied to each at the corners , together with , gives the claim.
Proof of Corollary 18
With quadratic and , the quadratic upper bound of Proposition 17(ii) is an equality, , whose maximum over the ball is since . Part (i) with gives
The Shor relaxation maximizes over with ; its value is , attained at for a unit top eigenvector . Finally, for ,
Proof of Lemma 19
Formula (54) is the second-order chain rule for a computational graph in reverse form [57]. Affine maps have no second derivative, and a node contributes its adjoint times its local Hessian contracted with the first derivatives of its operands, which is for a unary node and for a product. For any vectors and ,
since the difference is
Choosing for each product, and dropping the unary terms with , gives for a positive semidefinite with . Then,
Appendix B Relaxation Details
This appendix writes out the level-one relaxation of Definition 3 in full, for ball, ellipsoid and box token sets, and records the implementation choices on which the experiments rest.
Let be the set of perturbed tokens, each with base coordinates , and let the fixed tokens have . With biases absorbed into the centres, the score of key and the value of key along are, respectively,
with , , , and . For the two linear terms act on the same coordinate. The lifted vector is , of dimension , and is its moment matrix (11), of side , whose first row is and whose lower right block holds the second moments. The scalars and the variables of the pattern cut are not lifted.
For balls and ellipsoids in base coordinates, , the relaxation maximizes
subject to the following constraints, in which the lifted score is
(R1) and for .
(R2) for , and .
(R3) with and (omitted when ), , and .
(R4)
(R5) and for for and for all .
(R6) , and . The certified pair is the width pair, with and , or, in the experiments, the margin pair when it gives the smaller radius. The margin pair is the one-hot pattern of the dominant key with the radius of the margin bound (23). The cut of the margin pair is implied by the attention intervals in (R3), as the proof of the first-order gap bound, Theorem 9, shows. On those instances the experiments therefore drop the cut in effect, and keeping the width cut instead would never give a weaker relaxation.
(R7) and .
The norm constraints are second-order cones, and the exponential cone constraint is . For the query, which is also key , the product is the product of its own weight with its own perturbation, as for every other key.
For a box , with and inequalities between vectors understood componentwise, (R1) and the products with the sets in (R5) become
the second family being the products . In an ablation on synthetic heads, the products of the box constraints of pairs of coordinates, the reformulation-linearization constraints on , were also added. They did not change the order of accuracy. The proof of the second-order bound, Theorem 12, for boxes uses only the constraints (B3) and the box variance bound (A25), namely .
Keys with negligible attention are pruned. For keys with the exponential cone and secant constraints are removed, while their score, log-attention and attention intervals, the definition , the interval diagonal and the products with the sets are kept. This removes badly scaled cones, with of the order of -18, that caused the solver to stop short at high temperature. Removing constraints enlarges the feasible set, so the certificate remains valid. The proof of the second-order bound, Theorem 12, goes through with of either sign for a pruned key. The unpruned keys still satisfy , because for the pruned ones. Since and both lie in , a pruned key has . Every value lies in the interval , of length , which also contains with . The pruned keys therefore add at most to the right side of the second-order bound (39), namely to
The safe dual bound of Proposition 16 is applied to the relaxation as it is passed to the solver. The multipliers are the solver's dual values projected onto the dual cones. Multipliers of linear inequalities are clipped at zero, and the scalar part of a second-order cone multiplier is raised to the norm of its vector part. An exponential cone multiplier is moved to the boundary of the dual cone in the component that certifies membership. Since any multipliers in the dual cones give a valid bound, both sign conventions of the returned duals are evaluated and the smaller bound is kept. The a priori bounds of Proposition 16 are those implied by the relaxation itself. They are the ball constraints for the first moments of the base coordinates, the intervals for , and , and . For the diagonal of , each ball block forms a group with and budget one, each box coordinate has , each weight has by (R4), and . The matrix term is bounded by the smaller of the eigenvalue term of the safe bound (46) and the entrywise bound of the positive semidefinite part. Rounding errors in the evaluation of the bound (46), including the eigenvalue computation, are covered by adding 64 times the sum of the absolute values of all its terms, where is the unit roundoff. This allowance is generous for the sizes involved, but it is not a proof in the sense of interval arithmetic. A fully rigorous evaluation would follow VSDP [50]. The same remark applies to the score intervals. Their endpoints are computed by the Shor relaxation at the solver's default tolerance of and widened by for an endpoint of value v.
The score intervals themselves are computed as follows. For a key , the upper end is the value of the Shor relaxation of , that is, the maximum of the lifted score over moment matrices of subject to (R1). The lower end is obtained from . Because the score depends on the query only through and on the key only through , the relaxation is solved in coordinates of dimension , a matrix of side 129 on GPT-2, with the same value. For the problem has one ball, and the relaxation is exact by the S-lemma. The attention intervals then follow in closed form from Lemma 2, namely
and the definition (14) gives the interval of the normalizer and the log-attention intervals . The log-sum-exp is evaluated in a numerically stable way. The exact secant gaps follow from the closed form (24), with . For narrow intervals, this formula subtracts nearly equal numbers. It is therefore computed with the standard library functions and , which remain accurate for small , and with a short Taylor series when is very small.
A node of the branch-and-bound is the instance with the score intervals of some keys restricted. Since a child is a restriction of its parent, its bound is the minimum of its parent's bound and the safe value of the relaxation with the node's score intervals and all controls recomputed from them. Nodes are explored best first. A child is discarded when the solver certifies that its relaxation is infeasible or when its bound does not exceed the best feasible value. The search stops when the bracket is below of the output's range of motion or after 24 semidefinite solves. The certificate is then the minimum of the first-order certificate and the largest bound of the open leaves. Feasible values, which certify the lower ends of all brackets, are obtained by local ascent from many starts. The starts are the nominal tokens, the maximizers of the support values used by the first-order certificate, and the first moments of the relaxation with roundings of its three leading eigenvectors. They also include the first moments of every branch-and-bound leaf and 24 random points on the boundaries of the token sets. Each ascent runs a limited-memory quasi-Newton method in base coordinates, with projection onto the token sets, for at most 2,000 iterations.
The relaxations of the synthetic experiments are solved through a modelling layer with the solver's default tolerances of . On GPT-2 they are passed directly to the solver's task interface, with primal and dual feasibility tolerances of and a relative gap tolerance of . A unit is re-solved at whenever the difference between its safe value and the solver's dual objective exceeds 1% of the gap between the certificate and the best feasible value, and the smaller safe value is kept. The exact references on synthetic heads are nonconvex programs in the log form of the softmax. They have the bilinear scores and the products of weights and values as explicit constraints, the exponential as a nonlinear constraint handled by spatial branch-and-bound, and all controls of Table 1 as variable bounds. They are solved to a relative gap of or to the time limit, 300 seconds for and 90 seconds for larger radii, in which case only their bounds are used.
The GPT-2 experiments use the following five prompts, numbered from zero as in Section 7.
-
The small dog ran across the green field to find the red ball that the children had thrown.
-
Every morning the baker opens the shop at six, and the smell of fresh bread fills the quiet street.
-
When the train arrived late, the passengers waited on the cold platform and talked about the weather.
-
Anna wrote a long letter to her brother, and then she walked to the post office to send it.
-
The river flows past the village, under the stone bridge, and into the lake where the boats are kept.