Reinforcement Learning for Adaptive MCMC

Congye Wang, Wilson Ye Chen, Heishiro Kanagawa, Chris J. Oates

Abstract

An informal observation, made by several authors, is that the adaptive design of a Markov transition kernel has the flavour of a reinforcement learning task. Yet, to-date it has remained unclear how to exploit modern reinforcement learning technologies for adaptive MCMC. The aim of this paper is to set out a general framework, called Reinforcement Learning Metropolis—Hastings, that is theoretically supported and empirically validated. Our principal focus is on learning fast-mixing Metropolis—Hastings transition kernels, which we cast as deterministic policies and optimise via a policy gradient. Control of the learning rate provably ensures conditions for ergodicity are satisfied. The methodology is used to construct a gradient-free sampler that out-performs a popular gradient-free adaptive Metropolis--Hastings algorithm on $\approx$90% of tasks in the PosteriorDB benchmark.

Introduction

Markov chain Monte Carlo (MCMC) is fundamental to Bayesian inference, yet its efficiency depends heavily on the choice of proposal distribution. While adaptive MCMC seeks to automate this tuning, traditional approaches are often restricted to simple parametric adjustments, such as scaling a covariance matrix. The iterative, feedback-driven nature of MCMC tuning suggests a natural fit for Reinforcement Learning (RL). However, bridging these fields requires overcoming significant theoretical hurdles, particularly ensuring that the resulting adaptive chain remains ergodic—converging to the correct target distribution despite the non-stationary nature of the adaptation.

Reinforcement Learning Metropolis-Hastings (RLMH)

The authors propose $\phi$-Metropolis-Hastings, a framework where the proposal distribution is governed by a state-dependent map $\phi$. This map is optimized by framing the tuning process as a Markov Decision Process (MDP).

In this MDP, the state consists of the current position in the chain and a proposed candidate. The action is defined by the parameters of the proposal distribution at these points. The reward is the logarithm of the Expected Squared Jump Distance (ESJD), a metric that encourages large, accepted moves. To optimize this policy, the authors utilize the Deep Deterministic Policy Gradient (DDPG) algorithm, training a neural network to represent the map $\phi$.

Evolution of the RLMH sampler: (Left) Reward increases as the policy is optimized. (Middle) The learned map evolves from identity to a non-linear transformation. (Right) Comparison of RLMH against MALA and NUTS on a bimodal target.

A critical contribution of this work is the proof of ergodicity. By implementing "diminishing adaptation"—achieved through controlled learning rate decay and gradient clipping—the algorithm is guaranteed to converge to the target distribution as the policy stabilizes.

Empirical Evaluation

The RLMH framework was evaluated using PosteriorDB, a comprehensive benchmark for Bayesian inference. The study covered 44 distinct tasks with dimensions ranging from 3 to 66, including Gaussian mixtures, ODE models, and hierarchical regressions.

RLMH was compared against two primary baselines:

  1. ARWMH: A standard gradient-free adaptive random walk Metropolis-Hastings sampler.
  2. AMALA: A gradient-based adaptive Metropolis-adjusted Langevin algorithm.

Key Results

  • Superior Mixing: RLMH outperformed ARWMH on 86% of tasks in terms of ESJD and 93% of tasks in terms of Maximum Mean Discrepancy (MMD).
  • Mode-Hopping: One of the most significant advantages of RLMH is its ability to learn "global" proposals. In multimodal landscapes, RLMH learns to propose jumps directly between distant modes, a feat that local samplers like MALA or NUTS often fail to achieve (as shown in the right panel of the figure above).
  • Gradient-Free Efficiency: Despite not using target gradient information, RLMH frequently outperformed the gradient-based AMALA, suggesting that a learned global proposal can be more effective than local gradient-driven exploration.

Discussion and Future Work

While RLMH shows great promise, it faces challenges in very high-dimensional spaces (e.g., 66 dimensions), where the RL action space becomes difficult to explore efficiently. Additionally, the current implementation requires a "warm-start" phase with a simpler sampler to initialize the target's covariance.

Future research directions include incorporating target gradients directly into the neural network policy to improve scaling and exploring more complex RL architectures. Despite the computational overhead of training a neural network during MCMC, the significant gains in sampling quality and automation make RLMH a powerful new tool for Bayesian computation.

Summary updated

BibTeX
@inproceedings{wang2025reinforcement,
  author = {Congye Wang and Wilson Ye Chen and Heishiro Kanagawa and Chris J. Oates},
  title = {{Reinforcement Learning for Adaptive MCMC}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2025},
  url = {https://openreview.net/forum?id=K8eGHgAHAz},
}
Figure