Surrogates User Guide#801
Conversation
f2e1448 to
eb988ba
Compare
There was a problem hiding this comment.
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
BOTORCHGP 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
GaussianProcessSurrogatepreviously acceptedcriterion_or_factory(and exposedcriterion_factory). Renaming the init alias tofit_criterion_or_factoryis 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 Changesin 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.
eb988ba to
80e4d9d
Compare
|
@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 |
| 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. | ||
|
|
| cost becomes a major concern. For these cases, BayBE offers a range of alternative | ||
| surrogate models: |
|
|
||
| | Component | Role | | ||
| |-----------|------| | ||
| | **Kernel** | Encodes assumptions about the function's structure. | |
There was a problem hiding this comment.
my personal preference: remove the dots int he end of sentences in such small bulletpoint-like notes
(feel free to ignore)
| | **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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. | |
| {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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?

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