Skip to content

Add BAxUS generator for high-dimensional Bayesian optimization - #452

Open
gian21391 wants to merge 3 commits into
xopt-org:mainfrom
gian21391:baxus-generator
Open

Add BAxUS generator for high-dimensional Bayesian optimization#452
gian21391 wants to merge 3 commits into
xopt-org:mainfrom
gian21391:baxus-generator

Conversation

@gian21391

@gian21391 gian21391 commented Jul 24, 2026

Copy link
Copy Markdown

Implements BAxUS (Papenmeier et al., NeurIPS 2022) for single-objective problems where most input dimensions are irrelevant. Optimization happens inside a sparse random embedding that expands whenever the trust region collapses, so a run starts cheap in a few dimensions and only pays for more as it earns them.

from xopt.generators.bayesian import BAxUSGenerator

generator = BAxUSGenerator(
    vocs=vocs,             # 100 continuous variables, 3 of which matter
    target_dim_init=2,     # start in a 2-D subspace
    seed=0,
    eval_budget=60,        # total planned evaluations — paces the expansion schedule
)

On a 100-D sphere with 3 effective dimensions the embedding grows 2 → 8 → 32 over 25 steps. The generator draws its own Sobol seed points, so no random_evaluate is needed first. Set eval_budget to the number of planned evaluations — without it the reference expansion schedule is replaced by a ceil(target_dim / 2) heuristic that expands far more slowly.

Scope — narrower than the other Bayesian generators

The GP lives in the embedded subspace rather than in VOCS space, so anything keyed to VOCS-space columns can't be honored. Constraints, observables, discrete and contextual variables, fixed_features, max_travel_distances, custom_objective, n_interpolate_points and turbo controllers are all rejected at construction rather than silently ignored. It generates one candidate at a time, and visualize_model raises.

Deviations from the reference

target_dim_init is a user knob rather than derived from input dimensionality; the acquisition is the inherited analytic LogEI over the trust-region box rather than Thompson sampling over a masked candidate set; and data not generated through the current embedding is least-squares projected into target space. All three are documented in the module docstring and docs/algorithms.md.

Test

119 tests in xopt/tests/generators/bayesian/test_baxus.py. Beyond ordinary coverage it pins: a _TutorialBaxusState oracle transcribed from the BoTorch tutorial that cross-checks the budget-aware failure-tolerance schedule; checkpoint integrity across dump/restore cycles; trust-region box geometry and that candidates come from the acquisition rather than a constant; lengthscale-weight normalization at target_dim up to 1200, where the naive geometric-mean form underflows; NaN and failed-evaluation ingestion; and every rejected-option path.

Docs: docs/algorithms.md entry, API reference page, README/index entries, and a runnable notebook covering the 100-D example plus checkpoint/resume.

@nikitakuklev

Copy link
Copy Markdown
Collaborator

Hi Gianluca,

Without reviewing the PR, I will say this quite plainly: we are not going to accept code that is direct Claude slop.

Obviously everyone is using agentic harnesses. I myself go through a disturbing amount of tokens every month. But to avoid sloppification, you have to fight against the absurd 'gazillion tests + defensive check everything' style of default Claude.

@gian21391

Copy link
Copy Markdown
Author

Hi Nikita, fair enough. I have pushed a commit to simplify the code. I think it is pretty readable now but I would like to do one more pass to check whether the design can be improved. The tests are extensive but not absurd anymore. I have tried to keep the coverage to 99%.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.97040% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xopt/tests/generators/bayesian/test_baxus.py 99.00% 2 Missing and 3 partials ⚠️
xopt/generators/bayesian/baxus.py 98.89% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@nikitakuklev

Copy link
Copy Markdown
Collaborator

Thanks, and no worries getting internals too polished - my biggest concern was/is docs text, because that is user-facing maybe-a-bit-verbose-opus-smell part. I'll run it through my opinionated fable/sol review loop before merge as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants