PB2 Hyper-parameters as Integers?

Hi,

I’m trying to use PB2 with hyper-parameters specified as follows:

search_space = {
    'fast_period': [3,30],
    'liquidate': [0,1],
    'should_cancel': [True, False],
}


pb2 = PB2(
    time_attr='training_iteration',
    perturbation_interval=perturbation_interval,
    require_attrs=False,
    hyperparam_bounds=search_space
    )

When i execute i run into an error because my trainable function requires parameters to be as integers.

Is there some way I can specify that the sampled hyperparameters should be integers when using the PB2 scheduler? I wasn’t able to find much in the docs.

with PBT i was able to specify integer perturbations like this :

hyperparams_mutations = {
    'fast_period': tune.qrandint(3,30,1),
    'liquidate': [0,1],
    'should_cancel': [True, False],
}

search_space = {
    'fast_period': tune.qrandint(3,30,1),
    'liquidate': tune.choice([0,1]),
    'should_cancel': tune.choice([True, False]),
}

Hi @l-j-g,

It looks like PBT has a way to do this with a custom explore function that can be used to post-process perturbed values (i.e. casting to int if needed), but PB2 does not. This can be added to PB2 to have the same behavior. Feel free to create a github issue to track this request!

One way to get around this for now is to do the casting/conversion within your trainable function, when loading the hyperparameters from the config.

Hello guys! I am interested in this issue aswell. I have been thinking abour modifying the source code by chaining the pb2_explore with my own custom version. Does this github already exist?

Hi @Amadou,

This will be added in [Tune] Add support for nested hyperparams in PB2 by justinvyu · Pull Request #31502 · ray-project/ray · GitHub. I will ping back when this is merged and usable in the latest ray-nightly.

1 Like

Hello justinvyu, Thank you very much. I overlooked your message here, is why I am replying so late

No worries! Feel free to mark this as resolved if no more questions :slight_smile: