From 8e08f83861e60f232720e0f90fd53e8feffc0271 Mon Sep 17 00:00:00 2001 From: emiliencgm Date: Thu, 26 Feb 2026 16:45:06 +0100 Subject: [PATCH 01/13] Add CHENKernelFactory draft --- .../gaussian_process/presets/chen.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 baybe/surrogates/gaussian_process/presets/chen.py diff --git a/baybe/surrogates/gaussian_process/presets/chen.py b/baybe/surrogates/gaussian_process/presets/chen.py new file mode 100644 index 0000000000..12cb9ff03e --- /dev/null +++ b/baybe/surrogates/gaussian_process/presets/chen.py @@ -0,0 +1,62 @@ +"""Adaptive Prior proposed in the paper: +Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. +DOI: https://doi.org/10.26434/chemrxiv.10001986/v2""" + +from __future__ import annotations + +import gc +from typing import TYPE_CHECKING + +import numpy as np +from attrs import define +from typing_extensions import override + +from baybe.kernels.basic import MaternKernel +from baybe.kernels.composite import ScaleKernel +from baybe.parameters import TaskParameter +from baybe.priors.basic import GammaPrior +from baybe.surrogates.gaussian_process.kernel_factory import KernelFactory + +if TYPE_CHECKING: + from torch import Tensor + + from baybe.kernels.base import Kernel + from baybe.searchspace.core import SearchSpace + +import math + +@define +class CHENKernelFactory(KernelFactory): + """ Surrogate model with an adaptive hyperprior proposed in the paper: + Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. + DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 + """ + + @override + def __call__( + self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor + ) -> Kernel: + effective_dims = train_x.shape[-1] - len( + [p for p in searchspace.parameters if isinstance(p, TaskParameter)] + ) + + x = math.sqrt(effective_dims) + l_mean = 0.4 * x + 4.0 + + lengthscale_prior = GammaPrior(2.0*l_mean, 2.0) + lengthscale_initial_value = l_mean + outputscale_prior = GammaPrior(1.0*l_mean, 1.0) + outputscale_initial_value = l_mean + + return ScaleKernel( + MaternKernel( + nu=2.5, + lengthscale_prior=lengthscale_prior, + lengthscale_initial_value=lengthscale_initial_value, + ), + outputscale_prior=outputscale_prior, + outputscale_initial_value=outputscale_initial_value, + ) + +# Collect leftover original slotted classes processed by `attrs.define` +gc.collect() From fe1e6998c58eb273c926cd6d58f3da1a8450a79e Mon Sep 17 00:00:00 2001 From: maxfleck Date: Thu, 26 Feb 2026 21:33:36 +0100 Subject: [PATCH 02/13] Import CHENKernelFactory in __init__.py --- baybe/surrogates/gaussian_process/presets/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/baybe/surrogates/gaussian_process/presets/__init__.py b/baybe/surrogates/gaussian_process/presets/__init__.py index deb7de9e64..434fbf560f 100644 --- a/baybe/surrogates/gaussian_process/presets/__init__.py +++ b/baybe/surrogates/gaussian_process/presets/__init__.py @@ -7,6 +7,9 @@ BayBEMeanFactory, ) +# Chen preset +from baybe.surrogates.gaussian_process.presets.chen import CHENKernelFactory + # Core from baybe.surrogates.gaussian_process.presets.core import GaussianProcessPreset @@ -31,6 +34,8 @@ "BayBEKernelFactory", "BayBELikelihoodFactory", "BayBEMeanFactory", + # Chen preset + "CHENKernelFactory", # EDBO preset "EDBOKernelFactory", "EDBOLikelihoodFactory", From b2c2361188cad3fe44e35b650b8413f4bad5ec1e Mon Sep 17 00:00:00 2001 From: tstuyver Date: Fri, 27 Feb 2026 00:17:44 +0100 Subject: [PATCH 03/13] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6270ff77c0..f639c03a8a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -39,4 +39,10 @@ - Kathrin Skubch (Merck KGaA, Darmstadt, Germany):\ Transfer learning regression benchmarks infrastructure - Myra Zmarsly (Merck Life Science KGaA, Darmstadt, Germany):\ - Identification of non-dominated parameter configurations \ No newline at end of file + Identification of non-dominated parameter configurations +- Thijs Stuyver (PSL University, Paris, France):\ + Adaptive hyper-prior tailored for reaction yield optimization tasks +- Maximilian Fleck (PSL University, Paris, France):\ + Adaptive hyper-prior tailored for reaction yield optimization tasks +- Guanming Chen (PSL University, Paris, France):\ + Adaptive hyper-prior tailored for reaction yield optimization tasks From 4e81b4633dc9d024c0aa2aea6145d017fe9d4fb8 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Thu, 16 Apr 2026 10:33:06 +0200 Subject: [PATCH 04/13] Apply ruff formatting --- .../gaussian_process/presets/chen.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/baybe/surrogates/gaussian_process/presets/chen.py b/baybe/surrogates/gaussian_process/presets/chen.py index 12cb9ff03e..069fbc6616 100644 --- a/baybe/surrogates/gaussian_process/presets/chen.py +++ b/baybe/surrogates/gaussian_process/presets/chen.py @@ -1,13 +1,13 @@ -"""Adaptive Prior proposed in the paper: +"""Adaptive Prior proposed in the paper: Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. -DOI: https://doi.org/10.26434/chemrxiv.10001986/v2""" +DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 +""" # noqa from __future__ import annotations import gc from typing import TYPE_CHECKING -import numpy as np from attrs import define from typing_extensions import override @@ -25,12 +25,13 @@ import math + @define class CHENKernelFactory(KernelFactory): - """ Surrogate model with an adaptive hyperprior proposed in the paper: - Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. - DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 - """ + """Surrogate model with an adaptive hyperprior proposed in the paper: + Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. + DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 + """ # noqa @override def __call__( @@ -42,10 +43,10 @@ def __call__( x = math.sqrt(effective_dims) l_mean = 0.4 * x + 4.0 - - lengthscale_prior = GammaPrior(2.0*l_mean, 2.0) + + lengthscale_prior = GammaPrior(2.0 * l_mean, 2.0) lengthscale_initial_value = l_mean - outputscale_prior = GammaPrior(1.0*l_mean, 1.0) + outputscale_prior = GammaPrior(1.0 * l_mean, 1.0) outputscale_initial_value = l_mean return ScaleKernel( @@ -58,5 +59,6 @@ def __call__( outputscale_initial_value=outputscale_initial_value, ) + # Collect leftover original slotted classes processed by `attrs.define` gc.collect() From 1ad28aef6f9d8a82930b89b176845227a023d0a3 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Thu, 16 Apr 2026 10:46:17 +0200 Subject: [PATCH 05/13] Finalize draft --- .../gaussian_process/presets/chen.py | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/baybe/surrogates/gaussian_process/presets/chen.py b/baybe/surrogates/gaussian_process/presets/chen.py index 069fbc6616..bace77467b 100644 --- a/baybe/surrogates/gaussian_process/presets/chen.py +++ b/baybe/surrogates/gaussian_process/presets/chen.py @@ -6,16 +6,28 @@ from __future__ import annotations import gc -from typing import TYPE_CHECKING +import math +from typing import TYPE_CHECKING, ClassVar -from attrs import define +from attrs import define, field from typing_extensions import override from baybe.kernels.basic import MaternKernel from baybe.kernels.composite import ScaleKernel -from baybe.parameters import TaskParameter +from baybe.parameters.categorical import TaskParameter +from baybe.parameters.selectors import ( + ParameterSelectorProtocol, + TypeSelector, + to_parameter_selector, +) from baybe.priors.basic import GammaPrior -from baybe.surrogates.gaussian_process.kernel_factory import KernelFactory +from baybe.surrogates.gaussian_process.components.kernel import ( + _PureKernelFactory, +) +from baybe.surrogates.gaussian_process.presets.baybe import ( + BayBELikelihoodFactory, + BayBEMeanFactory, +) if TYPE_CHECKING: from torch import Tensor @@ -23,37 +35,39 @@ from baybe.kernels.base import Kernel from baybe.searchspace.core import SearchSpace -import math - @define -class CHENKernelFactory(KernelFactory): +class CHENKernelFactory(_PureKernelFactory): """Surrogate model with an adaptive hyperprior proposed in the paper: Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 """ # noqa + _uses_parameter_names: ClassVar[bool] = True + # See base class. + + parameter_selector: ParameterSelectorProtocol | None = field( + factory=lambda: TypeSelector([TaskParameter], exclude=True), + converter=to_parameter_selector, + ) + # TODO: Reuse base attribute (https://github.com/python-attrs/attrs/pull/1429) + @override - def __call__( + def _make( self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor ) -> Kernel: - effective_dims = train_x.shape[-1] - len( - [p for p in searchspace.parameters if isinstance(p, TaskParameter)] - ) - - x = math.sqrt(effective_dims) - l_mean = 0.4 * x + 4.0 - - lengthscale_prior = GammaPrior(2.0 * l_mean, 2.0) - lengthscale_initial_value = l_mean - outputscale_prior = GammaPrior(1.0 * l_mean, 1.0) - outputscale_initial_value = l_mean + lengthscale = 0.4 * math.sqrt(train_x.shape[-1]) + 4.0 + lengthscale_prior = GammaPrior(2.0 * lengthscale, 2.0) + lengthscale_initial_value = lengthscale + outputscale_prior = GammaPrior(1.0 * lengthscale, 1.0) + outputscale_initial_value = lengthscale return ScaleKernel( MaternKernel( nu=2.5, lengthscale_prior=lengthscale_prior, lengthscale_initial_value=lengthscale_initial_value, + parameter_names=self.get_parameter_names(searchspace), ), outputscale_prior=outputscale_prior, outputscale_initial_value=outputscale_initial_value, @@ -62,3 +76,8 @@ def __call__( # Collect leftover original slotted classes processed by `attrs.define` gc.collect() + +# Aliases for generic preset imports +PresetKernelFactory = CHENKernelFactory +PresetMeanFactory = BayBEMeanFactory +PresetLikelihoodFactory = BayBELikelihoodFactory From 6eb566e9fa1f9f7009067a181ee28e921ce1b9d6 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Thu, 16 Apr 2026 11:36:17 +0200 Subject: [PATCH 06/13] Add proper paper references --- .../gaussian_process/presets/chen.py | 10 ++-------- .../gaussian_process/presets/edbo.py | 14 +++++--------- .../gaussian_process/presets/edbo_smoothed.py | 10 +++++----- docs/index.md | 1 + docs/misc/references.md | 4 ++++ docs/references.bib | 19 +++++++++++++++++++ docs/userguide/transfer_learning.md | 3 --- 7 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 docs/misc/references.md diff --git a/baybe/surrogates/gaussian_process/presets/chen.py b/baybe/surrogates/gaussian_process/presets/chen.py index bace77467b..05f9ccc483 100644 --- a/baybe/surrogates/gaussian_process/presets/chen.py +++ b/baybe/surrogates/gaussian_process/presets/chen.py @@ -1,7 +1,4 @@ -"""Adaptive Prior proposed in the paper: -Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. -DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 -""" # noqa +"""Preset for adaptive kernel hyperpriors proposed by :cite:p:`Chen2026`.""" from __future__ import annotations @@ -38,10 +35,7 @@ @define class CHENKernelFactory(_PureKernelFactory): - """Surrogate model with an adaptive hyperprior proposed in the paper: - Guanming Chen, Maximilian Fleck, Thijs Stuyver. Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors. ChemRxiv. 09 February 2026. - DOI: https://doi.org/10.26434/chemrxiv.10001986/v2 - """ # noqa + """A factory providing adaptive hyperprior kernels as proposed by :cite:p:`Chen2026`.""" # noqa: E501 _uses_parameter_names: ClassVar[bool] = True # See base class. diff --git a/baybe/surrogates/gaussian_process/presets/edbo.py b/baybe/surrogates/gaussian_process/presets/edbo.py index 6db0af8a30..167407517b 100644 --- a/baybe/surrogates/gaussian_process/presets/edbo.py +++ b/baybe/surrogates/gaussian_process/presets/edbo.py @@ -1,4 +1,4 @@ -"""EDBO preset for Gaussian process surrogates.""" +"""EDBO preset :cite:p:`Shields2021`.""" from __future__ import annotations @@ -58,11 +58,9 @@ def _contains_encoding( @define class EDBOKernelFactory(_PureKernelFactory): - """A factory providing EDBO kernels. + """A factory providing EDBO kernels, as proposed by :cite:p:`Shields2021`. - References: - * https://github.com/b-shields/edbo/blob/master/edbo/bro.py#L664 - * https://doi.org/10.1038/s41586-021-03213-y + Github repository: https://github.com/b-shields/edbo """ _uses_parameter_names: ClassVar[bool] = True @@ -130,11 +128,9 @@ def _make( @define class EDBOLikelihoodFactory(LikelihoodFactoryProtocol): - """A factory providing EDBO likelihoods. + """A factory providing EDBO likelihoods, as proposed by :cite:p:`Shields2021`. - References: - * https://github.com/b-shields/edbo/blob/master/edbo/bro.py#L664 - * https://doi.org/10.1038/s41586-021-03213-y + Github repository: https://github.com/b-shields/edbo """ @override diff --git a/baybe/surrogates/gaussian_process/presets/edbo_smoothed.py b/baybe/surrogates/gaussian_process/presets/edbo_smoothed.py index 1c2718adb6..904f711f31 100644 --- a/baybe/surrogates/gaussian_process/presets/edbo_smoothed.py +++ b/baybe/surrogates/gaussian_process/presets/edbo_smoothed.py @@ -1,4 +1,4 @@ -"""Smoothed EDBO preset for Gaussian process surrogates.""" +"""Smoothed EDBO preset (adapted from :cite:p:`Shields2021`).""" from __future__ import annotations @@ -40,12 +40,12 @@ @define class SmoothedEDBOKernelFactory(_PureKernelFactory): - """A factory providing smoothed versions of EDBO kernels. + """A factory providing smoothed versions of EDBO kernels (adapted from :cite:p:`Shields2021`). Takes the low and high dimensional limits of :class:`baybe.surrogates.gaussian_process.presets.edbo.EDBOKernelFactory` and interpolates the prior moments linearly in between. - """ + """ # noqa: E501 _uses_parameter_names: ClassVar[bool] = True # See base class. @@ -94,12 +94,12 @@ def _make( @define class SmoothedEDBOLikelihoodFactory(LikelihoodFactoryProtocol): - """A factory providing smoothed versions of EDBO likelihoods. + """A factory providing smoothed versions of EDBO likelihoods (adapted from :cite:p:`Shields2021`). Takes the low and high dimensional limits of :class:`baybe.surrogates.gaussian_process.presets.edbo.EDBOLikelihoodFactory` and interpolates the prior moments linearly in between. - """ + """ # noqa: E501 @override def __call__( diff --git a/docs/index.md b/docs/index.md index 3f8ba25cd9..31d138a369 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,6 +40,7 @@ Contribute Contributors Known Issues Changelog +References Github License ``` diff --git a/docs/misc/references.md b/docs/misc/references.md new file mode 100644 index 0000000000..d977a9bd5b --- /dev/null +++ b/docs/misc/references.md @@ -0,0 +1,4 @@ +# References + +```{bibliography} +``` diff --git a/docs/references.bib b/docs/references.bib index 307529d299..4d159cb686 100644 --- a/docs/references.bib +++ b/docs/references.bib @@ -8,3 +8,22 @@ @inproceedings{NIPS2007_66368270 volume = {20}, year = {2007} } + +@article{Chen2026, + author = {Chen, Guanming and Fleck, Maximilian and Stuyver, Thijs}, + title = {Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors}, + journal = {ChemRxiv}, + year = {2026}, + doi = {10.26434/chemrxiv.10001986/v2} +} + +@article{Shields2021, + author = {Shields, Benjamin J. and Stevens, Jason and Li, Jun and Parasram, Marvin and Damani, Farhan and Alvarado, Jesus I. Martinez and Janey, Jacob M. and Adams, Ryan P. and Doyle, Abigail G.}, + title = {Bayesian reaction optimization as a tool for chemical synthesis}, + journal = {Nature}, + volume = {590}, + number = {7844}, + pages = {89--96}, + year = {2021}, + doi = {10.1038/s41586-021-03213-y} +} diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index 6f509df31b..3273e20853 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -185,7 +185,4 @@ on the optimization: :class: only-dark ``` -```{bibliography} -``` - [`TaskParameter`]: baybe.parameters.categorical.TaskParameter \ No newline at end of file From 55c38521f04d12bfa31065e235e03eae151e452c Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Thu, 16 Apr 2026 13:28:24 +0200 Subject: [PATCH 07/13] Update GaussianProcessPreset enum --- baybe/surrogates/gaussian_process/presets/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/baybe/surrogates/gaussian_process/presets/core.py b/baybe/surrogates/gaussian_process/presets/core.py index ad77df0b4d..5347cf85e5 100644 --- a/baybe/surrogates/gaussian_process/presets/core.py +++ b/baybe/surrogates/gaussian_process/presets/core.py @@ -11,8 +11,11 @@ class GaussianProcessPreset(Enum): BAYBE = "BAYBE" """The default BayBE settings of the Gaussian process surrogate class.""" + CHEN = "CHEN" + """The adaptive kernel hyperprior settings proposed by :cite:p:`Chen2026`.""" + EDBO = "EDBO" - """The EDBO settings.""" + """The EDBO settings proposed by :cite:p:`Shields2021`.""" EDBO_SMOOTHED = "EDBO_SMOOTHED" - """A smoothed version of the EDBO settings.""" + """A smoothed version of the EDBO settings (adapted from :cite:p:`Shields2021`).""" From c43d73bb8773b1410d5351fd4e9f7f0cb15b6f2a Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Thu, 16 Apr 2026 13:29:28 +0200 Subject: [PATCH 08/13] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7715778a3..de3165f616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for GPyTorch objects (kernels, means, likelihood) as Gaussian process components, enabling full low-level customization - Factories for all Gaussian process components -- `EDBO` and `EDBO_SMOOTHED` presets for `GaussianProcessSurrogate` +- `CHEN`, `EDBO` and `EDBO_SMOOTHED` presets for `GaussianProcessSurrogate` - `TypeSelector` and `NameSelector` classes for parameter selection in kernel factories - `parameter_names` attribute to basic kernels for controlling the considered parameters - `ParameterKind` flag enum for classifying parameters by their role and automatic From ff10272bfd4b924e4ddb2f8468df21db7b645d44 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Fri, 24 Apr 2026 10:51:31 +0200 Subject: [PATCH 09/13] Apply minor cosmetics --- CONTRIBUTORS.md | 2 +- baybe/surrogates/gaussian_process/presets/edbo.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f639c03a8a..ef31b177b8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -40,7 +40,7 @@ Transfer learning regression benchmarks infrastructure - Myra Zmarsly (Merck Life Science KGaA, Darmstadt, Germany):\ Identification of non-dominated parameter configurations -- Thijs Stuyver (PSL University, Paris, France):\ +- Thijs Stuyver (PSL University, Paris, France):\ Adaptive hyper-prior tailored for reaction yield optimization tasks - Maximilian Fleck (PSL University, Paris, France):\ Adaptive hyper-prior tailored for reaction yield optimization tasks diff --git a/baybe/surrogates/gaussian_process/presets/edbo.py b/baybe/surrogates/gaussian_process/presets/edbo.py index 167407517b..098c6af14e 100644 --- a/baybe/surrogates/gaussian_process/presets/edbo.py +++ b/baybe/surrogates/gaussian_process/presets/edbo.py @@ -60,7 +60,7 @@ def _contains_encoding( class EDBOKernelFactory(_PureKernelFactory): """A factory providing EDBO kernels, as proposed by :cite:p:`Shields2021`. - Github repository: https://github.com/b-shields/edbo + GitHub repository: https://github.com/b-shields/edbo """ _uses_parameter_names: ClassVar[bool] = True @@ -130,7 +130,7 @@ def _make( class EDBOLikelihoodFactory(LikelihoodFactoryProtocol): """A factory providing EDBO likelihoods, as proposed by :cite:p:`Shields2021`. - Github repository: https://github.com/b-shields/edbo + GitHub repository: https://github.com/b-shields/edbo """ @override From 344263a8c81e01bdd8de8661f5e81064ed184ce4 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Mon, 27 Apr 2026 10:57:36 +0200 Subject: [PATCH 10/13] Hardcode mean and likelihood for CHEN preset --- .../gaussian_process/components/likelihood.py | 18 ++++++++++++++++++ .../gaussian_process/presets/chen.py | 10 +++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/baybe/surrogates/gaussian_process/components/likelihood.py b/baybe/surrogates/gaussian_process/components/likelihood.py index 2f8007ed59..c94982a469 100644 --- a/baybe/surrogates/gaussian_process/components/likelihood.py +++ b/baybe/surrogates/gaussian_process/components/likelihood.py @@ -4,6 +4,10 @@ from typing import TYPE_CHECKING, Any +from attrs import define +from typing_extensions import override + +from baybe.searchspace.core import SearchSpace from baybe.surrogates.gaussian_process.components.generic import ( GPComponentFactoryProtocol, PlainGPComponentFactory, @@ -11,6 +15,7 @@ if TYPE_CHECKING: from gpytorch.likelihoods import Likelihood as GPyTorchLikelihood + from torch import Tensor LikelihoodFactoryProtocol = GPComponentFactoryProtocol[GPyTorchLikelihood] PlainLikelihoodFactory = PlainGPComponentFactory[GPyTorchLikelihood] @@ -18,3 +23,16 @@ # At runtime, we avoid loading GPyTorch eagerly for performance reasons LikelihoodFactoryProtocol = GPComponentFactoryProtocol[Any] PlainLikelihoodFactory = PlainGPComponentFactory[Any] + + +@define +class LazyGaussianLikelihoodFactory(LikelihoodFactoryProtocol): + """A factory providing Gaussian likelihoods using lazy loading.""" + + @override + def __call__( + self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor + ) -> GPyTorchLikelihood: + from gpytorch.likelihoods import GaussianLikelihood + + return GaussianLikelihood() diff --git a/baybe/surrogates/gaussian_process/presets/chen.py b/baybe/surrogates/gaussian_process/presets/chen.py index 05f9ccc483..5e90c4aa5c 100644 --- a/baybe/surrogates/gaussian_process/presets/chen.py +++ b/baybe/surrogates/gaussian_process/presets/chen.py @@ -21,10 +21,10 @@ from baybe.surrogates.gaussian_process.components.kernel import ( _PureKernelFactory, ) -from baybe.surrogates.gaussian_process.presets.baybe import ( - BayBELikelihoodFactory, - BayBEMeanFactory, +from baybe.surrogates.gaussian_process.components.likelihood import ( + LazyGaussianLikelihoodFactory, ) +from baybe.surrogates.gaussian_process.components.mean import LazyConstantMeanFactory if TYPE_CHECKING: from torch import Tensor @@ -73,5 +73,5 @@ def _make( # Aliases for generic preset imports PresetKernelFactory = CHENKernelFactory -PresetMeanFactory = BayBEMeanFactory -PresetLikelihoodFactory = BayBELikelihoodFactory +PresetMeanFactory = LazyConstantMeanFactory +PresetLikelihoodFactory = LazyGaussianLikelihoodFactory From 46d3749298b7f7703586e6d0c020ad588346a906 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Mon, 27 Apr 2026 11:06:35 +0200 Subject: [PATCH 11/13] Add permalink to EDBO prior settings --- baybe/surrogates/gaussian_process/presets/edbo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/baybe/surrogates/gaussian_process/presets/edbo.py b/baybe/surrogates/gaussian_process/presets/edbo.py index 098c6af14e..539e2ef72c 100644 --- a/baybe/surrogates/gaussian_process/presets/edbo.py +++ b/baybe/surrogates/gaussian_process/presets/edbo.py @@ -61,6 +61,7 @@ class EDBOKernelFactory(_PureKernelFactory): """A factory providing EDBO kernels, as proposed by :cite:p:`Shields2021`. GitHub repository: https://github.com/b-shields/edbo + Prior settings: https://github.com/b-shields/edbo/blob/9b41eac3f6d9e520547702fd5b0c7ef6441625a4/edbo/bro.py#L658 """ _uses_parameter_names: ClassVar[bool] = True @@ -131,6 +132,7 @@ class EDBOLikelihoodFactory(LikelihoodFactoryProtocol): """A factory providing EDBO likelihoods, as proposed by :cite:p:`Shields2021`. GitHub repository: https://github.com/b-shields/edbo + Prior settings: https://github.com/b-shields/edbo/blob/9b41eac3f6d9e520547702fd5b0c7ef6441625a4/edbo/bro.py#L658 """ @override From f35c77bdb0638a87f73898316a173fbc941afe55 Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Mon, 27 Apr 2026 12:02:45 +0200 Subject: [PATCH 12/13] Ignore chemrxiv link for linkcheck Causing some FORBIDDEN issues: https://github.com/sphinx-doc/sphinx/issues/5051 --- docs/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 11ff636a77..eb6a718c0f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -154,7 +154,10 @@ ] # Ignore the following links when checking inks for viability -linkcheck_ignore = [r"https://github.com/b-shields/edbo/blob/master/edbo/bro.py*"] +linkcheck_ignore = [ + r"https://github.com/b-shields/edbo/blob/master/edbo/bro.py*", + r"https://doi.org/10.26434/chemrxiv.10001986/v2", +] # Ignore the warnings that are given by autosectionlabel From c16a6aac0ca90fc8b1bf9bfb06cd32a2da43955b Mon Sep 17 00:00:00 2001 From: AdrianSosic Date: Mon, 27 Apr 2026 13:51:26 +0200 Subject: [PATCH 13/13] Update linkcheck ignore for EDBO --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index eb6a718c0f..54d318e7ce 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -155,7 +155,7 @@ # Ignore the following links when checking inks for viability linkcheck_ignore = [ - r"https://github.com/b-shields/edbo/blob/master/edbo/bro.py*", + r"https://github.com/b-shields/edbo/blob*", r"https://doi.org/10.26434/chemrxiv.10001986/v2", ]