Make the interface of batched_lbfgsb module compatible with scipy.optimize#6273
Merged
nabenabe0928 merged 52 commits intooptuna:masterfrom Oct 17, 2025
Merged
Conversation
…tion and update argument handling in negative_acqf_with_grad
This was referenced Sep 12, 2025
batched_lbfgsb module compatible with scipy.optimize
Contributor
|
@not522 |
not522
reviewed
Sep 16, 2025
Contributor
|
@not522 Thank you for the review, but as we discussed internally, I will re-assign to another reviewer next week...! |
Contributor
nabenabe0928
left a comment
There was a problem hiding this comment.
@Kaichi-Irie
Could you merge the master branch and modify the corresponding unit tests accordingly?
…d validation in test_batched_lbfgsb_invalid_input
…e argument handling
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
…aichi-Irie/optuna into refactor-batched-lbfgsb-for-PR
nabenabe0928
approved these changes
Oct 17, 2025
Contributor
nabenabe0928
left a comment
There was a problem hiding this comment.
Thank you for the fix, LGTM!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR introduces a refactoring of batched_lbfgsb and its related functions, making the interface of the
batched_lbfgsbcompatible with thescipy.optimizemodule. The goal is to address two pieces of technical debt that could lead to future bugs and make the API less intuitive.Resolve Variable Capture to Prevent Bugs
The core issue is that the nested function
negative_acqf_with_gradwas implicitly using thenormalized_paramsvariable from its enclosing scope (_gradient_ascent_batched). While this may not be causing an active bug, it is a form of technical debt that makes the code harder to reason about and could easily lead to errors in the future. This PR resolves the capture.Improve API Flexibility for
func_and_gradThe current implementation of
batched_lbfgsbimplicitly requires that thefunc_and_gradcallable accepts a second argument (batch_indices), even if the function itself does not use it. This design is inflexible and counter-intuitive.For example, a simple single-argument function is currently incompatible:
This change allows
batched_lbfgsbto correctly handle callables with and without the second argument, making the API more flexible and user-friendly.Description of the changes
batched_lbfgsbhas been updated.batch_indicesargument has been removed fromfunc_and_grad. This information is now passed viaargs_listinstead.