PyXAB -- A Python Library for $\mathcal{X}$-Armed Bandit and Online Blackbox Optimization Algorithms

Wenjie Li, Haoze Li, Jean Honorio, Qifan Song

Abstract

We introduce a Python open-source library for $\mathcal{X}$-armed bandit and online blackbox optimization named PyXAB. PyXAB contains the implementations for more than 10 $\mathcal{X}$-armed bandit algorithms, such as HOO, StoSOO, HCT, and the most recent works GPO and VHCT. PyXAB also provides the most commonly-used synthetic objectives to evaluate the performance of different algorithms and the various choices of the hierarchical partitions on the parameter space. The online documentation for PyXAB includes clear instructions for installation, straight-forward examples, detailed feature descriptions, and a complete reference of the API. PyXAB is released under the MIT license in order to encourage both academic and industrial usage. The library can be directly installed from PyPI with its source code available at https://github.com/WilliamLwj/PyXAB

Addressing the Implementation Gap

In machine learning, optimizing "blackbox" functions—where internal mechanics are unknown and only outputs are observable—is a frequent necessity, particularly for hyperparameter tuning and neural architecture search. $\mathcal{X}$-armed bandits (or Lipschitz bandits) offer a powerful solution by hierarchically partitioning the search space into nodes, treating each as an "arm" in a multi-armed bandit framework.

Despite their theoretical appeal, these algorithms are notoriously difficult to implement. They require sophisticated management of tree structures, node sampling, and the delicate balance between exploration and exploitation. Prior to PyXAB, the field was characterized by "code silos," where implementations were either proprietary, scattered across incompatible languages like MATLAB and C, or entirely unavailable in Python.

A comparison of $\mathcal{X}$-armed bandit algorithms and their open-source availability prior to PyXAB.

Modular Architecture

PyXAB introduces a modular architecture that follows the standard learning paradigm of $\mathcal{X}$-armed bandits. This design allows researchers to easily swap components and benchmark different strategies.

The modular architecture of PyXAB, showing the interaction between algorithms, partitions, nodes, and objectives.

The library is built around four core components:

  1. Algorithm: A unified API where every algorithm implements pull() to select the next evaluation point and receive_reward() to update the internal model.
  2. Partition: Manages the hierarchical splitting of the parameter space (e.g., BinaryPartition, DimensionBinaryPartition).
  3. Node: The base class for storing domain information. Specialized logic, such as the $b_{h,i}$-values in StoSOO, can be implemented by overwriting node behavior.
  4. Objective: A standardized interface for defining the optimization target.

Benchmarking and Key Results

PyXAB includes built-in synthetic benchmarks like Garland, DoubleSine, and Himmelblau. These functions represent various optimization landscapes, from multiple local optima to specific smoothness properties, providing a rigorous testing ground for new algorithms.

Key achievements of the library include:

  • Comprehensive Coverage: Implementation of over 10 algorithms, many of which (like HCT, GPO, and VHCT) previously lacked accessible Python versions.
  • Engineering Excellence: The library maintains over 95% test coverage and follows PEP8 standards using the black formatter.
  • Accessibility: A complete optimization loop can be implemented in approximately 10 lines of Python code, democratizing access to complex optimization techniques that previously took days to implement from scratch.

Future Directions

While PyXAB provides a robust foundation, future work will focus on expanding into real-world benchmarks for deep learning frameworks and developing specialized partitions to better handle the "curse of dimensionality" in high-dimensional spaces. Released under the MIT license, PyXAB is designed to grow through community contributions.

Summary updated

Abstract

We introduce a Python open-source library for $\mathcal{X}$-armed bandit and online blackbox optimization named PyXAB. PyXAB contains the implementations for more than 10 $\mathcal{X}$-armed bandit algorithms, such as HOO, StoSOO, HCT, and the most recent works GPO and VHCT. PyXAB also provides the most commonly-used synthetic objectives to evaluate the performance of different algorithms and the various choices of the hierarchical partitions on the parameter space. The online documentation for PyXAB includes clear instructions for installation, straight-forward examples, detailed feature descriptions, and a complete reference of the API. PyXAB is released under the MIT license in order to encourage both academic and industrial usage. The library can be directly installed from PyPI with its source code available at https://github.com/WilliamLwj/PyXAB
BibTeX
@misc{li2023pyxab,
  author = {Wenjie Li and Haoze Li and Jean Honorio and Qifan Song},
  title = {{PyXAB -- A Python Library for $\textbackslash\{\}mathcal\{X\}$-Armed Bandit and Online Blackbox Optimization Algorithms}},
  year = {2023},
  eprint = {2303.04030},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.04030},
}
Figure