Skip to content

Approximate GP implementation#416

Merged
roussel-ryan merged 12 commits intomainfrom
approximate
Apr 6, 2026
Merged

Approximate GP implementation#416
roussel-ryan merged 12 commits intomainfrom
approximate

Conversation

@roussel-ryan
Copy link
Copy Markdown
Collaborator

This pull request introduces support for approximate Gaussian Process (GP) model building to the codebase, enabling scalable modeling for larger datasets. The main changes include the implementation of an ApproximateModelConstructor using variational GP models, updates to benchmarking and documentation, and refactoring of model training logic to support both exact and variational approaches.

Approximate GP Modeling Support:

  • Added ApproximateModelConstructor class in xopt/generators/bayesian/models/approximate.py to construct scalable variational GP models for each outcome, leveraging SingleTaskVariationalGP and variational ELBO training.
  • Introduced build_variational_gp utility method in base_model.py for creating and training variational GP models.
  • Refactored model training logic in standard.py to allow flexible training of individual models with custom marginal log likelihoods, supporting both exact and variational approaches. [1] [2] [3]

Documentation and Examples:

  • Added a new notebook example, approximate.ipynb, demonstrating benchmarking and usage of approximate GP models versus standard models, including scalability and performance comparisons.
  • Updated documentation (index.md and mkdocs.yml) to reference approximate GP model building and the new example notebook. [1] [2]

Testing:

  • Added tests to verify that ApproximateModelConstructor builds models using SingleTaskVariationalGP, and updated tests for model training and error handling. [1] [2] [3]

Underlying API Enhancements:

  • Updated imports and type signatures to support variational GP models throughout the base model code. [1] [2] [3]

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 96.93878% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
xopt/generators/bayesian/models/standard.py 93.93% 0 Missing and 2 partials ⚠️
xopt/generators/bayesian/models/approximate.py 97.87% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@nikitakuklev
Copy link
Copy Markdown
Collaborator

General question - does caching hyperparameters work for approximate GPs? Seems ok since only kernel parameters should be saved, and they are valid even if inducing point is removed, but good to check.

Also a request - add parameter for inducing point count and allocator (the two available in botorch)

@roussel-ryan
Copy link
Copy Markdown
Collaborator Author

Looking at caching hyperparameters right now, will add the options you mentioned

@roussel-ryan
Copy link
Copy Markdown
Collaborator Author

Looks like there is a botorch bug with loading in a state dict for ApproximateGP models, will submit a PR for botorch when I get a chance tomorrow, for now I will disable use_cached_hyperparameters

@roussel-ryan
Copy link
Copy Markdown
Collaborator Author

Added a botorch issue meta-pytorch/botorch#3250

@roussel-ryan
Copy link
Copy Markdown
Collaborator Author

@nikitakuklev I've added the requested options, lmk what you think

Copy link
Copy Markdown
Collaborator

@nikitakuklev nikitakuklev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Also, need to add to validate_gp_constructor and all

Comment thread xopt/generators/bayesian/models/standard.py Outdated
Comment thread xopt/generators/bayesian/models/standard.py Outdated
Comment thread xopt/generators/bayesian/models/standard.py
Comment thread xopt/generators/bayesian/models/approximate.py Outdated
Comment thread xopt/generators/bayesian/models/standard.py Outdated
@roussel-ryan
Copy link
Copy Markdown
Collaborator Author

@nikitakuklev thanks for the comments, should be addressed now, lmk if there are more changes you'd like

gp_constructor.build_approximate_gp(
X=torch.empty((0, 1)),
Y=torch.empty((0, 1)),
Yvar=torch.empty((0, 1)),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yvar is not supported (this is masked test issue only)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching that

@roussel-ryan roussel-ryan merged commit a123eca into main Apr 6, 2026
19 checks passed
@roussel-ryan roussel-ryan deleted the approximate branch April 6, 2026 22:09
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