‌

Listen on your favorite platform:

Enjoying the episode? Get the next one in your inbox

New episodes, blog posts and Bayesian modeling resources — roughly once a month.

Featuring Max Balandat

• Join this channel to get access to perks:

https://www.patreon.com/c/learnbayesstats

• Proudly sponsored by PyMC Labs. Get in touch at https://www.pymc-labs.com/

• Intro to Bayes Course (first 2 lessons free): https://topmate.io/alex_andorra/503302

• Advanced Regression Course (first 2 lessons free): https://topmate.io/alex_andorra/1011122

Our theme music is « Good Bayesian », by Baba Brinkman (feat MC Lars and Mega Ran). Check out his awesome work at https://bababrinkman.com/ !

Takeaways:

  • BoTorch is designed for researchers who want flexibility in Bayesian optimization.
  • The integration of BoTorch with PyTorch allows for differentiable programming.
  • Scalability at Meta involves careful software engineering practices and testing.
  • Open-source contributions enhance the development and community engagement of BoTorch.
  • LLMs can help incorporate human knowledge into optimization processes.
  • Max emphasizes the importance of clear communication of uncertainty to stakeholders.
  • The role of a researcher in industry is often more application-focused than in academia.
  • Max's team at Meta works on adaptive experimentation and Bayesian optimization.

Chapters:

08:51 Understanding BoTorch

12:12 Use Cases and Flexibility of BoTorch

15:02 Integration with PyTorch and GPyTorch

17:57 Practical Applications of BoTorch

20:50 Open Source Culture at Meta and BoTorch's Development

43:10 The Power of Open Source Collaboration

47:49 Scalability Challenges at Meta

51:02 Balancing Depth and Breadth in Problem Solving

55:08 Communicating Uncertainty to Stakeholders

01:00:53 Learning from Missteps in Research

01:05:06 Integrating External Contributions into BoTorch

01:08:00 The Future of Optimization with LLMs

Thank you to my Patrons for making this episode possible!

Yusuke Saito, Avi Bryant, Ero Carrera, Giuliano Cruz, James Wade, Tradd Salvo, William Benton, James Ahloy, Robin Taylor,, Chad Scherrer, Zwelithini Tunyiswa, Bertrand Wilden, James Thompson, Stephen Oates, Gian Luca Di Tanna, Jack Wells, Matthew Maldonado, Ian Costley, Ally Salim, Larry Gill, Ian Moran, Paul Oreto, Colin Caprani, Colin Carroll, Nathaniel Burbank, Michael Osthege, Rémi Louf, Clive Edelsten, Henri Wallen, Hugo Botha, Vinh Nguyen, Marcin Elantkowski, Adam C. Smith, Will Kurt, Andrew Moskowitz, Hector Munoz, Marco Gorelli, Simon Kessell, Bradley Rode, Patrick Kelley, Rick Anderson, Casper de Bruin, Philippe Labonde, Michael Hankin, Cameron Smith, Tomáš Frýda, Ryan Wesslen, Andreas Netti, Riley King, Yoshiyuki Hamajima, Sven De Maeyer, Michael DeCrescenzo, Fergal M, Mason Yahr, Naoya Kanai, Aubrey Clayton, Jeannine Sue, Omri Har Shemesh, Scott Anthony Robson, Robert Yolken, Or Duek, Pavel Dusek, Paul Cox, Andreas Kröpelin, Raphaël R, Nicolas Rode, Gabriel Stechschulte, Arkady, Kurt TeKolste, Marcus Nölke, Maggi Mackintosh, Grant Pezzolesi, Joshua Meehl, Javier Sabio, Kristian Higgins, Matt Rosinski, Bart Trudeau, Luis Fonseca, Dante Gates, Matt Niccolls, Maksim Kuznecov, Michael Thomas, Luke Gorrie, Cory Kiser, Julio, Edvin Saveljev, Frederick Ayala, Jeffrey Powell, Gal Kampel, Adan Romero, Will Geary, Blake Walters, Jonathan Morgan, Francesco Madrisotti, Ivy Huang, Gary Clarke, Robert Flannery, Rasmus Hindström, Stefan, Corey Abshire, Mike Loncaric, David McCormick, Ronald Legere, Sergio Dolia, Michael Cao, Yiğit Aşık, Suyog Chandramouli and Adam Tilmar Jakobsen.

Links from the show:

loader

Key Takeaways

Max Balandat describes Bayesian optimization as a loop: fit a probabilistic surrogate model with uncertainty quantification to an expensive black-box function, optimize an acquisition function that trades off exploration and exploitation, evaluate the new point, refit, and repeat. BoTorch is the PyTorch library for running that loop, and Max is explicit that it isn't for everyone. It targets researchers developing new Bayesian optimization algorithms, and practitioners who need a lot of flexibility (custom data processing, non-standard search spaces such as molecules, materials or proteins) and know the methods well enough not to shoot themselves in the foot. If you just want black-box optimization without worrying about models and acquisition functions, Max points you to Ax, Meta's higher-level platform for adaptive experimentation, co-released with BoTorch.

Yes, with some manual work. BoTorch's acquisition functions are Monte Carlo based, so all they need are samples from the model's posterior at the inputs you query. Max explains that you could convert those samples to torch tensors and compute something like Monte Carlo expected improvement from them. What you lose is differentiability. BoTorch uses the reparameterization trick to differentiate through posterior samples, which lets it optimize the acquisition function with gradients. Without that, you're left with zeroth-order optimization of the acquisition function, which is fine in low dimensions but struggles on complex, high-dimensional problems, where gradient-based methods are much better. You also don't have to bring your own model: BoTorch ships high-quality Gaussian process implementations that work out of the box.

Max explains that GPyTorch shares BoTorch's research-first design: it's built so people can easily subclass and extend it. Its core idea was to solve the GP equations with iterative linear algebra, such as Krylov subspace methods and linear conjugate gradient solves, instead of a Cholesky decomposition. That pays off with structured matrices, lots of data and GPU computation, and the library has since added stochastic variational and other sparse GP methods. The caveat is overhead. The internals needed to handle structured matrix representations make it slower when you only have 50 to 100 data points and everything is a small dense matrix that an optimized Cholesky solve handles quickly. If you just want to fit a standard GP with a Matern kernel fast, you don't necessarily need GPyTorch.

Because everything in BoTorch and GPyTorch is written in PyTorch and is differentiable, Max explains that you can plug in any PyTorch module, such as an encoder that maps structured inputs into a latent space, in front of a GP. This is deep kernel learning: a neural network extracts features and the GP models the function on top of them. You can train both jointly, use a pre-trained extractor and fit only the GP hyperparameters, or fine-tune both. Joint training needs a decent amount of data and comes with its own difficulties, so in molecular or protein design Max often sees people first train something like a variational autoencoder on lots of data to learn a lower-dimensional latent space, then put the GP on that embedding.

Max separates two kinds of scale. The first is the number of observations in a single problem. Most Bayesian optimization problems are small, but some Meta use cases involve hundreds of thousands of observations, which calls for methods such as stochastic variational GPs with mini-batch training, or TuRBO, the trust-region approach David Eriksson developed before joining Max's team. The second is the number of problems people rely on, which Max says comes down to good old software engineering: efficient implementations, unit and integration tests, nightly benchmarks to catch regressions, rigorous code review and on-call rotations. He also favors aggregating data. Fitting a model on trillions of raw data points means fighting infrastructure battles, while aggregated data gives much higher ROI and lets generic tooling work across heterogeneous problems.

Max distinguishes two kinds of uncertainty. For the model's own uncertainty, like a posterior predictive variance, his team is very clear in plots about what the intervals represent and gives intuitive explanations people can grasp at a high level before digging into the details. The harder question is whether the tool will work on a given problem at all. Experience helps triage: weird noise distributions plus millions of data points is risky business, while a standard black-box problem will likely work. The rest is empirical: run proofs of concept, probe the edge cases, build trust incrementally, then productionize. Max adds that shipping a tool doesn't guarantee anyone uses it, so adoption also means working with product and program managers on runbooks that recommend it over eyeballing or grid search.

Max's team doesn't take paper ideas straight to production: a new model or acquisition function first gets explored in notebooks, then run through a benchmark suite, so problems tend to surface early. Often, methods that work well in one setting don't in another. His example is hierarchical search spaces, where choosing one ML model module brings its own hyperparameters and choosing another brings different ones. Some published approaches look good on paper but turned out harder on Meta's internal problems than the papers suggested. When things do break in production, Max says it's usually mundane: a subtle change in a dependency alters the algorithm's behavior in a way no test covered. The fix is to spot it quickly, repair it and add a test so it doesn't happen again.

Max sees LLMs as a way to give Bayesian optimization strong priors, while stressing that it's early days and nobody has converged on the right approach. One source is the knowledge distilled into the models themselves, which could enable few-shot optimization and make Bayesian optimization more of a technology than the art it still is. Another is human knowledge: practitioners often know roughly where the optimum is, or that the function is monotonic or periodic, but won't write a GPyTorch subclass with a periodic kernel to encode it. A natural-language interface could extract that for them. The same goes for preferences. Teams tuning online systems may watch something like 20 metrics without being able to write down a utility function, and free-form feedback carries far more information than pairwise comparisons.

Related Episodes