Open sumny opened 1 week ago
This PR now also includes an example (SurrogateGP.R
) how to maintain surrogate models without directly relying on mlr3
routines to further reduce overhead.
surrogate = SurrogateGP$new(archive = instance$archive)
surrogate$param_set$set_values(
covtype = "matern5_2",
optim.method = "gen",
control = list(trace = FALSE),
nugget.stability = 10^-8
)
surrogate$update()
microbenchmark::microbenchmark({surrogate$predict(data.table(x = 1))}, times = 1000L, "milliseconds")
Unit: milliseconds
expr min lq mean median uq max neval
{ surrogate$predict(data.table(x = 1)) } 1.030535 1.07618 1.116669 1.101158 1.122628 4.567874 1000
Likely this is the way to go to at least replace default_gp()
and default_rf()
in default_surrogate()
or have something like default_efficient_surrogate()
.
Todos:
SurrogateGPCollection
and SurrogateRF
and SurrogateRFCollection
default_surrogate()
type = "efficient"
or "robust"
to either use this new efficient surrogates or the older, robust ones wrapping learnersAcqFunction
s assert surrogate
and make this compatible
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 (https://github.com/mlr-org/mlr3mbo/commit/012b60c0f607abee241d8aedaf4b00d264378a74). Note, however, that this is still embarrassingly slow as can be seen when comparing to the time required to make a direct prediction withoutmlr3
overhead below, where we still observe an overhead of a factor of roughly15
.old https://github.com/mlr-org/mlr3mbo/commit/012b60c0f607abee241d8aedaf4b00d264378a74
new (this PR)
direct prediction without
mlr3
overhead: