BoTorch: Bayesian Optimization Built on PyTorch
Bayesian optimization in PyTorch
At a glance
- What is it?
- BoTorch is a low-level library for composing Bayesian optimization loops in PyTorch. It suits researchers who need custom acquisition functions and models, not teams looking for a finished optimization service.
- Who is it for?
- Adopt BoTorch if you are doing Bayesian optimization research or need custom models and acquisition functions, and you are comfortable with PyTorch, GPyTorch and double precision. Do not adopt it if you want a ready-made optimization service with storage and feature transforms; the README points those users to Ax.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 7 days ago.
- What is it written in?
- Mainly Jupyter Notebook, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 27, 2026, and from our analysis. They are not legal advice.
Editorial analysis
What BoTorch Is For, and Who It Is For
BoTorch is a library for Bayesian optimization built on PyTorch. The README states that its primary audience is researchers and sophisticated practitioners in Bayesian optimization and AI, and that it is meant to be used as a low-level API for implementing new algorithms for Ax. That positioning matters more than any feature list. BoTorch gives you the pieces of an optimization loop as separate objects: a probabilistic model, an acquisition function, and an optimizer that maximizes the acquisition function over a bounded domain. You assemble them yourself.
The README is explicit about who should not start here. It recommends that end users who are not actively doing research on Bayesian optimization simply use Ax, which it describes as an easy-to-use platform that also handles feature transformations and meta-data management. So the boundary is clear: BoTorch is for people who want to change the algorithm, and Ax is for people who want to run the algorithm.
The Three-Stage Loop: Model, Acquisition Function, Optimizer
The mechanism visible in the README is a three-stage loop. First you fit a Gaussian process model to observed data. The example uses SingleTaskGP with an input transform, wraps it in an ExactMarginalLogLikelihood from GPyTorch, and calls fit_gpytorch_mll. Second you construct an acquisition function from that fitted model; the example uses LogExpectedImprovement with best_f set to the best observed value. Third you optimize the acquisition function with optimize_acqf over explicit bounds, passing q, num_restarts and raw_samples.
The README states that BoTorch supports Monte Carlo-based acquisition functions via the reparameterization trick, which it says makes it straightforward to implement new ideas without imposing restrictive assumptions about the underlying model. That is the design decision that separates it from libraries built around closed-form acquisition functions. It also states that BoTorch has first-class support for GPyTorch models, including multi-task Gaussian processes, deep kernel learning, deep GPs and approximate inference. The dependency list in pyproject.toml confirms the coupling: gpytorch is pinned at 1.15.2 or later, linear_operator at 0.6.1 or later, and torch at 2.4 or later.
Installing BoTorch and Running a First Optimization Step
The README lists Python 3.11 or later, PyTorch 2.0.1 or later, gpytorch 1.14 or later, linear_operator 0.6 or later, pyro-ppl 1.8.4 or later, scipy, and multiple-dispatch as installation requirements. The pyproject.toml raises the PyTorch floor to 2.4 and the gpytorch floor to 1.15.2, so trust the file over the prose when resolving dependencies. The simplest install is from PyPI:
pip install botorchThe README notes that BoTorch stopped publishing an official Anaconda package to the pytorch channel after the 0.12 release, and that conda users should install from conda-forge instead:
conda install botorch -c gpytorch -c conda-forgeFor a first real use, the README's getting-started sequence fits a model and then optimizes an acquisition function. Note the comment that double precision is highly recommended for GPs, and that the output tensor needs an explicit output dimension:
import torch
from botorch.models import SingleTaskGP
from botorch.models.transforms import Normalize
from botorch.fit import fit_gpytorch_mll
from gpytorch.mlls import ExactMarginalLogLikelihood
train_X = torch.rand(10, 2, dtype=torch.double) * 2
Y = 1 - (train_X - 0.5).norm(dim=-1, keepdim=True)
Y += 0.1 * torch.rand_like(Y)
gp = SingleTaskGP(train_X=train_X, train_Y=Y, input_transform=Normalize(d=2))
mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
fit_gpytorch_mll(mll)With the fitted model, you build an acquisition function and optimize it over bounds. The bounds tensor must match the model's dtype and input dimension:
from botorch.acquisition import LogExpectedImprovement
from botorch.optim import optimize_acqf
logEI = LogExpectedImprovement(model=gp, best_f=Y.max())
bounds = torch.stack([torch.zeros(2), torch.ones(2)]).to(torch.double)
candidate, acq_value = optimize_acqf(logEI, bounds=bounds, q=1, num_restarts=5, raw_samples=20)The call returns a candidate point and the acquisition value at that point. In a real loop you would evaluate the candidate, append it to train_X and Y, and fit again.
Beta Status, Deprecated Defaults and the Cost of the Low-Level API
The README states plainly that BoTorch is currently in beta and under active development, and pyproject.toml carries the classifier Development Status :: 4 - Beta. That is a real constraint for anyone planning to build a product on top of it. APIs can move between releases, and the changelog exists precisely because they do.
The second limitation is the one the README imposes on you by design. Choosing BoTorch means you own the parts Ax would otherwise own: feature transformations, meta-data management, storage, and the loop itself. The README says Ax handles those, and that is the trade you are making. If your problem is a standard single-objective optimization over a fixed search space, writing that plumbing yourself is work you do not need to do.
A third constraint is numerical. The README's own example comment says double precision is highly recommended for GPs and links to a discussion about it. Fitting Gaussian processes also means the cost of the fit grows with the number of observations, and the acquisition optimization is a separate inner optimization with its own num_restarts and raw_samples budget. Neither number has a documented default that is right for every problem, so tuning them is part of using the library.
BoTorch Compared with Ax and GPyTorch
The comparison that matters most is with Ax, because the README makes it directly. Ax is described as an easy-to-use platform for end users that is also flexible enough for Bayesian optimization researchers to plug into for feature transformations and meta-data management. BoTorch is described as a low-level API for implementing new algorithms for Ax. The difference in approach is therefore not about which optimizer is better; it is about where the abstraction line sits. Ax gives you a service with a managed loop and storage. BoTorch gives you the primitives and expects you to write the loop.
The second comparison is with GPyTorch. BoTorch depends on GPyTorch and the README states it has first-class support for GPyTorch models. GPyTorch is the Gaussian process layer: it provides the model classes, likelihoods and marginal log likelihoods. BoTorch adds the optimization layer on top: acquisition functions such as LogExpectedImprovement, and the optimize_acqf routine that searches for the next point. In the getting-started example, the model and the marginal likelihood come from botorch.models and gpytorch.mlls respectively, and both are needed to fit before any acquisition function can be built. If your problem is regression with a Gaussian process and no sequential decision loop, GPyTorch alone is the smaller dependency.
Maintenance, Versioning and Licence
The repository is not archived, and the last push was on 2026-09-08, which is recent relative to the release history. The most recent release listed is v0.18.1 on 2026-06-08, preceded by v0.18.0 on 2026-06-03 and a maintenance release v0.17.2 on 2026-03-05. The presence of a maintenance release between minor versions suggests that patch releases are used to carry fixes without new features.
Upgrade cost is tied to the dependency floors. pyproject.toml requires torch 2.4 or later and gpytorch 1.15.2 or later, and the README's installation section lists lower floors, so an environment that satisfied the README text may still fail against the packaged metadata. Optional extras add their own weight: the fully_bayesian extra pulls jax, jaxlib and numpyro for fitting fully Bayesian models via NUTS, and the lcbench extra pulls pandas and pyarrow for the LCBench benchmark data loader. Installing botorch[dev] or botorch[tutorials] pulls in the test, formatting and notebook toolchains.
The licence is MIT, declared both in pyproject.toml and in the LICENSE file. MIT is permissive, so it permits use in closed-source products, but the project also asks that you cite the BoTorch paper if you use it. Citation is a request, not a licence condition, and nothing here is legal advice.
Editorial conclusion
Adopt BoTorch if you are doing Bayesian optimization research or need custom models and acquisition functions, and you are comfortable with PyTorch, GPyTorch and double precision. Do not adopt it if you want a ready-made optimization service with storage and feature transforms; the README points those users to Ax. Before committing, check that your Python is at least 3.11 and your PyTorch at least 2.4, since the pyproject.toml pins those minimums, and confirm that the acquisition function you need is not one of the ones the documentation marks as deprecated.
Frequently asked questions
What is BoTorch?
BoTorch is a library for Bayesian optimization built on PyTorch. The README describes it as a modular interface for composing probabilistic models, acquisition functions and optimizers, aimed at researchers and sophisticated practitioners.
How do I install BoTorch?
The README gives pip install botorch as the simplest option, and notes that conda users should install from the conda-forge channel with conda install botorch -c gpytorch -c conda-forge, since BoTorch stopped publishing to the pytorch channel after the 0.12 release.
What is the difference between BoTorch and Ax?
The README says BoTorch is a low-level API for implementing new algorithms for Ax, and recommends that end users who are not doing Bayesian optimization research simply use Ax. Ax handles feature transformations, meta-data management and storage.
What is the difference between BoTorch and GPyTorch?
BoTorch depends on GPyTorch and the README states it has first-class support for GPyTorch models, including multi-task Gaussian processes and deep kernel learning. GPyTorch provides the model and likelihood layer, while BoTorch adds acquisition functions and the optimizer that searches for the next point.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/meta-pytorch-botorch)