Repository navigation
Conversation
* add gp.acquisition with AcquisitionFunction base class, MaximumVariance, UpperConfidenceBound, ExpectedImprovement, and ProbabilityOfImprovement * EI and PI are computed in log space to keep values and gradients finite far from the incumbent * add gp.posterior.Posterior, an immutable JAX-traceable posterior snapshot, and GaussianProcess.posterior(); posterior_mean/posterior_covariance delegate to it * get_sample_point accepts acquisition=, q=, and fantasy_noise=, and returns shape (q, d); x may be one starting coordinate or (m, d) candidates * q > 1 selects points greedily with the Kriging Believer heuristic, using local fantasy observations so the Gaussian process is never modified * optimization keeps the best in-domain iterate rather than the last one * default behavior (maximum posterior variance, q = 1) is unchanged * update gp-1d demo to pass candidates directly to get_sample_point * add Kriging Believer note to gp formalism docs * add tests for batch selection, acquisitions, log-space EI, and noise augmentation
* get_sample_point stops once the best acquisition value improves by at most rtol * |best| + atol over the last window steps; n is now the maximum number of steps * new keyword arguments rtol (default 1e-2), atol (default 1e-8), and window (default 10); rtol=None restores fixed-n optimization * add AcquisitionFunction.log_scale (True for EI and PI), so convergence of log-space acquisitions compares absolute differences, i.e., relative changes of the underlying quantity * add tests for early stopping, convergence of UCB and EI, the windowed criterion, and argument validation * note the stopping criterion in the gp-1d demo
Collaborator
Author
|
The tests just failed—whoops! This is a real failure that I'll need to investigate tomorrow. Until then, feel free to hold off on a review. |
* python 3.14 introduced lazy evaluation of type annotations, which allows for the possibility of name collisions on evaluation * these changes resolve this issue by importing members from gp submodules directly, rather than importing the entire submodule and type hinting at a member of a submodule
…posterior * gp.posterior is distinct from gp.GaussianProcess.posterior * this suppresses the style error
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GaussianProcess.get_sample_pointcould only maximize posterior variance, returned one point per call, and always ran a fixed number of optimizer steps. This PR makes the acquisition function pluggable, adds batch selection ofqpoints per call, and stops optimization once it converges.Default behavior is unchanged apart from stopping earlier: maximum posterior variance, one point per call, same return shape
(1, d). Existing calls keep working.Changes
Acquisition functions (
gp.acquisition, new)AcquisitionFunctionbase class, plusMaximumVariance,UpperConfidenceBound,ExpectedImprovement, andProbabilityOfImprovement.maximize=and, for vector-valued GPs, scalarizationweights=.Posterior snapshot (
gp.posterior, new)Posterioris a read-only, JAX-traceable snapshot of a conditioned GP. Acquisition functions evaluate against it, and you can get one withGaussianProcess.posterior().posterior_meanandposterior_covariancenow delegate to it.get_sample_pointacquisition=selects the acquisition function. The default isMaximumVariance().xmay be a single starting point(d,), or candidates(m, d). The best in-domain candidate is used as the starting point, and out-of-domain candidates are skipped.q=selects several points greedily using the Kriging Believer heuristic. After each pick, the posterior is conditioned on a "fantasy" observation at the posterior mean, with noisefantasy_noise(default: the mean training noise, floored atnugget). Fantasy observations are local to the call; the GP is never modified.rtol·|best| + atolover the lastwindowsteps (defaults1e-2,1e-8,10). For log-space acquisitions this compares absolute differences, which are relative changes in EI or PI.nis now the maximum number of steps, andrtol=Nonerestores fixed-nbehavior.Docs and demo
docs/formalism/gp.md: note on the Kriging Believer heuristic.demos/gp-1d.ipynb: passes random candidates straight toget_sample_point, replacing the manual pre-screening step.Notes
xi=0can pick nearly the same point repeatedly within a batch. This is a known weakness of PI, documented in its docstring; usexi > 0.q=3batch takes about 1–2 s on CPU.nugget, the fantasy noise is floored, so Kronecker kernels fall back to a dense Cholesky solve during batch selection. Results are unaffected; it's just slower.Testing
tests/test_gp.py: batch selection (including that a greedy max-variance batch matches sequential conditioning), each acquisition function, the log-space EI math, noise handling, early stopping, and input checks. The full suite passes (52 tests).demos/gp-1d.ipynbruns end to end.AI Use
Much of these changes were made with the use of AI/LLMs, in particular Claude Opus 5.5. After I suggested an initial plan and iterating on that design, Claude was used to execute the implementation. I verified the implementation against the plan and verified consistency with the codebase. Finally, Claude was used to draft this PR.