microsoft / MLOS

MLOS is a project to enable autotuning for systems.
https://microsoft.github.io/MLOS
MIT License
139 stars 66 forks source link

mlos_bench: parameter constraints #721

Open bpkroth opened 7 months ago

bpkroth commented 7 months ago

For historical reasons, there are currently TunableGroups and Tunables in mlos_bench (the benchmarking portion) which are converted to ConfigSpace HyperParameters for mlos_core (the optimizer portion). Those are further converted to the appropriate backend (e.g., ConfigSpace for SMAC, or another variant of hyperparameters for FLAML).

ConfigSpace supports Conditions and ForbiddenClauses that could used to implement parameter constraints, but we haven't exposed it yet.

We have also off and on discussed replacing TunableGroups with ConfigSpace throughout, but that may also limit some of our ability to make other changes, so we've skipped it for now.

As a workaround for the moment one thing that could be done is a user driven "validation" script that evaluates the config suggested and returns a "bad" score immediately instead of executing the test.

Short of that, each optimizer's acquisition function needs to be adjusted to support this in the search space enumeration.

Related: https://github.com/microsoft/MLOS/issues/403

bpkroth commented 7 months ago

Some things to note:

This will require some care in thinking through what the config specification looks like as well as how to handle it in either TunableGroups vs ConfigSpace conversions or else automatic enforcement in the mlos_bench.Optimizer side of things.

poojanilangekar commented 7 months ago

Hi @bpkroth,

I had a look at the Conditions and the ForbiddenCluases. However, I am unsure how to implement conditions between hyperparameters. I think the conditions work on the child hyperparameter based on the parent hyperparameter and value. On the other hand, the forbidden clauses work on a hyperparameter/value(s) pair. From what I understand, we can't directly add a condition between two hyperparameters, is this correct or am I missing something here?

Thanks, Pooja

bpkroth commented 7 months ago

I haven't thought through the full implementation in mlos_bench yet, but it likely starts with something here:

bpkroth commented 7 months ago

Regarding your observation, I think it's mostly a documentation issue. This PR in ConfigSpace seems to indicate that Forbidden clauses between Hyperparameters, not just constants, is possible.

https://github.com/automl/ConfigSpace/pull/245/files

How I might handle this is something like the following:

Since not all backend optimizers support ConfigSpace (e.g., FLAML) we might also need to implement an internal "rejection" method inside mlos_bench for this (e.g., automatically report a bad value back when a suggested value returned by the optimizer is invalid)

bpkroth commented 7 months ago

@motus any other thoughts?

bpkroth commented 7 months ago

Related: https://microsoft.github.io/FLAML/docs/Use-Cases/Tune-User-Defined-Function/#more-constraints-on-the-tuning

poojanilangekar commented 7 months ago

Thanks for getting back to me about this, I will go over the linked documentation/PRs and reach out once I have a better idea of the approach.

bpkroth commented 7 months ago

FWIW: https://github.com/automl/ConfigSpace/issues/352

eddiebergman commented 7 months ago

Hi @poojanilangekar, I am maintaining ConfigSpace and hopefully we can get towards making this possible :)