---
title: Hamiltonian Assisted Metropolis Sampling
url: https://www.emergentmind.com/topics/hamiltonian-assisted-metropolis-sampling-hams
type: topic
---

# Hamiltonian Assisted Metropolis Sampling

Hamiltonian Assisted Metropolis Sampling (HAMS) is a class of Markov chain Monte Carlo (MCMC) algorithms that leverage Hamiltonian or augmented dynamics, irreversibility, and momentum auxiliary variables to improve sampling efficiency from complex distributions. HAMS has been developed for continuous, discrete, and quantum settings, with distinctive properties including generalized detailed balance, accelerated mixing, and, for certain target distributions, rejection-free proposals.

## 1. Foundations and General Principles

HAMS constructs reversible or irreversible MCMC samplers by augmenting the state space with auxiliary momentum variables and employing Hamiltonian-like proposal dynamics. For continuous targets, given a target $\pi(x) \propto \exp[-U(x)]$, the joint distribution is formulated as
\[
\pi(x, u) \propto \exp\bigl\{ -H(x, u) \bigr\} = \exp\bigl\{ -U(x) - \tfrac{1}{2} u^\top M^{-1} u \bigr\},
\]
where $u$ is the momentum and $M$ the mass matrix [2005.08159]. HAMS takes a structured proposal of $(x, u)$ using a linear-Gaussian map, followed by a generalized Metropolis acceptance/rejection step.

In the quantum domain, HAMS enables Gibbs distribution sampling by constructing Markov chains over unitaries or quantum states, bypassing direct energy eigenbasis manipulation and using quantum subroutines such as phase estimation and weak measurement [2111.14676, 2406.16023].

For discrete variables, HAMS analogues augment the discrete state with continuous momentum, exploit auxiliary-variable proposals, and implement momentum negation and over-relaxation to achieve irreversibility and rejection-free moves under specific models [2507.09807, 2507.21982].

## 2. Continuous HAMS: Algorithm Structure and Properties

### Augmented Target and Proposal

Continuous HAMS proposals use the augmented joint density on $\mathbb{R}^d\times\mathbb{R}^d$ and involve a symmetric matrix $A$ that tunes the mixture of drift and momentum [2005.08159, 2106.03012]. A typical proposal step is:
\[
\begin{aligned}
x^* &= x_0 - a_1 \nabla U(x_0) + a_2 u_0 + Z_1, \\
u^* &= -u_0 - a_2 \nabla U(x_0) + a_3 u_0 + Z_2,
\end{aligned}
\]
with $(Z_1, Z_2)$ drawn from a Gaussian with covariance $2A - A^2$.

The acceptance probability employs the generalized detailed balance condition:
\[
\rho = \min\! \left(1, \frac{\pi(x^*,-u^*) Q(x_0, -u_0 | x^*, -u^*)}{\pi(x_0, u_0) Q(x^*, u^* | x_0, u_0)} \right).
\]
Upon rejection, only the momentum is negated.

### Irreversibility and Advanced Schemes

Irreversibility is introduced by the specific momentum negation and the use of non-reversible proposal kernels, leading to enhanced mixing and reduced autocorrelation compared to classical Langevin-based schemes [2106.03012]. HAMS encompasses various integrators (e.g., GJF, BAOAB, ABOBA) as parameter choices and provides tuning rules that can optimize spectral properties and effective sample size.

For the isotropic Gaussian case, the acceptance rate reaches unity—every proposal is accepted (the "rejection-free property") [2005.08159, 2106.03012].

### Preconditioning and Tuning

Preconditioning via linear transformation of $x$ and adaptation of $M$ is critical for high-dimensional or highly correlated targets. Practical parameter settings maximize acceptance rate or effective sample size, with step sizes typically adjusted during burn-in [2005.08159].

## 3. Quantum HAMS: Circuit-Based and Weak Measurement Approaches

### Quantum Circuit Sampling (Classical Gates)

Quantum HAMS sidesteps direct manipulation of energy eigenstates by sampling over unitaries acting on a fiducial state. For a quantum Hamiltonian $H$ and initial state $|\psi_0\rangle$, the algorithm samples from the induced "average energy"
\[
E(V) = \langle \psi_0 | V^\dagger H V | \psi_0 \rangle
\]
and constructs a Markov chain over circuits $V$. Proposals are made by replacing single gates, and the Metropolis acceptance is
\[
P_{\text{accept}} = \min(1, \exp[-\beta \Delta E]).
\]
Expectation values of observables are calculated over this induced ensemble and then extrapolated to the ground-state or low-energy regime using fits such as $E(\beta) = E_0 + {A}/{\beta^C}$ [2111.14676].

### Quantum Weak Measurement HAMS

In fully quantum implementations, HAMS constructs a quantum Markov process with the unique Gibbs state as approximate fixed point by combining boosted quantum phase estimation (QPE), jump operators, and weak measurement. The sampling proceeds as follows [2406.16023]:
- Boosted QPE is run on the system, using $g$ independent QPE procedures whose outputs are median-aggregated for robust energy estimation.
- Proposed moves are applied via unitaries $C_j$, generating candidate states.
- Acceptance is implemented as a weak rotation of an ancilla flag qubit, performing a gentle measurement to effect the (quantum) Metropolis filter.
- Rejection is handled by unitary reversal, eliminating the need for Marriott–Watrous rewinding.

Successive application of this CPTP map contracts to the Gibbs state up to small error, controlled by the QPE precision and weak measurement parameter $\tau$. The unique full-rank fixed point and mixing guarantees follow from the structure of the jump-operator algebra and the Lindblad generator [2406.16023].

## 4. Discrete HAMS: Auxiliary Variables, Over-Relaxation, and Preconditioning

### Discrete Augmentation and Proposal

Discrete HAMS (DHAMS) adapts the continuous methodology to discrete target spaces by:
- Introducing a continuous Gaussian momentum $u$ for state $x\in\mathcal{A}^d$, forming $\pi(x, u) \propto \exp(f(x) - \frac{1}{2}\|u\|^2)$.
- Proposal step involves:
   - Momentum refreshment ($u_{t+1/2} = \epsilon u_t + \sqrt{1-\epsilon^2} Z$).
   - Forming an auxiliary variable $z_t = x_t - \delta u_{t+1/2}$.
   - Proposing $x^*$ via a factorizable softmax distribution using a first-order (or second-order for PDHAMS) Taylor expansion about $x_t$.
   - Negating momentum and adding a gradient correction: $u^* = -u_{t+1/2} + (x_t-x^*)/\delta + \phi [\nabla f(x^*) - \nabla f(x_t)]$.

Irreversibility is enforced by this negation and update; the acceptance probability again satisfies a form of generalized detailed balance [2507.09807, 2507.21982].

### Over-Relaxation and Rejection-Free Property

Discrete over-relaxation schemes further reduce random walk effects and autocorrelation. In the special case of linear potentials, all proposals are accepted (i.e., the rejection-free property holds) [2507.09807].

Preconditioned DHAMS (PDHAMS) introduces a second-order (quadratic) approximation to $f(x)$, employing global Hessian surrogates and the Gaussian integral trick to decouple coordinates, yielding further improvements in sampling efficiency and scaling [2507.21982].

## 5. Theoretical Guarantees and Properties

HAMS algorithms, both in continuous and discrete domains, are characterized by:
- **Generalized detailed balance**: The Markov transition kernel $K$ satisfies
  \[
  \pi(x_0, u_0) K(x_1, u_1 | x_0, u_0) = \pi(x_1, -u_1) K(x_0, -u_0 | x_1, -u_1),
  \]
  ensuring the correct invariant distribution despite irreversibility.
- **Stationarity and Uniqueness**: The constructed process leaves the target (or Gibbs) measure invariant; in quantum settings, uniqueness follows from jump operator algebra [2406.16023, 2507.21982].
- **Rejection-free moves**: For Gaussian (continuous) or linear/quadratic (discrete) targets, acceptance is always $1$, leading to optimal mixing [2005.08159, 2507.09807, 2507.21982].
- **Enhanced mixing**: Spectral analysis on Gaussians demonstrates that the lag-1 auto-covariance modulus for HAMS is strictly less than for reversible alternatives (e.g., underdamped Langevin or MALA), translating to improved effective sample size per computational effort [2005.08159, 2106.03012].

## 6. Practical Implementation and Performance

### Parameter Tuning and Preconditioning

Default parameterizations reduce tuning to the step size $\epsilon$; optimal effectiveness empirically corresponds to acceptance rates of $60$–$80$%. Preconditioning via Cholesky factors or Hessian surrogates is critical for high-dimensional and structured target distributions [2005.08159, 2507.21982].

### Performance Summaries

Empirical results across high-dimensional Gaussians, state-space models, and latent-variable sampling tasks consistently demonstrate superior effective sample size (ESS) per unit time for HAMS variants compared to MALA, HMC, or random walk Metropolis. In discrete and preconditioned settings, PDHAMS exhibits order-of-magnitude faster mixing and lower estimation bias/variance [2507.09807, 2507.21982]. In quantum applications, effective estimation of low-lying energy observables is achieved without variational optimization, provided extrapolation to the zero-temperature limit is performed with systematic error analysis [2111.14676].

### Table: ESS Comparison for Discrete Gaussian Target ($d=8$) [2507.21982]

| Sampler     | ESS$_{\min}$ | ESS$_{\rm med}$ | ESS$_{\max}$ |
|:------------|:------------:|:---------------:|:-------------:|
| Metropolis  |      4.7     |     4.7         |     4.8       |
| NCG         |     58.5     |    58.9         |    59.6       |
| AVG         |     43.0     |    43.7         |    43.9       |
| V-DHAMS     |     73.9     |    75.1         |    76.1       |
| O-DHAMS     |     82.3     |    82.7         |    83.8       |
| V-PDHAMS    |    269.1     |   275.8         |   283.7       |
| O-PDHAMS    |    615.9     |   630.4         |   636.3       |

This ranking is typical of both discrete and continuous experiments and confirms the accelerated mixing due to the irreversibility and auxiliary momenta inherent to HAMS.

## 7. Extensions and Open Problems

The HAMS framework has prompted several extensions:
- **Quantum generalizations** leveraging weak measurement and boosted phase estimation overcome earlier technical roadblocks, but questions of tighter error analysis, optimal weak measurement scheduling, and rapid mixing for non-commuting Hamiltonians remain open [2406.16023].
- **Advanced preconditioned variants** for discrete targets (PDHAMS) show further mixing speedups and statistical efficiency by leveraging quadratic approximations [2507.21982].
- **Relationship to Langevin-based methods**: HAMS unifies and subsumes a broad class of reversible and irreversible Langevin integrators, providing a generalized approach to fast sampling—from classical to quantum, from continuous to discrete targets [2106.03012, 2507.09807].

Ongoing research addresses optimal proposal construction, error-controlled extrapolation in quantum energy estimation, efficient cluster-style moves for low acceptance regimes, and the development of problem-adaptive preconditioners.

---

**References:**
- [2005.08159] Hamiltonian Assisted Metropolis Sampling
- [2106.03012] On Irreversible Metropolis Sampling Related to Langevin Dynamics
- [2507.09807] Discrete Hamiltonian-Assisted Metropolis Sampling
- [2507.21982] Preconditioned Discrete-HAMS: A Second-order Irreversible Discrete Sampler
- [2111.14676] Metropolis-style random sampling of quantum gates for the estimation of low-energy observables
- [2406.16023] Quantum Metropolis Sampling via Weak Measurement

Source: https://www.emergentmind.com/topics/hamiltonian-assisted-metropolis-sampling-hams