How to have nested points to evaluate config in optuna search

How severe does this issue affect your experience of using Ray?

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

I am using Optuna search with ray tune. For my config that I pass to ray, the hyperparameters to be tuned are nested inside of dicts, for example:

config={
"arch":{
   "nc1":  tune.choice([32, 64]),
   "nc2": tune.choice([64, 128]),
   "nc3": tune.choice([128, 256]),
   "nc4": tune.choice([256, 512]),
   }
}

However the points_to_evaluate parameter in Optuna search requires the input to be of type list, meaning if I put in the same dictionary above but with values defined it throws a type error that it is not of type list:

points_to_evaluate={
"arch":{
   "nc1": 32,
   "nc2": 64,
   "nc3": 128,
   "nc4": 256,
   }
}

I’ve tried giving it in list format following what was outputted in the console:

points_to_evaluate=[
{"arch/nc1": 32},
{"arch/nc2": 64},
{"arch/nc3": 128},
{"arch/nc4": 256},
]

but gives the error:

ValueError: Dim of point {'arch/nc1': 32} and parameter_names {'arch/nc1': CategoricalDistribution(choices=(16, 32, 64)), 'arch/nc2': CategoricalDistribution(choices=(32, 64, 128)), 'arch/nc3': CategoricalDistribution(choices=(64, 128, 256)), 'arch/nc4': CategoricalDistribution(choices=(128, 256, 512)), 'optimizer/lr': LogUniformDistribution(high=0.01, low=0.0001), 'data_loader/batch_size': CategoricalDistribution(choices=(64, 128, 256))} do not match.

Hence was wondering how I would give points to evaluate when my config is a set of nested parameters

Can you try this?

points_to_evaluate=[
{"arch/nc1": 32,
"arch/nc2": 64,
"arch/nc3": 128,
"arch/nc4": 256}
]

@stephano41 I hope it will help You:
https://discuss.ray.io/t/how-to-define-fcnet-hiddens-size-and-number-of-layers-in-rllib-tune/6504/14

Sorry for the late reply! I tried what @matthewdeng suggested and it worked!

It took me a while to implement as my configs were written in yaml files, and so had to figure out how to nest a dictionary into a list.

Also realised that all hyperparameters must be listed otherwise it doesn’t quite work with dim error