BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization

Maximilian Balandat, Brian Karrer, Daniel R. Jiang, Samuel Daulton, Benjamin Letham, Andrew Gordon Wilson, Eytan Bakshy

Overview

BoTorch is a modular, high-performance library for Bayesian Optimization (BO) built on top of PyTorch. By leveraging Monte-Carlo acquisition functions and a "sample average approximation" approach, it allows researchers to easily design and optimize complex, non-analytic acquisition functions with the speed of hardware acceleration and the precision of auto-differentiation.

The Usability Gap in Bayesian Optimization

Bayesian Optimization is the gold standard for optimizing "expensive" black-box functions—tasks like tuning hyperparameters for a deep learning model or designing new chemical compounds where every trial costs significant time or money.

However, the field has historically faced a usability gap. Traditional BO often relies on analytic acquisition functions (like Expected Improvement) that are mathematically elegant but rigid. They struggle with modern requirements like multi-output models, asynchronous batching, or complex constraints. Existing BO libraries were often "black boxes" themselves, making it difficult for researchers to implement new ideas without fighting the underlying framework. Furthermore, most BO tools didn't fully exploit the computational revolutions of the last decade: auto-differentiation and GPU acceleration.

Methods: Differentiable Programming for BO

BoTorch bridges this gap by reimagining BO through the lens of modern differentiable programming. Its core methodology rests on three pillars:

BoTorch's modular architecture for Monte-Carlo acquisition functions
  1. Monte-Carlo (MC) Acquisition Functions: Instead of relying on closed-form math, BoTorch expresses acquisition functions as expectations over the model's posterior. This makes the framework "model-agnostic"—as long as you can draw samples from a model's posterior, you can use it for BO.
  2. Sample Average Approximation (SAA): This is a key algorithmic shift. Instead of using stochastic gradient descent (which is noisy and requires tedious tuning of learning rates), BoTorch fixes a set of "base samples" at the start of an optimization step. This transforms a stochastic problem into a deterministic one, allowing the use of powerful, higher-order quasi-Newton optimizers like L-BFGS.
  3. The Reparameterization Trick: To make these MC samples differentiable with respect to the input candidates, BoTorch uses the reparameterization trick. This allows gradients to flow from the acquisition function utility all the way back to the input features.

The authors also introduce the One-Shot Knowledge Gradient (OKG). Traditional Knowledge Gradient is a "look-ahead" method that is notoriously slow because it requires solving a nested optimization problem. BoTorch's "one-shot" formulation optimizes the candidate point and the "fantasy" future outcomes simultaneously, drastically reducing computational overhead.

Key Insights and Modularity

  • Fixing the Samples Matters: The move from "re-sampling every iteration" to SAA is a major algorithmic insight. It provides the stability needed to use L-BFGS, which converges much faster and more reliably than standard SGD in the context of BO.
  • Modularity as a Feature: By decoupling the Model, Sampler, Objective, and Acquisition Function, BoTorch allows for "plug-and-play" research. For example, you can swap a Gaussian Process for a Bayesian Neural Network without rewriting your acquisition logic.
  • Exploiting Structure: BoTorch is built on GPyTorch, which uses clever linear algebra to provide $O(1)$ predictive distributions. This allows the library to evaluate tens of thousands of points in parallel, a scale previously unreachable for most BO setups.

Key Results

The paper evaluates BoTorch across several benchmarks, including synthetic global optimization functions, reinforcement learning (tuning a DQN on Cartpole), and real-world hyperparameter optimization (tuning a neural network surrogate for the UCI Adult dataset and SWA for VGG-16 on CIFAR-10).

Optimization performance comparing BoTorch against other popular BO libraries
  • Sample Efficiency: In head-to-head comparisons, BoTorch-based algorithms consistently reached the global optimum in fewer iterations than other popular libraries like GPyOpt, Cornell-MOE, and Dragonfly.
  • Computational Speedup: Leveraging GPUs and fast predictive distributions resulted in 10–40x speedups compared to standard posterior inference on CPUs.
  • OKG Scalability: The One-Shot Knowledge Gradient was up to 6x faster than the previous state-of-the-art implementation in MOE, while also providing better optimization performance on noisy functions.

Limitations and Future Work

While highly capable, BoTorch does have limitations. For the "one-shot" OKG approach, the dimensionality of the optimization problem grows linearly with the number of Monte-Carlo samples ($N$). For very high-dimensional problems or very large $N$, this could become a bottleneck. Additionally, while modularity is great for researchers, the "low-level" nature of PyTorch-based components might present a steeper learning curve for users who just want a "one-click" hyperparameter tuner (though higher-level interfaces like Ax have since been built on top of BoTorch to address this).

Summary updated

BibTeX
@inproceedings{balandat2020botorch,
  author = {Maximilian Balandat and Brian Karrer and Daniel R. Jiang and Samuel Daulton and Benjamin Letham and Andrew Gordon Wilson and Eytan Bakshy},
  title = {{BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=hDEi_qaSikG},
}
Figure