Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Katib UI with Optuna Algorithm Settings #1626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const RandomSearchSettings: AlgorithmSetting[] = [
{
name: 'random_state',
value: null,
type: AlgorithmSettingType.STRING,
type: AlgorithmSettingType.INTEGER,
},
];

Expand Down Expand Up @@ -60,7 +60,6 @@ export const TPESettings: AlgorithmSetting[] = [
value: null,
type: AlgorithmSettingType.STRING,
},

{
name: 'prior_weight',
value: null,
Expand All @@ -69,22 +68,38 @@ export const TPESettings: AlgorithmSetting[] = [
{
name: 'n_EI_candidates',
value: null,
type: AlgorithmSettingType.STRING,
type: AlgorithmSettingType.INTEGER,
},
{
name: 'random_state',
value: null,
type: AlgorithmSettingType.STRING,
type: AlgorithmSettingType.INTEGER,
},
];

export const MultivariateTPESettings: AlgorithmSetting[] = [];
export const MultivariateTPESettings: AlgorithmSetting[] = [
{
name: 'n_startup_trials',
value: null,
type: AlgorithmSettingType.INTEGER,
},
{
name: 'n_ei_candidates',
value: null,
type: AlgorithmSettingType.INTEGER,
},
{
name: 'random_state',
value: null,
type: AlgorithmSettingType.INTEGER,
},
];

export const CMAESSettings: AlgorithmSetting[] = [
{
name: 'random_state',
value: null,
type: AlgorithmSettingType.STRING,
type: AlgorithmSettingType.INTEGER,
},
{
name: 'sigma',
Expand Down
4 changes: 2 additions & 2 deletions pkg/suggestion/v1beta1/goptuna/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ func toGoptunaSampler(algorithm *api_v1_beta1.AlgorithmSpec) (goptuna.Sampler, g
return nil, nil, err
}
opts = append(opts, tpe.SamplerOptionSeed(int64(seed)))
} else if s.Name == "startup_trials" {
} else if s.Name == "n_startup_trials" {
n, err := strconv.Atoi(s.Value)
if err != nil {
return nil, nil, err
}
opts = append(opts, tpe.SamplerOptionNumberOfStartupTrials(n))
} else if s.Name == "ei_candidates" {
} else if s.Name == "n_ei_candidates" {
n, err := strconv.Atoi(s.Value)
if err != nil {
return nil, nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/suggestion/v1beta1/optuna/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def _create_sampler(self, algorithm_spec):
if name == "tpe" or name == "multivariate-tpe":
kwargs = {}
for k, v in settings.items():
if k == "startup_trials":
if k == "n_startup_trials":
kwargs["n_startup_trials"] = int(v)
elif k == "ei_candidates":
elif k == "n_ei_candidates":
kwargs["n_ei_candidates"] = int(v)
elif k == "random_state":
kwargs["seed"] = int(v)
Expand Down
8 changes: 4 additions & 4 deletions test/suggestion/v1beta1/test_optuna_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def setup_method(self):
servicers, grpc_testing.strict_real_time())

@pytest.mark.parametrize(
["algorithm_name", "algorithm_settings"],
["algorithm_name", "algorithm_settings"],
[
["tpe", {"startup_trials": "20", "ei_candidates": "10", "random_state": "71"}],
["multivariate-tpe", {"startup_trials": "20", "ei_candidates": "10", "random_state": "71"}],
["tpe", {"n_startup_trials": "20", "n_ei_candidates": "10", "random_state": "71"}],
["multivariate-tpe", {"n_startup_trials": "20", "n_ei_candidates": "10", "random_state": "71"}],
["cmaes", {"restart_strategy": "ipop", "sigma": "2", "random_state": "71"}],
["random", {"random_state": "71"}],
],
Expand All @@ -47,7 +47,7 @@ def test_get_suggestion(self, algorithm_name, algorithm_settings):
spec=api_pb2.ExperimentSpec(
algorithm=api_pb2.AlgorithmSpec(
algorithm_name=algorithm_name,
algorithm_settings = [
algorithm_settings=[
api_pb2.AlgorithmSetting(
name=name,
value=value
Expand Down