Parallelizing Thompson Sampling

amin karbasi, Vahab Mirrokni, Mohammad Shadravan

Thompson Sampling (TS) is a cornerstone algorithm for online decision-making, effectively balancing the "exploration" of new actions with the "exploitation" of known rewards. However, standard TS is fully sequential: an agent picks an arm, observes the reward, updates its model, and repeats. In many real-world applications—such as clinical trials, A/B testing, or large-scale recommendation systems—this sequential bottleneck is impractical. Actions often need to be deployed in massive, simultaneous batches before any feedback is received.

This paper introduces a dynamic batching framework that enables massive parallelism. It reduces the number of required model updates from $T$ to just $O(\log T)$ while maintaining the near-optimal regret guarantees of fully sequential TS.

The Dynamic Batching Mechanism

The authors propose Batch Thompson Sampling (B-TS) and its contextual variant (B-TS-C). The core innovation is a dynamic batching mechanism based on a "doubling trick."

Instead of updating the model at fixed intervals (static batching), the algorithm tracks the number of times each arm $a$ has been played ($k_a$). A batch only concludes—triggering a model update—when the play count for any arm reaches the next power of two ($2^{l_a}$).

  • Early on, when uncertainty is high, batches are small and updates are frequent.
  • Later on, as the algorithm becomes more confident, batch sizes grow exponentially, and updates become rare.
Pseudocode for Batch Thompson Sampling (B-TS) and its contextual variant (B-TS-C), highlighting the doubling trick for batch updates.

Key Insights and Results

Exponential Efficiency

The jump from $T$ interactions to $O(\log T)$ is massive. For a horizon of $T=10,000$, a sequential agent must interact and update its model 10,000 times. In contrast, the B-TS agent might only need around 40-50 interactions.

Figure 1 demonstrates that the number of queries scales linearly with the number of arms (a) but logarithmically with time (b), confirming the $O(\log T)$ theoretical bound.

Dynamic vs. Static Batching

The paper demonstrates that dynamic batching is far superior to static batching. Even if a static policy is given four times as many batches as B-TS, it still incurs higher regret because it cannot adapt its exploration rate to its growing confidence.

Theoretical Parity and Real-World Validation

Perhaps the most surprising result is that you do not lose anything asymptotically by waiting to update. The regret bounds for B-TS match the optimal sequential bounds up to constant factors.

  • Regret Performance: In synthetic tests, B-TS followed almost the exact same regret trajectory as sequential TS, proving that batching doesn't necessitate a drop in performance.
  • Minimax Optimality: A specialized version, B-MOTS, achieved the optimal $O(\sqrt{NT})$ regret bound, matching the best possible theoretical performance for any bandit algorithm.
  • MovieLens Dataset: On real-world recommendation data, B-TS-C performed nearly identically to its sequential counterpart, while a static batching baseline lagged significantly behind.

Limitations and Future Work

While the $O(\log T)$ time scaling is excellent, the number of batches still scales linearly with the number of arms ($N$). In systems with millions of items, this could still lead to a high number of updates. Additionally, the contextual bandit analysis currently focuses on a finite number of arms; extending this framework to infinite or continuous arm spaces remains an open challenge for future research.

Summary updated

BibTeX
@inproceedings{karbasi2021parallelizing,
  author = {amin karbasi and Vahab Mirrokni and Mohammad Shadravan},
  title = {{Parallelizing Thompson Sampling}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=rdMQrE-loT5},
}
Figure