diff --git a/mlos_bench/mlos_bench/config/experiments/README.md b/mlos_bench/mlos_bench/config/experiments/README.md index ae1094739c0..b90fd022717 100644 --- a/mlos_bench/mlos_bench/config/experiments/README.md +++ b/mlos_bench/mlos_bench/config/experiments/README.md @@ -53,8 +53,9 @@ it looks like this: "redis": [] }, - "optimization_target": "score", - "optimization_direction": "min" + "optimization_targets": { + "score": "min" + } } ``` @@ -78,12 +79,13 @@ It has a mixture of parameters from different components of the framework. for e At runtime, these values will be pushed down to the `AzureVMService` configuration, e.g., [`service-linux-vm-ops.jsonc`](../services/remote/azure/service-linux-vm-ops.jsonc). -Likewise, parameters +Likewise, the parameter ```jsonc { - "optimization_target": "score", - "optimization_direction": "min" + "optimization_targets": { + "score": "min" + } } ``` diff --git a/mlos_bench/mlos_bench/config/experiments/experiment_RedisBench.jsonc b/mlos_bench/mlos_bench/config/experiments/experiment_RedisBench.jsonc index e33beab7b4d..3da9e89e1cf 100644 --- a/mlos_bench/mlos_bench/config/experiments/experiment_RedisBench.jsonc +++ b/mlos_bench/mlos_bench/config/experiments/experiment_RedisBench.jsonc @@ -41,6 +41,5 @@ "redis": [] }, - "optimization_target": "score", - "optimization_direction": "min" + "optimization_targets": {"score": "min"} } diff --git a/mlos_bench/mlos_bench/config/optimizers/mlos_core_default_opt.jsonc b/mlos_bench/mlos_bench/config/optimizers/mlos_core_default_opt.jsonc index f48d2f2e149..88006219ae0 100644 --- a/mlos_bench/mlos_bench/config/optimizers/mlos_core_default_opt.jsonc +++ b/mlos_bench/mlos_bench/config/optimizers/mlos_core_default_opt.jsonc @@ -5,8 +5,7 @@ "class": "mlos_bench.optimizers.MlosCoreOptimizer", "config": { - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": 100 } } diff --git a/mlos_bench/mlos_bench/config/optimizers/mlos_core_flaml.jsonc b/mlos_bench/mlos_bench/config/optimizers/mlos_core_flaml.jsonc index 47d92aff6ee..f20fc278186 100644 --- a/mlos_bench/mlos_bench/config/optimizers/mlos_core_flaml.jsonc +++ b/mlos_bench/mlos_bench/config/optimizers/mlos_core_flaml.jsonc @@ -5,9 +5,8 @@ "class": "mlos_bench.optimizers.MlosCoreOptimizer", "config": { - "optimization_target": "score", - "optimization_direction": "min", "max_suggestions": 100, - "optimizer_type": "FLAML" + "optimizer_type": "FLAML", + "optimization_targets": {"score": "min"} } } diff --git a/mlos_bench/mlos_bench/config/optimizers/mlos_core_smac.jsonc b/mlos_bench/mlos_bench/config/optimizers/mlos_core_smac.jsonc index 3eb40c11468..5a7cf88bbba 100644 --- a/mlos_bench/mlos_bench/config/optimizers/mlos_core_smac.jsonc +++ b/mlos_bench/mlos_bench/config/optimizers/mlos_core_smac.jsonc @@ -5,8 +5,7 @@ "class": "mlos_bench.optimizers.MlosCoreOptimizer", "config": { - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": 100, "optimizer_type": "SMAC", "output_directory": null // Override to have a permanent output with SMAC history etc. diff --git a/mlos_bench/mlos_bench/config/optimizers/mock_opt.jsonc b/mlos_bench/mlos_bench/config/optimizers/mock_opt.jsonc index 1d3dec27cb2..ec9ee44ce14 100644 --- a/mlos_bench/mlos_bench/config/optimizers/mock_opt.jsonc +++ b/mlos_bench/mlos_bench/config/optimizers/mock_opt.jsonc @@ -5,7 +5,7 @@ "class": "mlos_bench.optimizers.MockOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 5, "seed": 42 } diff --git a/mlos_bench/mlos_bench/config/schemas/cli/common-defs-subschemas.json b/mlos_bench/mlos_bench/config/schemas/cli/common-defs-subschemas.json index 00a353426f3..e7676af4ab5 100644 --- a/mlos_bench/mlos_bench/config/schemas/cli/common-defs-subschemas.json +++ b/mlos_bench/mlos_bench/config/schemas/cli/common-defs-subschemas.json @@ -15,7 +15,6 @@ "uniqueItems": true } }, - "experiment_id": { "description": "The name of the experiment. Controls trial reuse and sometimes used to disambiguate certain resources definitions. Note: changes to this value will result in a new experiment being created, which may be necessary upon certain config or script changes.", "type": "string", @@ -31,6 +30,14 @@ "description": "Config ID to use (or resume) for the experiment.", "type": "integer", "minimum": 0 + }, + "optimization_targets": { + "description": "Names of the optimization targets and their directions.", + "type": "object", + "additionalProperties": { + "enum": ["min", "max"] + }, + "minItems": 1 } } } diff --git a/mlos_bench/mlos_bench/config/schemas/cli/globals-schema.json b/mlos_bench/mlos_bench/config/schemas/cli/globals-schema.json index 3df7cb245e0..015b4a6e62c 100644 --- a/mlos_bench/mlos_bench/config/schemas/cli/globals-schema.json +++ b/mlos_bench/mlos_bench/config/schemas/cli/globals-schema.json @@ -10,11 +10,9 @@ "type": "string", "pattern": "/schemas/cli/globals-schema.json$" }, - "tunable_params_map": { "$ref": "./common-defs-subschemas.json#/$defs/tunable_params_map" }, - "experiment_id": { "$ref": "./common-defs-subschemas.json#/$defs/experiment_id" }, @@ -23,6 +21,9 @@ }, "config_id": { "$ref": "./common-defs-subschemas.json#/$defs/config_id" + }, + "optimization_targets": { + "$ref": "./common-defs-subschemas.json#/$defs/optimization_targets" } }, "additionalProperties": { diff --git a/mlos_bench/mlos_bench/config/schemas/optimizers/optimizer-schema.json b/mlos_bench/mlos_bench/config/schemas/optimizers/optimizer-schema.json index 32db42f9e66..92bcee5574b 100644 --- a/mlos_bench/mlos_bench/config/schemas/optimizers/optimizer-schema.json +++ b/mlos_bench/mlos_bench/config/schemas/optimizers/optimizer-schema.json @@ -12,15 +12,8 @@ "$comment": "config properties common to all optimizer types.", "type": "object", "properties": { - "optimization_target": { - "description": "The name of the metric to optimize.", - "type": "string", - "example": "score" - }, - "optimization_direction": { - "description": "Whether to minimize or maximize the optimization target.", - "enum": ["min", "max"], - "example": "min" + "optimization_targets": { + "$ref": "../cli/common-defs-subschemas.json#/$defs/optimization_targets" }, "max_suggestions": { "description": "The maximum number of additional (in the case of merging experiment data or resuming experiments) config suggestions to run when we launch the app, or no limit if 0 is provided. Note: configs may be repeated in more than one trial.", diff --git a/mlos_bench/mlos_bench/optimizers/base_optimizer.py b/mlos_bench/mlos_bench/optimizers/base_optimizer.py index 5825c3467c9..91b0c77b2ca 100644 --- a/mlos_bench/mlos_bench/optimizers/base_optimizer.py +++ b/mlos_bench/mlos_bench/optimizers/base_optimizer.py @@ -34,8 +34,7 @@ class Optimizer(metaclass=ABCMeta): # pylint: disable=too-many-instance-attr # See Also: mlos_bench/mlos_bench/config/schemas/optimizers/optimizer-schema.json BASE_SUPPORTED_CONFIG_PROPS = { - "optimization_target", - "optimization_direction", + "optimization_targets", "max_suggestions", "seed", "start_with_defaults", @@ -78,8 +77,15 @@ def __init__(self, self._start_with_defaults: bool = bool( strtobool(str(self._config.pop('start_with_defaults', True)))) self._max_iter = int(self._config.pop('max_suggestions', 100)) - self._opt_target = str(self._config.pop('optimization_target', 'score')) - self._opt_sign = {"min": 1, "max": -1}[self._config.pop('optimization_direction', 'min')] + + opt_targets: Dict[str, str] = self._config.pop('optimization_targets', {'score': 'min'}) + if not isinstance(opt_targets, dict): + raise ValueError(f"optimization_targets should be a dict: {opt_targets}") + # TODO: Implement multi-target optimization. + if len(opt_targets) != 1: + raise NotImplementedError("Multi-target optimization is not implemented.") + (self._opt_target, opt_dir) = list(opt_targets.items())[0] + self._opt_sign = {"min": 1, "max": -1}[opt_dir] def _validate_json_config(self, config: dict) -> None: """ diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_direction.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_direction.jsonc index 2dc83df55f8..64f5b142b3e 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_direction.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_direction.jsonc @@ -2,7 +2,6 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", - "optimization_direction": "INVALID" + "optimization_targets": {"score": "INVALID"} } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target.jsonc index 4c6dd8d6d41..d24483043e2 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target.jsonc @@ -2,7 +2,6 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": ["latency", "throughput"], - "optimization_direction": "min" + "optimization_targets": ["latency", "throughput"] } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target_old_style.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target_old_style.jsonc new file mode 100644 index 00000000000..3e967c76a66 --- /dev/null +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_optimization_target_old_style.jsonc @@ -0,0 +1,8 @@ +{ + "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", + + "config": { + "optimization_target": "latency", + "optimization_direction": "min" + } +} diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_schema_ref.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_schema_ref.jsonc index 06e81d95b22..85354c14752 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_schema_ref.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_schema_ref.jsonc @@ -4,7 +4,7 @@ "class": "mlos_bench.optimizers.MockOptimizer", "config": { - "optimization_target": "score" + "optimization_targets": {"score": "min"} } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_space_adapter_type.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_space_adapter_type.jsonc index b23efb585d8..a1923c3fab4 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_space_adapter_type.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/bad_space_adapter_type.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, // space_adapter_type only accepts certain values "space_adapter_type": "unknown" } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/config_bad_type.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/config_bad_type.jsonc index 7f435469c38..843a392e0a8 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/config_bad_type.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/config_bad_type.jsonc @@ -3,7 +3,7 @@ "class": "mlos_bench.optimizers.MockOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "seed": "wrong type" } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_opt_config.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_opt_config.jsonc index cafac3605e3..59aff2689dc 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_opt_config.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_opt_config.jsonc @@ -4,6 +4,6 @@ "class": "mlos_bench.optimizers.InvalidOptimizer", "config": { - "optimization_target": "score" + "optimization_targets": {"score": "min"} } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_space_adapter_config.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_space_adapter_config.jsonc index 053a57b0689..d5d596140c5 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_space_adapter_config.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/invalid_space_adapter_config.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "space_adapter_type": "IDENTITY", "space_adapter_config": { // IDENTITY space adapter doesn't accept any config values diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/missing_opt_class_config.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/missing_opt_class_config.jsonc index 231f50034cb..621709f213e 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/missing_opt_class_config.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/missing_opt_class_config.jsonc @@ -1,7 +1,7 @@ { "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_bad_optimizer_type.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_bad_optimizer_type.jsonc index 9da4bd0f0c2..6e9094537e4 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_bad_optimizer_type.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_bad_optimizer_type.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, // optimizer_type only accepts certain values "optimizer_type": "unknown" } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_flaml_bad_arg.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_flaml_bad_arg.jsonc index ca84e43c918..383af65f0bb 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_flaml_bad_arg.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_flaml_bad_arg.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "optimizer_type": "FLAML", "base_estimator": "foo" } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_random_bad_conf.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_random_bad_conf.jsonc index 60d9cb03baf..d721bbadc95 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_random_bad_conf.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_random_bad_conf.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "space_adapter_type": null, "optimizer_type": "RANDOM", "random_seed": 0 diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_smac_bad_probability.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_smac_bad_probability.jsonc index 9498c5ae205..a02a0141306 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_smac_bad_probability.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/invalid/mlos_opt_smac_bad_probability.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_extra.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_extra.jsonc index a541e233fdd..aa4ee005832 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_extra.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_extra.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "optimizer_type": "SMAC", // base_estimator is only valid for optimizer_type == SKOPT "base_estimator": "gp" diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_llamatune_extra.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_llamatune_extra.jsonc index 6891319e947..dbfa9830682 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_llamatune_extra.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mlos_opt_smac_llamatune_extra.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mock_opt_extra_outer.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mock_opt_extra_outer.jsonc index 5b1259232f2..5311c617cc0 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mock_opt_extra_outer.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/mock_opt_extra_outer.jsonc @@ -5,7 +5,7 @@ "extra_outer": "should not be here", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/one_shot_opt_extra.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/one_shot_opt_extra.jsonc index e400acced86..5a7ecea4117 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/one_shot_opt_extra.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/bad/unhandled/one_shot_opt_extra.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.one_shot_optimizer.OneShotOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "extra_param": "should not be here" } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/grid_search_opt_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/grid_search_opt_full.jsonc index 89a782a9735..cb042135384 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/grid_search_opt_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/grid_search_opt_full.jsonc @@ -6,9 +6,8 @@ ], "config": { "max_suggestions": 100, - "optimization_direction": "max", - "optimization_target": "score", + "optimization_targets": {"score": "max"}, "seed": 12345, "start_with_defaults": true } -} \ No newline at end of file +} diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_flaml_null_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_flaml_null_full.jsonc index 0be5f47165a..1ad4488b708 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_flaml_null_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_flaml_null_full.jsonc @@ -3,7 +3,7 @@ "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 10, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_random_identity_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_random_identity_full.jsonc index 01f13fc8a77..e30cd09ffeb 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_random_identity_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_random_identity_full.jsonc @@ -3,7 +3,7 @@ "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_llamatune_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_llamatune_full.jsonc index 24fdbda7aaa..a3a4d9859c9 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_llamatune_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_llamatune_full.jsonc @@ -3,7 +3,7 @@ "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_null_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_null_full.jsonc index dd4a93c2cbf..3e5b26ebc51 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_null_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mlos_opt_smac_null_full.jsonc @@ -2,7 +2,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false, diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mock_opt_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mock_opt_full.jsonc index 3dfd052fc10..9ff6b14ac1e 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mock_opt_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/mock_opt_full.jsonc @@ -3,7 +3,7 @@ "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/one_shot_opt_full.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/one_shot_opt_full.jsonc index 3b5d2f34a4e..c6d70a2087f 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/one_shot_opt_full.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/full/one_shot_opt_full.jsonc @@ -10,7 +10,7 @@ "config": { // Here we do our best to list the exhaustive set of full configs available for the base optimizer config. - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "start_with_defaults": false diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mlos_opt_smac_llamatune_partial.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mlos_opt_smac_llamatune_partial.jsonc index 1159d982adb..e62fc18d0fc 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mlos_opt_smac_llamatune_partial.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mlos_opt_smac_llamatune_partial.jsonc @@ -3,7 +3,7 @@ "class": "mlos_bench.optimizers.mlos_core_optimizer.MlosCoreOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 20, "seed": 12345, "optimizer_type": "SMAC", diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mock_opt_schema_partial_config.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mock_opt_schema_partial_config.jsonc index 4419da9d566..00be235e7b0 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mock_opt_schema_partial_config.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/mock_opt_schema_partial_config.jsonc @@ -3,7 +3,7 @@ "class": "mlos_bench.optimizers.MockOptimizer", "config": { - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "seed": 12345 } } diff --git a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/one_shot_opt_partial.jsonc b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/one_shot_opt_partial.jsonc index 330e176a023..6178a845599 100644 --- a/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/one_shot_opt_partial.jsonc +++ b/mlos_bench/mlos_bench/tests/config/schemas/optimizers/test-cases/good/partial/one_shot_opt_partial.jsonc @@ -3,6 +3,6 @@ "class": "mlos_bench.optimizers.OneShotOptimizer", "config": { - "optimization_target": "score" + "optimization_targets": {"score": "min"} } } diff --git a/mlos_bench/mlos_bench/tests/optimizers/conftest.py b/mlos_bench/mlos_bench/tests/optimizers/conftest.py index 907a2d98a57..7149a79c933 100644 --- a/mlos_bench/mlos_bench/tests/optimizers/conftest.py +++ b/mlos_bench/mlos_bench/tests/optimizers/conftest.py @@ -59,8 +59,7 @@ def mock_opt_no_defaults(tunable_groups: TunableGroups) -> MockOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": 5, "start_with_defaults": False, "seed": SEED @@ -77,8 +76,7 @@ def mock_opt(tunable_groups: TunableGroups) -> MockOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": 5, "seed": SEED }, @@ -94,8 +92,7 @@ def mock_opt_max(tunable_groups: TunableGroups) -> MockOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "max", + "optimization_targets": {"score": "max"}, "max_suggestions": 10, "seed": SEED }, @@ -111,8 +108,7 @@ def flaml_opt(tunable_groups: TunableGroups) -> MlosCoreOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": 15, "optimizer_type": "FLAML", "seed": SEED, @@ -129,8 +125,7 @@ def flaml_opt_max(tunable_groups: TunableGroups) -> MlosCoreOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "max", + "optimization_targets": {"score": "max"}, "max_suggestions": 15, "optimizer_type": "FLAML", "seed": SEED, @@ -155,8 +150,7 @@ def smac_opt(tunable_groups: TunableGroups) -> MlosCoreOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "min", + "optimization_targets": {"score": "min"}, "max_suggestions": SMAC_ITERATIONS, "optimizer_type": "SMAC", "seed": SEED, @@ -177,8 +171,7 @@ def smac_opt_max(tunable_groups: TunableGroups) -> MlosCoreOptimizer: tunables=tunable_groups, service=None, config={ - "optimization_target": "score", - "optimization_direction": "max", + "optimization_targets": {"score": "max"}, "max_suggestions": SMAC_ITERATIONS, "optimizer_type": "SMAC", "seed": SEED, diff --git a/mlos_bench/mlos_bench/tests/optimizers/grid_search_optimizer_test.py b/mlos_bench/mlos_bench/tests/optimizers/grid_search_optimizer_test.py index c56b66b9e1c..177511758c6 100644 --- a/mlos_bench/mlos_bench/tests/optimizers/grid_search_optimizer_test.py +++ b/mlos_bench/mlos_bench/tests/optimizers/grid_search_optimizer_test.py @@ -83,7 +83,7 @@ def grid_search_opt(grid_search_tunables: TunableGroups, max_iterations = len(grid_search_tunables_grid) * 2 - 3 return GridSearchOptimizer(tunables=grid_search_tunables, config={ "max_suggestions": max_iterations, - "optimization_direction": "max", + "optimization_targets": {"score": "max"}, }) diff --git a/mlos_bench/mlos_bench/tests/optimizers/llamatune_opt_test.py b/mlos_bench/mlos_bench/tests/optimizers/llamatune_opt_test.py index da2acfb6363..3ddcec3417a 100644 --- a/mlos_bench/mlos_bench/tests/optimizers/llamatune_opt_test.py +++ b/mlos_bench/mlos_bench/tests/optimizers/llamatune_opt_test.py @@ -30,7 +30,7 @@ def llamatune_opt(tunable_groups: TunableGroups) -> MlosCoreOptimizer: "space_adapter_config": { "num_low_dims": 2, }, - "optimization_target": "score", + "optimization_targets": {"score": "min"}, "max_suggestions": 10, "optimizer_type": "SMAC", "seed": SEED,