Skip to content

Multi-fidelity surrogate models - #721

Open
jpenn2023 wants to merge 125 commits into
dev/mfbofrom
dev-mfbo-main-surrogate-models
Open

Multi-fidelity surrogate models#721
jpenn2023 wants to merge 125 commits into
dev/mfbofrom
dev-mfbo-main-surrogate-models

Conversation

@jpenn2023

Copy link
Copy Markdown
Collaborator

Adding multi-fidelity properties for the SearchSpace class and multi-fidelity Gaussian process classes with the required fidelity kernels.

Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
@AdrianSosic
AdrianSosic force-pushed the dev-mfbo-main-surrogate-models branch from ccac1f8 to 178772a Compare February 4, 2026 16:58
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated

@AVHopp AVHopp left a comment

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.

Some comments on everything but the multi_fidelity.py file, as I guess that we will discuss this today in a bit more detail.

Comment thread baybe/kernels/basic.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/presets/default.py Outdated
Comment thread baybe/surrogates/gaussian_process/presets/fidelity.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
@jpenn2023
jpenn2023 force-pushed the dev-mfbo-main-surrogate-models branch from 2e64082 to 8e8547b Compare February 27, 2026 07:29
@AdrianSosic

Copy link
Copy Markdown
Collaborator

Hey @jpenn2023, I just wanted to have a look at your PR but then noticed that something went wrong with your rebase. I know you asked me about the weird diff shown on Github (and yes, that is generally still a problem), but it turns out that your diff is wrong for a different reason – namely because you somehow rebased your commits together with an entire bunch of other commits 😬 Can you quickly fix it and ping me once ready for review?

@jpenn2023
jpenn2023 force-pushed the dev-mfbo-main-surrogate-models branch from d96cf75 to 2c513b0 Compare March 6, 2026 12:25
@AdrianSosic
AdrianSosic force-pushed the dev-mfbo-main-surrogate-models branch from 2c513b0 to 754d5da Compare March 6, 2026 13:48
@AdrianSosic
AdrianSosic changed the base branch from dev/mfbo to main March 6, 2026 13:54
@AdrianSosic
AdrianSosic changed the base branch from main to dev/mfbo March 6, 2026 13:55
@AdrianSosic
AdrianSosic force-pushed the dev-mfbo-main-surrogate-models branch from 754d5da to 563b86a Compare March 6, 2026 17:21
@AdrianSosic
AdrianSosic changed the base branch from dev/mfbo to main March 6, 2026 17:22
@AdrianSosic
AdrianSosic changed the base branch from main to dev/mfbo March 6, 2026 17:22
@AdrianSosic
AdrianSosic force-pushed the dev-mfbo-main-surrogate-models branch from 563b86a to 88db97f Compare March 6, 2026 17:26
@AdrianSosic

Copy link
Copy Markdown
Collaborator

Hey @jpenn2023, have a look, this should now give you a clean picture of your PR content, right?

@jpenn2023

Copy link
Copy Markdown
Collaborator Author

Hey @jpenn2023, have a look, this should now give you a clean picture of your PR content, right?

Hi @AdrianSosic. Yes, this view looks right to me.

@Scienfitz Scienfitz left a comment

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 biggest question is why the concepts of TL and MF are now deedply intertwined by using a single searchspace property for combining them isntead of two properties characterizing the searchspaces task / fidelity character

Comment thread baybe/searchspace/core.py
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/surrogates/base.py Outdated
Comment thread baybe/surrogates/gaussian_process/core.py
Comment thread baybe/recommenders/pure/bayesian/base.py Outdated

@AVHopp AVHopp left a comment

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.

Some more thoughts from my end

Comment thread baybe/searchspace/core.py
Comment thread baybe/searchspace/core.py
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
@AVHopp

AVHopp commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

@jpenn2023 it seems like the continuous search space example is currently failing which is why the doc building does not run (just FYI as reading the doc building error logs can be a bit annoying)

@AVHopp AVHopp left a comment

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.

I've found several comments that were marked as resolved without them actually being addressed. Please ONLY resolve comments when the changes are actually visible and have been pushed. Also, it would be great if you could give context when resolving a comment. For example, I asked an explicit question at one point and the comment was just being resolved without providing an answer and without changing the corresponding code.

EDIT: Whoopsie, this was on me. Ignore :)

Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread baybe/searchspace/core.py
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/surrogates/gaussian_process/multi_fidelity.py Outdated
@AVHopp
AVHopp marked this pull request as draft August 6, 2026 08:36
@Scienfitz Scienfitz modified the milestones: 0.16.0, 0.17.0 Aug 6, 2026
@AVHopp
AVHopp marked this pull request as ready for review August 6, 2026 14:47

@Scienfitz Scienfitz left a comment

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.

just threadwork left

@AdrianSosic AdrianSosic left a comment

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.

Hey @AVHopp , here some first input. I'll now look at the kernel constructions in particular, as well as the tests

Comment thread baybe/searchspace/core.py
Comment thread baybe/searchspace/core.py Outdated
Comment thread baybe/searchspace/core.py Outdated
return len(task_param.values)

@property
def n_fidelities(self) -> int:

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.

I know you're just following the pattern of the task parameter, but I think we need to make a decision now. Much of the task stuff grew over time, but here we're now deliberately adding new functionality without having really decided how we handle the "multiple task/fidelity" case. Half of the properties/methods are private because they explicitly say private since not yet decided how to handle multiple params but then the other half is public, effectively ignoring the problem. So one of two things will happen:

  • We decide that support for multi params is coming soon --> much deprecation work, i.e. all should be private
  • We decide that support is far down the road --> why making it private then

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.

Let's discuss this point in a meeting.

@AVHopp AVHopp Aug 14, 2026

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.

Agreed to have everything related to the search space and its properties introduced here private.

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.

Changed this in 3d4bd5d. Please comment if something else/additional should be private, resolve if happy.

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.

the analogous task properties also need to be privatized, the code is otherwise in an inconsistent state

I think this can be done without deprecation as super unimportant and super unimpactful "breaking" change, but if you disagree then do it with a deprecation

Comment thread baybe/searchspace/validation.py Outdated
NotImplementedError: If more than one
:class:`baybe.parameters.categorical.TaskParameter` is requested.
NotImplementedError: If more than one fidelity parameter is present.
NotImplementedError: If task and fidelity parameters are combined.

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.

I think "combined" is not a good word because it sounds like you are producing one new parameter type from the two others. Same in error message

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.

Changed in 840dfff, please resolve if this wording is better or provide an alternative.

Comment thread baybe/surrogates/base.py Outdated
Comment on lines +282 to +289
if not any(
i not in (searchspace.task_idx, searchspace.fidelity_idx)
for i in range(len(searchspace.comp_rep_columns))
):
raise IncompatibleSurrogateError(
f"'{self.__class__.__name__}' requires at least one "
f"non-task/non-fidelity 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.

This is very cumbersome. Also, I'd appreciate if you could avoid access to low-level attributes like exp_rep and comp_rep since otherwise I'll have to recode this after the candidates PR 😬

In fact, no need to access such low level stuff. Simply check e.g. that there is at least one REGULAR parameter in the search space. And then also turn the message around, i.e. instead of listing non-regular types (which will break once the list get's longer), just mention that we need at least one regular 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.

Check has been simplified in 383e86a. I also took another look at potential changes that touch comp_rep or expr_rep, and added two comments in places where we'll need to adjust after the merge of candidates: a492139 Please resolve if this is fine.

Comment thread baybe/surrogates/gaussian_process/core.py Outdated
):
raise IncompatibleSurrogateError(
f"'{self.__class__.__name__}' does not support custom components "
f"for numerical multi-fidelity search spaces, which are delegated "

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.

I think the "which" makes no sense. What should it refer to? The costum components? No --> they are not compatible. The search space? No --> botorch doesn't use our search spaces.

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.

Changed the formulation in d28b7e5. Please resolve if you are satisfied with the text now.

Comment thread baybe/surrogates/gaussian_process/core.py Outdated
Comment thread CHANGELOG.md Outdated

@AdrianSosic AdrianSosic left a comment

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.

I'll review the kernel tests once we've aligned on the decorator stuff

Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment on lines +160 to +161
searchspace = SearchSpace.from_product(parameters)
measurements = create_fake_input(

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.

why create these objrects inside the test if we have them already defined outside (keep test logic minimal)

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.

Can you elaborate on this? The corresponding search space objects which do not use any REGULAR parameters are not yet defined outside of the function, but the parameters are (with the excepction of the task parameter). Does it really make sense to have those search spaces and measurements all defined outside of the test on the module level or am I misunderstanding you?

Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
Comment thread tests/test_fidelity.py Outdated
AVHopp and others added 5 commits August 14, 2026 09:41
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
@AVHopp
AVHopp force-pushed the dev-mfbo-main-surrogate-models branch from 65e2110 to 567a113 Compare August 14, 2026 08:10
Comment thread CHANGELOG.md

### Deprecations
- The `task_kernel_or_factory` argument of `ICMKernelFactory` has been renamed to
`index_kernel_or_factory` since it now also carries fidelity indices. The old name is

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.

The last sentence The old... is obsolete as this is always implied when something is listed under Deprecations



def _enable_transfer_learning(
def _enable_index_kernel(

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.

I'm fine with this as it closes my original question, leaving it for you two to close this thread

"""The factory for the base kernel operating on numerical input features."""

task_kernel_factory: KernelFactoryProtocol = field(
task_kernel_factory: KernelFactoryProtocol | None = field(

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.

I'm not a huge fan of the new name as it expresses the architecture and not what is its used for (which is a more reasonable naming approach if there are choices involved)

eg we could have kernels intended for task/fidelity that are not index. but give that this is currently not the case and I have no better name suggestion feel free to resolve

Comment thread baybe/searchspace/core.py Outdated
return len(task_param.values)

@property
def n_fidelities(self) -> int:

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.

the analogous task properties also need to be privatized, the code is otherwise in an inconsistent state

I think this can be done without deprecation as super unimportant and super unimpactful "breaking" change, but if you disagree then do it with a deprecation

Comment thread baybe/surrogates/base.py

return result

def _validate_fit_context(

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.

personally I thought this name made sense

validate_X_context = gets everyhtign as input that X sees (or X itself as input)

Or is Adrian suggesting to make this method use _ModelContext (and rename the method accordingly)? Could also be an option if its 100% equivalent

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

Labels

dev new feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants