Repository navigation
Description
Hi and congrats for this sweet piece of software, really love it :)
I've implemented an async solution very similar to the one in the example notebook, with 13 virtual machines connecting to a master server hosting the Tornado webserver (like in the notebook), and it seems like I'm now constantly running over the same symptoms on the master server (the server registering the tested points and their respective target in the async example):
Error: 'Data point [3.47653914e+04 2.10539196e+02 3.15656650e+00 6.77134492e+00 1.01962491e+01] is not unique'
Traceback (most recent call last):
File "playground_master.py", line 72, in post
self._bo.register(params=body["params"], target=body["target"])
File "/usr/local/lib/python3.5/dist-packages/bayes_opt/bayesian_optimization.py", line 104, in register
self._space.register(params, target)
File "/usr/local/lib/python3.5/dist-packages/bayes_opt/target_space.py", line 161, in register
raise KeyError('Data point {} is not unique'.format(x))
KeyError: 'Data point [3.47653914e+04 2.10539196e+02 3.15656650e+00 6.77134492e+00 1.01962491e+01] is not unique'
It seems like the BO is suggesting to the 13 VMs to test points (set of 5 values in my case) which are already tested, almost in a constant manner after ~ 800 points tested.
Here's my troubleshooting so far:
- Using the load/save examples in the front page of BO, I save all points tested in a JSON file and for this instance of the problem, I see 817 points already registered in the JSON
- It seems like this data point thrown in the traceback is indeed ALREADY in the JSON, with an associated target value
- The 13 slave VMs are still trying to ask for "suggestions" (further set of points to test), but it seems like BO gives set of points already tested ; I still see some rare cases when it's not tested yet and the counts case increase slightly to 818, 819 points.. (but most of the time the traceback is thrown)
I'm a little bit surprised you can end up with such scenario given my PBOUND is very broad, and so, has a lot to points to be worked on without having to test the same ones again:
{'learning_timesteps': (5000, 40000),
'timesteps_per_batch': (4, 72),
'observation_loopback': (1, 20),
'mmr__timeperiod': (7, 365),
'model': (-0.49, 5.49) }
This is how I initialized the utility, which, as far as I understood, is responsible for suggesting points that were already tested:
_uf = UtilityFunction(kind="ucb", kappa=2.576, xi=0)
Should I modify the acquisition function? or some of the hyperparameters "kappa", "xi" ?
I see #92 related to this but I'm not doing any manual point probing / not doing any initialization, I really sticked to the Async notebook example, so I'm not sure this issue applies to me :(
Let me know if I can share further information & more context to this
Thanks in advance for the help :)
Lucas
Activity
fmfn commentedon Apr 22, 2019
Yeah, that's an annoying, somewhat obscure bug, that comes back every now and then. I haven't been able to reproduce it consistently, so it's hard to track it down. If you could come up with a script that always leads to this bug, please share (either here or shoot me an email).
I have a few suspicions as to why it happens, but haven't confirm them. I also have in mind a couple of ways to patching it, in the sense of going over the bug not necessarily fixing it (since I don't really know why/when it happens). So that's an option.
Are you catching these
KeyErrors and moving on with the process? I'm interested in knowing if you reach a point where no more new suggestions are being given and the whole comes to a halt.PoCk3T commentedon Apr 22, 2019
Thanks @fmfn .
Yeah it almost comes to an halt, because the "slaves" asks for points to test, work on them, send back target result, but the KeyError is throwed (and caught, so the server can keep serving other requests). Thus the optimization as such is on a halt.
Sure I can try to make a minimal version to reproduce this if this keeps happening ; overnight, I've tested "ei" instead of "ucb", but same issues happened, and now I'm back to "ucb" with a XI value of 0.01 instead of 0.00 and watching. As I was reading other issues around here, I also went ahead and changed -0.49 to 0.0 in one my boundaries in order to avoid any potential issues related to negative boundaries. Will keep you posted
Would it help if I share a JSON where problem happens ? My boundaries and indicator function are already indicated in this thread, so with that three elements that should be the easiest to reproduce, or am I missing something ? :)
Thanks again!
fmfn commentedon Apr 22, 2019
The
xiparameters is not used byUCB, so I don't expect that to make a different. If you changekappayou may be able to "fix" it.The JSON should be enough for now. I want to probe if the problem is with maximizing the acquisition function. If that's the case, it could just be a matter of increasing
kappato get the ball rolling again, maybe you can start trying that.PoCk3T commentedon Apr 24, 2019
Small update of the day:
Please let me know if I should try with another Kappa value or if a minimal way to reproduce it is needed (it's basically this JSON + the boundaries and I indicated in my original post)
wg12385 commentedon Dec 19, 2019
Hi, i've stumbled on this bug myself (big fan of the software otherwise !). Have either of you found a work-around yet ?
If it helps i've tried handling the KeyError and increasing the kappa value then trying again and it doesn't make any difference for me, once I get one identical point, it will ONLY produce identical points from then on.
Also this might be relevant, for me I can tell that it is going to produce the error before it tries, because the suggested parameters are all "round" numbers, (1.e-1 rather than 1.39475739e-1, etc), though i've got no idea what that could mean.
yfszzx commentedon Nov 17, 2020
I met same problem, and after hours debug, I guess that when we load old points, every time method “register”is used, method " suggest" must be used once, though we need no new point in the process. Now it works well. I think when “suggest” is used, some importent inner calculation is running and the inner result is recorded, which is importent for next "suggest"
bwheelz36 commentedon Jun 7, 2021
Hey all, I am also running into this problem. The below script consistently reproduces the error for me.
As a workaround, I can replace the error statement in line 163 of target_space with a warning statement. But that still results in the same point being assessed again and again... Another easy alternative would be to augment the repeated point with some random noise?
Some other thoughts:
zwelz3 commentedon Jul 26, 2021
I saw this issue and I think I have an example that consistently produces the error. Running on Windows 10, version 1.1.0 of this package.
I may be setting alpha too high. Lowering alpha does not produce this issue.
Please ignore the gross research nature of the code. I was playing around with tweaking tunable parameters in a notebook.
I've added a zip of the notebook which is probably easier to run than the paste above.
NoisyObj_ManualLoop.zip
rmcconke commentedon May 31, 2022
I have also run into this issue, but with a much simpler example. It seems like this issue occurs when the same point is registered twice.
When I leave the random noise out of the black box function, I get this error:
When I uncomment that random noise in the result, it runs fine. So, it seems this issue occurs when the optimizer converges to a similar value on the bounds for my case.
bwheelz36 commentedon Jun 14, 2022
Indeed. As I note above, this seems to occur when the problem is already solved - the optimizer sees no more value in probing points other than the ones it has already probed.
To solve this problem in my application, I just put a try/catch statement which I've copied and pasted below which will allow a few 'same points' to be probed, before quitting if the behavior keeps occurring. In my work, when the same point starts to get repeatedly probed it is a good indication of convergence so I am happy to just stop the process at that point.
I think the question is how we should actually handle this - e.g. we could attempt to put something like the code block below into the main code such that it will throw some warnings a few times and then terminate? It's not totally clear to me what the 'correct' behavior should be...
rmcconke commentedon Jun 14, 2022
It seems this could be part of a larger feature related to a "termination" condition - AFAIK, the current code only runs for a specified number of iterations, it does not have a "convergence criteria". The error arises from the
registerfunction finding an identical point, so when the optimizer gets "stuck" here I think the same point will be repeatedly suggested.After suggesting a duplicate point, the point is not registered (the
trystatement fails), and it will suggest the same point on the next iteration (the posterior hasn't changed). So, it may be possible to detect immediately (i.e., after only a single duplicate suggestion). It isn't really an error, it is the optimizer getting stuck at a point where the utility function is higher than any other unprobed location.This tends to happen with highly exploitative values of
kappaorxi, so we could also suggest a higher value in the error message if this occurs.bwheelz36 commentedon Dec 4, 2022
fixed in #372
2258324319 commentedon Feb 22, 2023
Thanks for bwhelz36's work, this problem has been solved on bayesian-optimazition>=1.4.0
if your python>=3.7,
pip install bayesian-optimazition==1.4.2if you are using python36 or python35 like me, this doesn't work. Because they add colorama 0.4.6, which is not suitable for us.
but you can install bwheelz's work in which he solved this bug first:
pip install bayesian-optimazition==1.4.0