cswork / libraryOpen practice workspace

Articles

Bayesian Optimization Interview Questions: Surrogates, Acquisition, and Noisy Trials

Answer Bayesian optimization interview questions on GP surrogates, acquisition choices, noisy trials, constraints, and evaluation.

You have budget for twelve expensive model-training trials. Configuration A has the best observed score, but that score came from one noisy run. Configuration B has a slightly lower predicted mean and much more uncertainty. Should the next trial repeat A, explore B, or try a third setting? A Bayesian optimization interview answer should explain the decision rule and what evidence would make the final recommendation trustworthy.

This guide treats Bayesian optimization as a loop: define an objective and feasible space, fit a surrogate, use an acquisition function to choose the next evaluation, observe a noisy outcome, update the model, and stop under a budget. For a tuning prompt, use Select and tune XGBoost hyperparameters and state which validation metric each trial is allowed to see.

Evidence boundary: BoTorch's official documentation supports the surrogate, posterior, acquisition, and noisy-trial mechanisms discussed below. The A/B/C candidate exercise is synthetic reasoning, not a reported company question or a numerical BoTorch result.

The short answer: optimize the next measurement

Bayesian optimization is useful when evaluating the true objective is expensive relative to fitting and querying a surrogate. Training a model, running a lab experiment, or testing a simulation may take minutes or days; calculating a candidate's acquisition score is comparatively cheap. Rather than enumerate a grid, the loop uses observed outcomes to decide where a scarce next trial is most valuable.

The surrogate predicts a distribution over the unknown objective at candidate settings. A Gaussian process is a common example, but the approach is not limited to GPs. The acquisition function consumes that predictive belief and assigns a value to trying a candidate. The key distinction is that the best predicted objective and the best next experiment need not be the same point: uncertain regions can be worth measuring.

An interview answer should begin by defining the unit of a trial, feasible parameter bounds, objective direction, measurement noise, and total cost. Without these, “use expected improvement” is only a named technique. If the objective is cheap to evaluate or the space is tiny and discrete, random or exhaustive search may be simpler and more robust.

What must the surrogate model?

Let x be a candidate configuration and f(x) the latent performance you care about. A trial observes y, which may equal f(x) plus measurement noise. The surrogate uses completed pairs of x and y to produce a posterior belief about f at untried settings. The posterior mean describes plausible performance; uncertainty describes what the model has not learned. A model that supplies only a point estimate leaves an acquisition policy blind to exploration.

Keep two kinds of uncertainty distinct. Epistemic uncertainty reflects limited knowledge of f at a setting and can shrink with informative data. Aleatoric or observation noise reflects variation in repeated measurements under the trial protocol; it may persist even when the setting is well studied. A wide predictive distribution might arise from either or both. Repeating the exact trial can help estimate a noisy mean, while sampling an unexplored region helps learn the shape of f.

BoTorch documents models with inferred constant noise and models supplied with observed noise variance. Those choices require different evidence. If trial variances differ because some settings are unstable or measured with different sample sizes, pretending every observation has the same precision can distort the surrogate. Record repeats, seeds, sample sizes, and standard errors when available. Do not pass a standard deviation where a variance is expected.

For hyperparameter tuning, standardize or transform inputs appropriately, preserve categorical semantics, and enforce feasible bounds. A GP kernel on arbitrary integer encodings of unrelated categories can imply false proximity. If the space is high dimensional or heavily conditional, say where a simple GP may struggle and consider a compatible model or a simpler baseline. BoTorch's acquisition interface supports posterior-sampling models beyond GPs, but flexibility is not a license to ignore fit diagnostics.

Which candidate should the acquisition choose?

Imagine three settings under the same training and evaluation budget. A has a high posterior mean and narrow uncertainty. B has a somewhat lower mean and wide uncertainty. C has a low mean and narrow uncertainty. A pure exploitation policy chooses A. An exploration-aware policy may select B if the probability and magnitude of beating the incumbent justify another expensive trial. C is unlikely to be useful unless it offers another benefit, such as satisfying a constraint.

This is a qualitative exercise. Without an explicit posterior distribution, incumbent baseline, and acquisition function, it is incorrect to claim B has the highest expected improvement. The strongest answer says what would be calculated and which assumptions would change the ranking. Expected improvement values improvement over an incumbent under a predictive distribution; upper-confidence-bound-style policies add a tunable uncertainty reward; Thompson sampling chooses according to a posterior sample. Each embodies a different exploration policy.

BoTorch describes both analytic and Monte Carlo acquisition functions. Joint batch choices generally require accounting for correlations among candidate outcomes: choosing the top three single-point scores can waste trials on near-duplicates. A batch acquisition can value a set of points together. The candidate selected by the acquisition still has to be feasible and runnable; acquisition optimization is an inner optimization problem with its own bounds and numerical checks.

Ask the interviewer whether the next trial is one setting or a batch, whether some trials are already running, and whether one setting costs more than another. A batch can reduce wall-clock time but spend more budget before learning from earlier outcomes. Pending evaluations should be represented rather than naively recommending the same point to several workers. If trial costs vary substantially, maximizing improvement per unit cost can be more appropriate than raw improvement.

Why does noise change expected improvement?

With noiseless observations, the best observed value is a reasonable incumbent baseline. With noisy observations, the maximum observed y is upward-biased: the “winner” may simply have received a lucky seed. Using that lucky maximum as if it were the true f value can make every other candidate look unpromising. The acquisition needs to account for uncertainty at previously observed settings as well as candidates.

BoTorch's closed-loop constrained tutorial uses qLogEI and qLogNEI, the latter a log-space noisy expected-improvement approach. The tutorial explicitly models noisy objective and constraint observations and iterates candidate selection, observation, and surrogate update. That is a concrete official example, not proof that qLogNEI is optimal for every workload. If using a library, name its current API and version; do not reproduce old snippets from memory.

A repeat trial can be valuable when the leading setting's performance is uncertain and the final decision depends on whether its mean truly beats alternatives. But repeated observations consume budget. Compare the expected decision value of another replicate with the value of exploring a new region. If there is only one trial left, ask whether it should optimize discovery or confirm the candidate you intend to ship.

Use common random numbers or matched seeds when comparing configurations if the experiment design permits it; this can reduce comparison variance. Do not reuse a validation set in a way that leaks test information into tuning. With stochastic training, log the seed and environment so a surprising score can be reproduced. With online experiments, changing traffic mix, novelty effects, or noncompliance are separate design issues; Bayesian optimization does not repair a biased measurement pipeline.

A noisy-trial interview trace

Set a hypothetical twelve-trial budget. Spend an initial few trials covering the feasible space rather than placing all observations near one guess. Fit the surrogate on the results and check whether its uncertainty is credible against repeats or held-out trials. Suppose A's single score is highest but its replicate is notably lower. Update the model with both observations instead of keeping only the maximum. Now the posterior for A's latent mean may move down while its uncertainty becomes more honest.

Next, evaluate the acquisition over A, B, C, and the broader feasible domain. If it chooses B, explain whether that is because B has a plausible high upside, because a constraint is uncertain, or because it is cheap. Do not write “exploration” as a catch-all. After B's trial, append the observation, refit or update the surrogate, and recompute acquisition values. A closed loop changes its next choice when evidence changes.

When fewer than three trials remain, distinguish a search recommendation from a deployment recommendation. The acquisition-selected next point is not automatically the setting to deploy. The final setting should be selected from a posterior decision rule or validated candidate set under the stated objective and constraints. Confirm it with a fresh, independent evaluation or enough repeat runs to estimate stability. Report the remaining uncertainty, not only the largest tuned validation score.

The exercise can fail even with flawless acquisition code. If the objective changes midway, compute budgets differ between trials, or preprocessing is fitted using future folds, the surrogate learns a mixture of incomparable measurements. Version the dataset, metric, training pipeline, hardware budget, and constraints for each trial. A trial ledger is as important as the optimizer state.

How do constraints and unequal costs enter?

Suppose accuracy is the objective but inference latency must stay under a threshold. Discarding every unmeasured setting with uncertain latency may prevent exploration; ignoring latency until the end can waste the budget on unusable candidates. Model feasibility or include it in the acquisition so the next trial considers both potential improvement and probability of satisfying the constraint. The BoTorch tutorial demonstrates a noisy objective with a noisy constraint, though your actual constraint model and risk tolerance depend on the application.

Distinguish hard safety constraints from negotiable business preferences. A configuration that might exceed a safety limit should not be tried just because it has a high acquisition value. Enforce known feasibility rules before proposing the trial; use conservative bounds or a safe-search design for uncertain hazards. Bayesian optimization is a selection method, not authorization to perform unsafe experiments.

Trial cost may vary with model size, dataset size, or simulation fidelity. A cheap proxy run can screen candidates, but only if you understand how its score relates to the full objective. Multi-fidelity methods can explicitly model that relationship. Otherwise a low-fidelity winner may not transfer. If a full run takes a day and a proxy takes an hour, explain the fidelity bias and how many full confirmations the budget reserves.

In parallel operation, don't ignore pending trials. A naive worker that reads an unchanged completed dataset can suggest the same candidate several times. Reserve suggested points, use a batch acquisition, or account for pending evaluations. When one trial fails, distinguish infrastructure failure from an observed poor objective; silently treating a timeout as a low score changes the modeled function.

When should you stop or choose another method?

Stop when the budget is exhausted, the expected value of another trial is below its cost, or the decision is sufficiently stable under the application loss. A tiny acquisition value alone is not an infallible stopping rule: the surrogate may be overconfident, the search space may be misspecified, or the optimizer may have found a local acquisition optimum. Check calibration, repeated trials, and random-search baselines.

Bayesian optimization is not automatically preferable for every hyperparameter grid. If each evaluation is cheap, many configurations can run in parallel, and the dimensions are mostly categorical or conditional, a well-designed random search may be easier to operate. If the objective drifts over time, old trials may no longer describe today's function. State the conditions under which adaptive modeling repays its overhead.

Compare methods fairly on the same evaluation budget, seed protocol, and untouched final test. Plot best confirmed objective versus cumulative cost, not only trial number. Report uncertainty across optimizer runs, because the optimizer itself has randomness and can get lucky. Separate optimization quality from model-selection bias: the test set must not become another acquisition signal.

A concise interview answer has four parts: what f and the constraints mean; what posterior the surrogate produces; what acquisition values and why; and how noisy measurements are recorded, repeated, and independently confirmed. If any part is missing, naming a fashionable library cannot rescue the decision.

Sources and Further Reading