perf: speed up surrogate predictions #173
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Acquisition function optimization wit a batch size of
1
, i.e., as used with any standard sequential numeric optimizer like DIRECT or L-BFGS-B is currently embarassingly slow due to 1)bbotk
overhead and especially 2 )mlr3
overhead (both overhead results from many assertions, checks, etc. that are triggered whenever the prediction method of the surrogate is used and evaluations are logged into the archive and the overhead of the batched evaluation mechanism ofbbotk
instances and objectives).For batch sizes larger than
1
, this is less problematic.This PR tries to at least partially improve the surrogate predict overhead arising from 2) for a single predict call by not relying on
predict_newdata
but skipping some checks and task constructions and directly usingpredict
of the learner(s) wrapped in theSurrogateLearner
orSurrogateLearnerCollection
.To further improve upon this, the only option is likely to move away from wrapping
LearnerRegr
as surrogates but implementing them directly via the baseSurrogate
class to skip all themlr3
assertions and checks.Benchmark showing a median improvement of a factor of around
1.7
compared to current main branch (012b60c).Note, however, that this is still embarrassingly slow as can be seen when comparing to the time required to make a direct prediction without
mlr3
overhead below, where we still observe an overhead of a factor of roughly15
.old 012b60c
new (this PR)
direct prediction without
mlr3
overhead: