-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py #441
bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py #441
Conversation
Previously, when the new upper limit was less than the original lower limit, the new_bounds could bypass the global_bounds.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #441 +/- ##
==========================================
+ Coverage 98.42% 98.46% +0.04%
==========================================
Files 8 8
Lines 573 588 +15
Branches 84 88 +4
==========================================
+ Hits 564 579 +15
+ Misses 5 3 -2
- Partials 4 6 +2 ☔ View full report in Codecov by Sentry. |
Thanks for linking me to those posts, I was not aware of them. However, this issue is distinct from #394, which addresses a window-width bypass. In This issue arises, for example, when an optimizer instance loads a log that was generated by an instance with bounds greater than those of the current instance. I will return to this PR to add a test case to |
Hey @perezed00, just to confirm, the case you're trying to cover is that sometimes, the lower bound can be greater than the upper bound (i.e. the bounds are out of order) and then the lower bound is not trimmed properly and allowed to be greater than the global bound? |
No, the case I've identified is roughly as follows: Here is the same info, but written more programmatically: Assuming nx_lower<nx_upper: Not assuming nx_lower<nx_upper: |
Thanks, that makes sense! I guess some more testing is in order. If the case you describe only shows up when loading logs from a differently configured optimizer, it makes sense that it wasn't covered before. |
Sounds good. I don't mind adding some comments to the In summary, I'll revise this PR after doing the following:
It will probably be a few days before I get a chance to implement these, but I'll post again when complete. |
Hey @perezed00, did you get around to have another look at this? Seems like the issue might've popped up for another user so I'd be eager to get this fixed. |
Thanks for the reminder, I'll finish this up today.
…On Mon, Sep 4, 2023, 5:47 AM till-m ***@***.***> wrote:
Hey @perezed00 <https://github.com/perezed00>, did you get around to have
another look at this? Seems like the issue might've popped up for another
user so I'd be eager to get this fixed.
—
Reply to this email directly, view it on GitHub
<#441 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMC6B6ZDLYQEKWYQOY46Y6LXYWPUXANCNFSM6AAAAAA3QEEEUQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Added test cases to catch an error when both bounds of new_bounds exceeded the global_bounds
_trim function now avoids an error when both bounds for a given parameter in new_bounds exceed the global_bounds
Hi, @till-m I have updated this pull request. Regarding the list of tasks above, here's what was done:
Additionally, the name of variables in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me in general. Some small questions and things to verify.
Here's an alternative solution to the bounds problem: When determining the center of the shrinking window, the transformer should only consider the subset of the target_space that is within the global_bounds. This should prevent the transformer from suggesting out-of-bounds points to begin with. This is better than simply loading a log with a smaller domain, because it still allows the Gaussian process to use the data from the larger domain. I should note that I think the original paper has a method of dealing with this problem (see page 6 if interested), but I do think that the solution above would circumvent the issue without much added work. |
Regarding your alternative solution -- I like your suggestion, maybe the appropriate way to implement this would be to restrict Also, I think it'd be good to have a warning to inform the user that the transformer observed a maximum outside the global bounds and why this can happen. |
I don't think this would be too hard to implement in the Since we have identified a few separate issues, I propose we implement the solutions in separate PRs. Here is how I see the issues:
I don't mind if this PR get's closed without integration (I'll leave that decision to you), I just don't want this single PR to become a discussion that is too long to follow. |
Hi @perezed00, my apologies, for not getting back to you, I have been rather busy recently. |
Hi @till-m, No problem, I have also been very busy. Basically, the if the transformer sees a set of parameters in the target_space that optimize the function, then it tries to converge to that set of parameters. Mathematically, can mask the target_space so that the transformer only sees the parameters within the global bounds. I implemented a windowing function within `domain_reduction.py' that doesn't require modifying other portions of the code base. I'll upload that now, along with some improved comments. During this process, I learned that the mask will not stop the transformer from suggesting bounds outside of the On the other hand, as far as I can tell, the mask does drastically improve convergence. I believe that a transformer with a mask is as good as (or better than) a "normal" transformer at converging. This can (should?) be explicitly tested. If, in your opinion, the convergence seems okay, we might want to suppress the convergence warning since it is quite common at this point. |
Added windowing function to improve the convergence of optimizers that use domain_reduction. Improved comments and documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay...
Biggest thing from my side is the fact that the max_window
should be calculated using the target space. Rest looks good to me :)
Sorry for the late reply here , I am in the final stretch of dissertation work. I will finish this in 5 days. |
No worries. Good luck with the dissertation! |
Hey @perezed00, don't mean to rush you, but any update on this? :) |
Hey @till-m , Thanks for your patience. The changes have been implemented. target_space.max() now respects the bounds and I improved the warning messages. Warnings are now more specific and less frequent. Let me know if you see any other issues. Cheers |
This function was used to prototype a solution. It should not have been pushed and can be removed.
hey, I'm a bit swamped right now, will have a look as soon as I can. Thanks for the contributions :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I think this is basically ready for merge, excluding the 3 minor comments + the warning discussion.
@osullivryan If you have the time, I think a review from your side would also be appreciated.
Thanks for adding so much high-quality documentation, by the way! |
Hey @perezed00 and @till-m , I took a look. Nice catch and fix! Awesome! |
From my side, I think this is good to go. @bwheelz36 @leandrobbraga @fmfn feel free to review. If you have no comments, I will merge this PR soon. @perezed00 thank you very much for your contribution. As you may have noticed, we are a bit short on maintainers for this project currently. Based on the way you wrote this PR, the thoughtfulness of your approaches and the clarity of the code you wrote, I think it would be very valuable to have you on the team. If you're interested, please let me know :) |
@till-m Thanks for the invite to join the team. I accept, I would be happy to join. Just a bit of a warning however: I defend my dissertation in April, so I might be less responsive a couple months before then. Cheers! |
Looks good to me. |
Thanks, that is helpful info. I wasn't aware, but I'll take a look now |
* Fixes issue-436: Constrained optimization does not allow duplicate points (#437) * Update docs of `bayesian_optimization.py` and `observer.py`. * Fix minor style issue in module docstring * Update docs of `__init__.py` and `events.py`. * Fix minor style issue in class docstring * Add workflow to check docstrings * Update bayes_opt/bayesian_optimization.py Co-authored-by: Leandro Braga <[email protected]> * Improve acq_max seeding of L-BFGS-B optimization (#297) * bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py (#441) * Update trim bounds in domain_reduction.py Previously, when the new upper limit was less than the original lower limit, the new_bounds could bypass the global_bounds. * Update test_seq_domain_red.py Added test cases to catch an error when both bounds of new_bounds exceeded the global_bounds * Update domain_reduction.py _trim function now avoids an error when both bounds for a given parameter in new_bounds exceed the global_bounds * Update domain_reduction.py comments * fixed English in domain_reduction.py * use numpy to sort bounds, boundary exceeded warn. * simple sort test added * domain_red windows target_space to global_bounds Added windowing function to improve the convergence of optimizers that use domain_reduction. Improved comments and documentation. * target_space.max respects bounds; SDRT warnings * Remove unused function. This function was used to prototype a solution. It should not have been pushed and can be removed. * Updated target_space.py docstrings * Update tests/test_target_space.py Co-authored-by: till-m <[email protected]> * Added pbound warnings, updated various tests. * updated line spacing for consistency and style * added pbound test condition --------- Co-authored-by: till-m <[email protected]> * DomainReduction docs, docstyle * Add missing doc dependency --------- Co-authored-by: YoungJae Bae <[email protected]> Co-authored-by: Leandro Braga <[email protected]> Co-authored-by: ptapping <[email protected]> Co-authored-by: Edgar <[email protected]>
* Replace custom colour implementation, add docs for `logger.py`, `util.py` (#435) * Replace custom colour implementation, add docs for `logger.py`, `util.py` * minor typo/syntax fixes * User `or` to separate different possible types * Update docs & linting for `constraints.py`, `target_space.py` (#440) * Run tests on any PR * Update docs, linting * Update bayes_opt/constraint.py Co-authored-by: Leandro Braga <[email protected]> * Rename mislabelled parameters --------- Co-authored-by: Leandro Braga <[email protected]> * Update various docstrings, add workflow to check docstrings (#445) * Fixes issue-436: Constrained optimization does not allow duplicate points (#437) * Update docs of `bayesian_optimization.py` and `observer.py`. * Fix minor style issue in module docstring * Update docs of `__init__.py` and `events.py`. * Fix minor style issue in class docstring * Add workflow to check docstrings * Update bayes_opt/bayesian_optimization.py Co-authored-by: Leandro Braga <[email protected]> --------- Co-authored-by: YoungJae Bae <[email protected]> Co-authored-by: Leandro Braga <[email protected]> * Pydocstyle (#453) * Improve acq_max seeding of L-BFGS-B optimization (#297) --------- Co-authored-by: ptapping <[email protected]> * Domain reduction, Sphinx docs (#455) * Fixes issue-436: Constrained optimization does not allow duplicate points (#437) * Update docs of `bayesian_optimization.py` and `observer.py`. * Fix minor style issue in module docstring * Update docs of `__init__.py` and `events.py`. * Fix minor style issue in class docstring * Add workflow to check docstrings * Update bayes_opt/bayesian_optimization.py Co-authored-by: Leandro Braga <[email protected]> * Improve acq_max seeding of L-BFGS-B optimization (#297) * bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py (#441) * Update trim bounds in domain_reduction.py Previously, when the new upper limit was less than the original lower limit, the new_bounds could bypass the global_bounds. * Update test_seq_domain_red.py Added test cases to catch an error when both bounds of new_bounds exceeded the global_bounds * Update domain_reduction.py _trim function now avoids an error when both bounds for a given parameter in new_bounds exceed the global_bounds * Update domain_reduction.py comments * fixed English in domain_reduction.py * use numpy to sort bounds, boundary exceeded warn. * simple sort test added * domain_red windows target_space to global_bounds Added windowing function to improve the convergence of optimizers that use domain_reduction. Improved comments and documentation. * target_space.max respects bounds; SDRT warnings * Remove unused function. This function was used to prototype a solution. It should not have been pushed and can be removed. * Updated target_space.py docstrings * Update tests/test_target_space.py Co-authored-by: till-m <[email protected]> * Added pbound warnings, updated various tests. * updated line spacing for consistency and style * added pbound test condition --------- Co-authored-by: till-m <[email protected]> * DomainReduction docs, docstyle * Add missing doc dependency --------- Co-authored-by: YoungJae Bae <[email protected]> Co-authored-by: Leandro Braga <[email protected]> Co-authored-by: ptapping <[email protected]> Co-authored-by: Edgar <[email protected]> * Small fixes, minor cosmetic changes * Add some more docs to target space and constraint, cosmetic changes * Remove duplicate code snippet * Remove numpydoc + adjust "*" formatting accordingly * Explicitly add D417, adjust code accordingly * Adjust `TargetSpace.probe()` behaviour to be in line with docstring. * Update bayes_opt/target_space.py Co-authored-by: Edgar <[email protected]> * Update README.md --------- Co-authored-by: Leandro Braga <[email protected]> Co-authored-by: YoungJae Bae <[email protected]> Co-authored-by: ptapping <[email protected]> Co-authored-by: Edgar <[email protected]>
Previously, when the upper limit of new_bounds < lower limit of global_bounds, the new_bounds could bypass the global_bounds. The proposed changes requires the little change to the existing code, but could cause one of the entries in new_bounds to stagnate at the global_bounds if the new_bounds entry is always outside of the global_bounds.