Skip to content

Surrogates User Guide#801

Open
AdrianSosic wants to merge 3 commits into
dev/gpfrom
docs/surrogates
Open

Surrogates User Guide#801
AdrianSosic wants to merge 3 commits into
dev/gpfrom
docs/surrogates

Conversation

@AdrianSosic
Copy link
Copy Markdown
Collaborator

@AdrianSosic AdrianSosic commented May 20, 2026

DevPR, parent is #745

Updates the surrogate user guide to mention all the newly added features.

Rendered doc on fork: https://adriansosic.github.io/baybe-dev/latest/userguide/surrogates.html

@AdrianSosic AdrianSosic added this to the 0.15.0 milestone May 20, 2026
@AdrianSosic AdrianSosic self-assigned this May 20, 2026
@AdrianSosic AdrianSosic added the documentation Improvements or additions to documentation label May 20, 2026
@AdrianSosic AdrianSosic changed the base branch from main to dev/gp May 20, 2026 13:24
@AdrianSosic AdrianSosic marked this pull request as ready for review May 20, 2026 13:46
Copilot AI review requested due to automatic review settings May 20, 2026 13:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates BayBE’s surrogate documentation and accompanying code/tests to reflect newly added Gaussian process (GP) configurability and presets, including a BoTorch-aligned preset and supporting multitask/transfer-learning utilities.

Changes:

  • Expanded the Surrogates user guide with a detailed GP section (components, customization, presets, alternatives, custom surrogates).
  • Added a new BOTORCH GP preset plus supporting GPyTorch helpers and kernel-factory validation.
  • Updated tests, Streamlit demo, and warnings configuration to accommodate the new GP components/preset behavior.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_kernels.py Adjusts kernel evaluation to use dense conversion (to_dense) for loss computation.
tests/test_imports.py Ensures the new _gpytorch components module is import-tested under torch deps.
tests/test_gp.py Adds a BoTorch-preset equivalence test (single- and multi-task) and updates criterion naming.
streamlit/surrogate_models.py Extends the Streamlit demo with multitask + transfer learning controls and GP preset selection.
pytest.ini Filters a known linear_operator warning.
docs/userguide/surrogates.md Major rewrite/expansion of surrogate documentation, focusing on GP usage and presets.
docs/conf.py Adds GPyTorch intersphinx mapping for external API linking.
CHANGELOG.md Mentions the new BOTORCH GP preset in the “Added” section.
baybe/surrogates/gaussian_process/presets/core.py Introduces GaussianProcessPreset.BOTORCH.
baybe/surrogates/gaussian_process/presets/botorch.py Implements kernel/mean/likelihood/fit-criterion factories intended to mimic BoTorch defaults.
baybe/surrogates/gaussian_process/presets/__init__.py Exposes the BoTorch preset factories in the presets package exports.
baybe/surrogates/gaussian_process/core.py Renames fit-criterion factory plumbing and updates preset construction behavior.
baybe/surrogates/gaussian_process/components/kernel.py Updates factory typing and strengthens multitask kernel active-dimension validation.
baybe/surrogates/gaussian_process/components/_gpytorch.py Adds custom GPyTorch mean + multitask likelihood helpers used by the BoTorch preset.
Comments suppressed due to low confidence (1)

baybe/surrogates/gaussian_process/core.py:193

  • GaussianProcessSurrogate previously accepted criterion_or_factory (and exposed criterion_factory). Renaming the init alias to fit_criterion_or_factory is a breaking API change without a compatibility path. Consider supporting both names (with a deprecation warning for the old one) and/or documenting it under ### Breaking Changes in the changelog.
    fit_criterion_factory: FitCriterionFactoryProtocol = field(
        alias="fit_criterion_or_factory",
        factory=BayBEFitCriterionFactory,
        converter=partial(  # type: ignore[misc]
            to_component_factory, component_type=GPComponentType.CRITERION
        ),
        validator=is_callable(),
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/userguide/surrogates.md Outdated
Comment thread baybe/surrogates/gaussian_process/components/_gpytorch.py
Comment thread baybe/surrogates/gaussian_process/components/_gpytorch.py
Comment thread streamlit/surrogate_models.py
Comment thread streamlit/surrogate_models.py
Comment thread tests/test_gp.py
@AdrianSosic
Copy link
Copy Markdown
Collaborator Author

@copilot: The PR has now been rebased. Please close all thread from your current review and start a fresh one.

Copy link
Copy Markdown

Copilot AI commented May 20, 2026

@copilot: The PR has now been rebased. Please close all thread from your current review and start a fresh one.

I can’t close or reopen GitHub review threads from this coding-agent interface. No code changes were required for this request on branch docs/surrogates (current head: 80e4d9d). If you want, I can proceed with a fresh pass over the rebased diff and address any new review findings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +59 to +68
user-friendly as possible, BayBE allows you to specify each of these components in
multiple ways:
* As a BayBE object representing the component (e.g., a
{class}`~baybe.kernels.base.Kernel` object)
* As a low-level [GPyTorch](https://gpytorch.ai/) component (e.g., a
{class}`gpytorch.kernels.Kernel`)
* Or most flexibly: as a *factory* producing either of the two above.
More precisely: a callable that receives the actual recommendation context and
dynamically returns a component produced specifically for the problem at hand.

Comment on lines +194 to +195
cost becomes a major concern. For these cases, BayBE offers a range of alternative
surrogate models:
Copy link
Copy Markdown
Collaborator

@Scienfitz Scienfitz left a comment

Choose a reason for hiding this comment

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

very well written 👏


| Component | Role |
|-----------|------|
| **Kernel** | Encodes assumptions about the function's structure. |
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.

my personal preference: remove the dots int he end of sentences in such small bulletpoint-like notes
(feel free to ignore)

Suggested change
| **Kernel** | Encodes assumptions about the function's structure. |
| **Kernel** | Encodes assumptions about the function's structure |

Configuring these components in the right way is key to unlocking the full potential of
the Bayesian optimization process since they directly drive the surrogate's predictions
and thus its ability to describe your data. Therefore, we invest much effort into
making BayBE's *default GP configuration* a solid, well-tested choice for a wide range
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.

italic usage here feels strange to me

multiple ways:
* As a BayBE object representing the component (e.g., a
{class}`~baybe.kernels.base.Kernel` object)
* As a low-level [GPyTorch](https://gpytorch.ai/) component (e.g., a
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.

needs an admonition warning that this would break serializaiton

| **Kernel** | Encodes assumptions about the function's structure. |
| **Mean function** | The expected function values prior to observing any data. |
| **Likelihood** | Encodes assumptions about the observation noise. |
| **Fit criterion** | The optimization objective used to tune the model hyperparameters. |
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.

seeing a 5th component here called Observation-Standardization would make everyone feel like
Image

{class}`gpytorch.kernels.Kernel`)
* Or most flexibly: as a *factory* producing either of the two above.
More precisely: a callable that receives the actual recommendation context and
dynamically returns a component produced specifically for the problem at hand.
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.

should we link athh the relevant factory protocols so users can immediatley find the reuqired signatures?

outputscale_initial_value=2.0,
)

# Restricting a kernel to specific parameters
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.

this deserves more attention, how about a separate snippet that tells how to leave the overall kernel untouched and just change the kernel for 1 parameter?

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.

ah I realize thats prob not yet possible or at least not possible in the "nice" way of doing that directly in the parameter configuraiton... but that would be the place here to show it, right?

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

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants