-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add wrappers for Nevergrad #560
Comments
Hi @janosg , Under the Nevergrad library which optimization algorithm you would suggest me to include here, One plus one? OR CMA-ES , Random search , PSO? |
Hi @AashifAmeer, I you can use any optimizer. Start with the one that seems easiest to do. Long run we want all of them! |
@AashifAmeer I extended the issue description a bit so more people can work simultaneously on the issue. Please comment below which optimizer you picked. |
Hi @janosg , I want to work on this issue. I will work on OnePlusOne algorithm. I have read the documentation from nevergrad. So, the nevergrad wrapper is expected to similar that of scipy algorithms, right? From where should I start working? |
This should help you to get started: https://optimagic.readthedocs.io/en/latest/how_to/how_to_add_optimizers.html |
Hi. I have opened #579 which implements a wrapper for the PSO algorithm. |
@gulshan-123 and @r3kste, thanks for your PRs. In both PRs we currently have the problem that they way you implement parallelism is not compatible with our history collection. I first thought that the only way around this is to use the lower level ask-and-tell inferface, but I think there is a better solution you can try. BackgroundOptimagic's Implementation IdeaNevergrad has the I think the simplest way to make history collection work with nevergrad is to implement a custom |
Hello @janosg. Thanks for the feedback.
I want to point out that in #579, I actually set As |
We actually want to collect histories for all optimizers. The main benefit of history collection is to compare how efficient different optimizers are, i.e. how fast (in terms of function evaluations) they make progress. There are a few optimizers where we have not found ways to do it yet, but in nevergrad it seems to be quite easy, so we definitely want to do it. This would for example allow users to compare the efficiency of PSO with a random search algorithm. |
Hi @janosg, I have gone through the minimize function in the Optimizer class of Nevergrad (link). From my understanding, to enable parallelism, we need to implement a custom executor, as you had suggested. However, I noticed that since minimize performs optimization by "asking" for one point at a time (line 723, 728), it might be more appropriate to internally call fun instead of batch_fun. If we wish to utilize batch_fun, we would likely need to rely on the ask and tell interface to collect multiple recommendations and then evaluate them in batch (previously suggested approach). Also, I am thinking whether we can directly use ThreadPoolExecutor instead of custom executor, as fun will save the history when passed in |
@gulshan-123 Isn't the
And no, you cannot just put fun into a ThreadPoolExecutor as history collection would not work if fun is called in multiple processes. That's the reason why |
Hello. Chiming in to hopefully clear up any confusion.
With the way that the
This statement is correct, but the issue here is that it doesn't actually 'collect' the points to send it as a batch, rather it submits each point (from the batch of SolutionDue to the above mentioned reasons, I believe we cannot use the while optimizer.num_ask < optimizer.budget:
x_list = [optimizer.ask() for _ in range(optimizer.num_workers)]
losses = problem.batch_fun(
[x.value[0][0] for x in x_list], n_cores=self.n_cores
)
for x, loss in zip(x_list, losses, strict=True):
optimizer.tell(x, loss)
recommendation = optimizer.provide_recommendation() I would like to know your thoughts on this, and whether I missed out on anything. |
Wrap the gradient free optimizers from nevergrad in optimagic.
Nevergrad implements the following algorithms:
NgIohTuned
is "meta"-optimizer which adapts to the provided settings (budget, number of workers, parametrization) and should therefore be a good default.TwoPointsDE
is excellent in many cases, including very highnum_workers
.PortfolioDiscreteOnePlusOne
is excellent in discrete settings of mixed settings when high precision on parameters is not relevant; it's possibly a good choice for hyperparameter choice.OnePlusOne
is a simple robust method for continuous parameters withnum_workers
< 8.CMA
is excellent for control (e.g. neurocontrol) when the environment is not very noisy (num_workers ~50 ok) and when the budget is large (e.g. 1000 x the dimension).TBPSA
is excellent for problems corrupted by noise, in particular overparameterized (neural) ones; very highnum_workers
ok).PSO
is excellent in terms of robustness, highnum_workers
ok.ScrHammersleySearchPlusMiddlePoint
is excellent for super parallel cases (fully one-shot, i.e.num_workers
= budget included) or for very multimodal cases (such as some of our MLDA problems); don't use softmax with this optimizer.RandomSearch
is the classical random search baseline; don't use softmax with this optimizer.In the long run we want to wrap all of them, but if you are tackling this as your first issue you should focus on one. In that case please coment below which optimizer you are going to work on so we don't duplicate efforts.
The text was updated successfully, but these errors were encountered: