The scalar surrogate for a noisy oracle

The headers under gpr/bo/ hold a Gaussian process (GP) on a parameter vector with one scalar output. It is not the joint energy-force model of the saddle searches. Its oracle returns a value and an error bar. A client that tunes or designs stochastic runs, such as Monte Carlo averages, uses it as the surrogate of that oracle. This page states the formulas each part implements and the reference they come from.

Observations with one noise variance per row

Row \(i\) of the design is a parameter vector \(x_i\) with the value \(y_i = f(x_i) + \epsilon_i\). The error \(\epsilon_i\) is normal with zero mean and variance \(s_i^2\). The variances need not agree: a Monte Carlo average of \(N_i\) samples has \(s_i^2\) proportional to \(1/N_i\). The covariance of the observations is

\[K_y = K + \mathrm{diag}(s_1^2, \ldots, s_n^2), \qquad K_{ij} = k(x_i, x_j).\]

ScalarGaussianProcess::fit(x, y, noise_variances) adds \(s_i^2\) to entry \((i, i)\) and factors \(K_y\). fit(x, y, noise_variance) uses one variance for every row. With a zero prior mean, the prediction at \(x_*\) is

\[\mu(x_*) = k_*^\top K_y^{-1} y, \qquad \sigma_f^2(x_*) = k(x_*, x_*) - k_*^\top K_y^{-1} k_*,\]

with \(k_* = (k(x_1, x_*), \ldots, k(x_n, x_*))\). See Rasmussen and Williams (2006), section 2.2. \(\sigma_f\) is the standard deviation of the latent function \(f\), without the noise of a new run. predict returns it. An acquisition function that ranks parameter vectors needs this one: the noise of a replicate says nothing about where \(f\) is small. predictObservation returns \(\sqrt{\sigma_f^2(x_*) + s_*^2}\) for a caller-supplied \(s_*^2\), the spread of a new run at \(x_*\).

When the factorization needs it, fit adds the smallest nugget that brings the condition number of \(K_y\) under its limit. effectiveNugget() reports that value, which is zero for a well-conditioned design.

A parametric mean fitted with the process

The prior mean is zero by default. setMeanBasis takes basis functions \(\phi(x)\) and models \(f(x) = \phi(x)^\top \beta + g(x)\) with \(g\) a zero-mean GP. Let \(H\) hold \(\phi(x_i)^\top\) in row \(i\). In the limit of a vague prior on \(\beta\), fit estimates the coefficients by generalized least squares,

\[\hat\beta = A^{-1} H^\top K_y^{-1} y, \qquad A = H^\top K_y^{-1} H,\]

and conditions the GP on the residual \(y - H \hat\beta\). The prediction is

\[\mu(x_*) = \phi(x_*)^\top \hat\beta + k_*^\top K_y^{-1} (y - H \hat\beta),\]
\[\sigma_f^2(x_*) = k(x_*, x_*) - k_*^\top K_y^{-1} k_* + R^\top A^{-1} R, \qquad R = \phi(x_*) - H^\top K_y^{-1} k_*.\]

The last term carries the uncertainty of \(\hat\beta\) into the variance. It grows away from the design, where the trend is an extrapolation. The kriging literature calls this form universal kriging. It is Rasmussen and Williams (2006), section 2.7, equations (2.41) and (2.42), with the prior precision of \(\beta\) set to zero. meanCoefficients() returns \(\hat\beta\) and meanCoefficientCovariance() returns \(A^{-1}\). setUsePriorMean(true) is the basis \(\phi(x) = 1\), a fitted constant.

fit reports failure when \(A\) is not positive definite, for example with more basis functions than rows or with two functions that agree on every row.

Hyperparameters from the marginal likelihood

ScalarSurrogate (gpr/bo/ScalarSurrogate.h) fixes the kernel family, so its parameters are run-time values. The kernel is a radial shape (RadialKind: squared exponential, Matern 3/2 or Matern 5/2) of the distance \(r^2 = \sum_d (x_d - x'_d)^2 / \ell_d^2\). Each coordinate has its own length scale \(\ell_d\), and the signal variance is \(\sigma^2 = k(x, x)\). Its hyperparameters are \(\theta = (\log \ell_1, \ldots, \log \ell_D, \log \sigma^2)\), and \(\log \sigma_n^2\) as well when the rows carry no variance of their own. A variance supplied per row is data and is not fitted.

optimizeHyperparameters maximizes the log marginal likelihood

\[\log p(y \mid X, \theta) = -\tfrac12 y^\top K_y^{-1} y -\tfrac12 \log \det K_y - \tfrac n2 \log 2\pi\]

with the gradient

\[\frac{\partial}{\partial \theta_j} \log p(y \mid X, \theta) = \tfrac12 \mathrm{tr}\!\left( (\alpha \alpha^\top - K_y^{-1}) \frac{\partial K_y}{\partial \theta_j} \right), \qquad \alpha = K_y^{-1} y,\]

Rasmussen and Williams (2006), equations (5.8) and (5.9). With a mean basis of \(p\) functions the coefficients are integrated out under the vague prior, equation (2.45):

\[\log p(y \mid X, \theta) = -\tfrac12 y^\top P y - \tfrac12 \log \det K_y -\tfrac12 \log \det A - \tfrac{n - p}{2} \log 2\pi, \qquad P = K_y^{-1} - K_y^{-1} H A^{-1} H^\top K_y^{-1},\]

and the gradient keeps its form with \(\alpha = P y\) and \(P\) in place of \(K_y^{-1}\). scalarLogMarginalLikelihood evaluates the value and the gradient. A test compares that gradient with central differences for the three shapes: ScalarLogMarginalLikelihood.GradientMatchesCentralDifferences.

fitScalarHyperparameters runs the limited-memory BFGS solver of rgmin on \(\theta\), the solver the Bayesian quadrature fit uses. It starts eight times by default: once from the caller’s hyperparameters, then from points drawn with equal density in \(\theta\) inside a box. It returns the start with the largest likelihood. The default box comes from the data. A length scale lies between 0.02 and 20 times the range of its column. The signal variance lies between \(10^{-4}\) and \(10^{3}\) times the sample variance of \(y\), and the noise variance between \(10^{-8}\) and 10 times it. ScalarFitConfig sets the number of starts, the iteration limit, the seed and the box.

The likelihood has more than one maximum on small designs: a short length scale with little noise and a long length scale with much noise can both explain the same rows. The starts reduce that risk and do not remove it. The tests draw 240 rows from the prior and recover each length scale within a factor 1.4, the signal variance within a factor 2 and the noise variance within a factor 1.6.

Integer, listed and categorical axes

ParameterSearch.h searches a box whose axes are mapped to the unit cube. A ParameterBound is continuous by default, linear or logarithmic. Three members make it discrete:

  • integer keeps the whole numbers between the bounds.

  • allowed_values replaces the interval by a list, for example the divisors of a core count. The surrogate sees the position in the list, so neighbours in the list count as similar.

  • categorical, with allowed_values, marks the list as unordered labels. The default kernel then replaces the difference on that axis by the indicator of unequal labels: the term of \(r^2\) is \([x_d \neq x'_d] / \ell_d^2\). That is the squared Euclidean distance of a one-hot encoding up to a constant factor in \(\ell_d^2\), so the kernel stays positive definite. The marginal likelihood gradient uses the same term.

Rounding happens inside the acquisition. Every candidate is moved to its lattice point before the surrogate scores it, so the score belongs to the point that would be evaluated, and a candidate that rounds to an evaluated point is dropped. The neighbours of the best point on each discrete axis join the candidates: the two adjacent values of an ordered axis and every other label of a categorical one. A lattice with fewer points than the budget ends the search once every point has been evaluated. The Nelder-Mead polish of minimize is skipped when an axis is discrete.

The rank coordinate of an ordered list is a modelling choice. For divisors 1, 2, 4, 8 it equals a logarithmic axis. For an irregular list it treats each step as the same distance.

Batches by the constant liar

minimize owns the loop and calls the loss itself. ParameterSearch is the ask-and-tell form for a client that runs the evaluations: observe records a result and propose(q) returns up to \(q\) parameter vectors to run next, so that \(q\) runs fit in one allocation.

Expected improvement for a minimizer with incumbent \(f_{\min}\) is

\[\mathrm{EI}(x) = (f_{\min} - \mu(x)) \Phi(z) + \sigma_f(x) \phi(z), \qquad z = \frac{f_{\min} - \mu(x)}{\sigma_f(x)},\]

Jones, Schonlau and Welch (1998). Picking the \(q\) best candidates of one EI surface returns near-copies of one point. propose uses the constant liar heuristic of Ginsbourger, Le Riche and Carraro (2010) instead:

  1. Maximize EI over the candidates and take the best point \(x^{(1)}\).

  2. Condition the surrogate on a made-up observation \((x^{(1)}, L)\). The lie \(L\) is the incumbent, the variant the authors call CL-min. It removes the improvement near \(x^{(1)}\) without changing the incumbent.

  3. Maximize EI again for \(x^{(2)}\), and repeat until the batch is full.

The hyperparameters are not refitted on the lies. A lie has the noise variance of a typical run: the shared variance, or the median of the row variances. When no candidate has positive EI the batch is filled with the candidate of largest \(\sigma_f\). Fewer than \(q\) vectors come back when the lattice has fewer unevaluated points. Without observations propose returns Halton points, a space-filling start.

CL-min is the exploratory choice among the constant lies: a lie at the incumbent makes the neighbourhood of the pending point look solved. A Kriging believer would use \(\mu(x^{(1)})\) as the lie, and it differs only where the surrogate mean is far from the incumbent.

The losses are standardized to zero mean and unit variance before the fit, and the search runs in the unit cube. fit_hyperparameters in ParameterSearchConfig turns on the marginal likelihood fit before each proposal once there are \(\max(2D + 2, 6)\) rows. Its box is 0.05 to 5 for a length scale, 0.05 to 20 for the signal variance and \(10^{-8}\) to 1 for the noise variance, in those standardized units.

Constraints through a feasibility model

An observation may carry a constraint value \(c(x)\), feasible when \(c(x) \le 0\): a margin such as an error bar minus its target, or a wall time minus its limit. A second scalar GP models \(c\), independent of the loss model, and the acquisition is expected improvement times the probability of feasibility,

\[\alpha(x) = \mathrm{EI}(x) \, \Phi\!\left( \frac{-\mu_c(x)}{\sigma_c(x)} \right),\]

Gardner et al. (2014) and Gelbart, Snoek and Adams (2014). The incumbent is the best loss among the feasible evaluated points. Until one exists the acquisition is the probability of feasibility alone, as Gelbart, Snoek and Adams propose. The constraint values are divided by their root mean square and not shifted, because the threshold is zero.

A run that produced no loss, such as a crash, is recorded with a non-finite loss and a positive constraint. It enters the feasibility model only. A caller that knows the outcome and no margin passes \(-1\) for a feasible run and \(+1\) for an infeasible one.

Limitation: the feasibility model is a GP regression on the constraint value. With a real margin \(\Phi(-\mu_c / \sigma_c)\) is the probability of \(c(x) \le 0\) under that model. With the labels \(\pm 1\) it is a score that orders candidates and is not a calibrated probability. A calibrated one needs a classification likelihood (probit with a Laplace or expectation-propagation approximation, Rasmussen and Williams (2006), chapter 3), which this version does not implement. During a batch the feasibility model is not conditioned on the pending points. The lower confidence bound acquisition does not accept constraints.

The incumbent of a noisy oracle

Expected improvement measures improvement over \(f_{\min}\). For an exact oracle that is the smallest observed loss. For a noisy one the smallest observation is biased low: among many runs the smallest is the one whose noise happened to be most negative. One lucky run would then set a bar that no honest candidate can beat, and the search would stall or circle the lucky point.

With noisy_objective the incumbent is the plug-in value

\[f_{\min} = \min_i \mu(x_i),\]

the smallest posterior mean of the latent loss over the evaluated (and feasible) points \(x_i\). Picheny, Wagner and Ginsbourger (2013) review this form with the other criteria for noisy observations. EI is evaluated with the latent \(\sigma_f\), so it stays positive at an evaluated point whose mean is uncertain, and such a point may be proposed again as a replicate. best() returns the point with the smallest posterior mean and that mean. The constant liar uses the same value as its lie.

The plug-in form ignores the uncertainty of \(f_{\min}\) itself. It is the cheapest of the reviewed criteria and needs no integration over the incumbent. The test ParameterSearchNoise.ALuckyRunDoesNotCaptureTheSearch puts one run four noise standard deviations below the truth, away from the minimum, and checks that the incumbent and the next batch stay at the true minimum.