BOAT is a task-agnostic, gradient-based Bi-Level Optimization (BLO) Python library that focuses on abstracting the key BLO process into modular, flexible components. It enables researchers and developers to tackle learning tasks with hierarchical nested nature by providing customizable and diverse operator decomposition, encapsulation, and combination. BOAT supports specialized optimization strategies, including second-order or first-order, nested or non-nested, and with or without theoretical guarantees, catering to various levels of complexity.
To enhance flexibility and efficiency, BOAT incorporates the Dynamic Operation Library (D-OL) and the Hyper Operation Library (H-OL), alongside a collection of state-of-the-art first-order optimization strategies. BOAT also provides multiple implementation versions:
PyTorch-based: An efficient and widely-used version.
Jittor-based: An accelerated version for high-performance tasks.
MindSpore-based: Incorporating the latest first-order optimization strategies to support emerging application scenarios.
BOAT is designed to offer robust computational support for a broad spectrum of BLO research and applications, enabling innovation and efficiency in machine learning and computer vision.
🔑 Key Features
Dynamic Operation Library (D-OL): Incorporates 4 advanced dynamic system construction operations, enabling users to flexibly tailor optimization trajectories for BLO tasks.
Hyper-Gradient Operation Library (H-OL): Provides 9 refined operations for hyper-gradient computation, significantly enhancing the precision and efficiency of gradient-based BLO methods.
First-Order Gradient Methods (FOGMs): Integrates 4 state-of-the-art first-order methods, enabling fast prototyping and validation of new BLO algorithms. With modularized design, BOAT allows flexible combinations of multiple upper-level and lower-level operators, resulting in over 63+16 (nearly 80) algorithmic combinations, offering unparalleled adaptability.
Modularized Design for Customization: Empowers users to flexibly combine dynamic and hyper-gradient operations while customizing the specific forms of problems, parameters, and optimizer choices, enabling seamless integration into diverse task-specific codes.
Comprehensive Testing & Continuous Integration: Achieves 99% code coverage through rigorous testing with pytest and Codecov, coupled with continuous integration via GitHub Actions, ensuring software robustness and reliability.
Fast Prototyping & Algorithm Validation: Streamlined support for defining, testing, and benchmarking new BLO algorithms.
Unified Computational Analysis: Offers a comprehensive complexity analysis of gradient-based BLO techniques to guide users in selecting optimal configurations for efficiency and accuracy.
Detailed Documentation & Community Support: Offers thorough documentation with practical examples and API references via MkDocs, ensuring accessibility and ease of use for both novice and advanced users.
🚀 Why BOAT?
Existing automatic differentiation (AD) tools primarily focus on specific and fundamental optimization strategies, such as explicit or implicit methods, and are often targeted at meta-learning or specific application scenarios, lacking support for algorithm customization.
In contrast, BOAT expands the landscape of Bi-Level Optimization (BLO) applications by supporting a broader range of problem-adaptive operations. It bridges the gap between theoretical research and practical deployment, offering unparalleled flexibility to design, customize, and accelerate BLO techniques.
🏭 Applications
BOAT enables efficient implementation and adaptation of advanced BLO techniques for key applications, including but not limited to:
Execute the optimization loop, optionally customizing the solver strategy for dynamic methods.
python
1# Set number of iterations2iterations =100034# Optimization loop (Demo Only)5for x_itr inrange(iterations):6# Run a single optimization iteration7 loss, run_time = b_optimizer.run_iter(ll_feed_dict, ul_feed_dict, current_iter=x_itr)8
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.