---
title: Discrete Hamiltonian-Assisted Metropolis Sampling
url: https://www.emergentmind.com/topics/discrete-hams-dhams
type: topic
---

# Discrete Hamiltonian-Assisted Metropolis Sampling

Searching arXiv for recent and relevant papers on Discrete HAMS and closely related variants.
Discrete HAMS (DHAMS) is a gradient-based Markov chain Monte Carlo method for sampling discrete distributions that extends Hamiltonian-Assisted Metropolis Sampling (HAMS) to discrete state spaces by augmenting the target with a Gaussian momentum variable and sampling a Hamiltonian as an augmented distribution. In the formulation of "Discrete Hamiltonian-Assisted Metropolis Sampling" [2507.09807], the method is derived through an auxiliary-variable proposal scheme, negation and gradient correction for the momentum variable, and over-relaxation for the state variable. Two distinctive properties are achieved simultaneously: generalized detailed balance, which enables irreversible exploration of the target distribution, and a rejection-free property for a target distribution with a linear potential function [2507.09807].

## 1. Target distribution and Hamiltonian augmentation

DHAMS is defined for a discrete state \(x \in S \subset \mathbb{R}^d\), for example a \(d\)-dimensional lattice \(S=A^d\). The target mass function is written as
\[
\pi(x)\propto \exp(f(x)),
\]
with negative potential
\[
U(x)=-f(x),
\]
so that
\[
\pi(x)\propto \exp(-U(x)).
\]
A \(d\)-dimensional momentum \(p\in\mathbb{R}^d\) with standard Gaussian marginal is then introduced, yielding the joint augmented density
\[
\pi(x,p)\propto \exp\!\left(f(x)-\tfrac12\|p\|^2\right)=\exp(-H(x,p)),
\]
with Hamiltonian
\[
H(x,p)=U(x)+\tfrac12\|p\|^2.
\]
This augmentation is the discrete analogue of the continuous HAMS construction, where the target density on \(x\in\mathbb{R}^d\) is augmented by a momentum variable and an acceptance-rejection scheme is formulated to achieve generalized reversibility [2106.03012].

The Hamiltonian augmentation is not a formal analogy only. It provides the state space on which DHAMS defines its proposal, acceptance rule, and nonreversible exploration mechanism. The role of the Gaussian momentum is explicit in the abstract of [2507.09807]: DHAMS not only exploits gradient information but also incorporates a Gaussian momentum variable and samples a Hamiltonian as an augmented distribution.

## 2. Proposal mechanism and algorithmic structure

The paper "Discrete Hamiltonian-Assisted Metropolis Sampling" [2507.09807] describes the over-relaxed variant, O-DHAMS, as follows. Given \((x_t,p_t)\), an intermediate momentum is generated by auto-regression:
\[
p_{t+\frac12}=\epsilon\,p_t+\sqrt{1-\epsilon^2}\,\xi,\qquad \xi\sim N(0,I),\qquad \epsilon\in[0,1).
\]
An auxiliary variable is then defined by
\[
z_t=x_t-\delta\,p_{t+\frac12},\qquad \delta>0.
\]

Conditional on \((x_t,p_{t+\frac12})\), the target is approximated at \(x_t\) by the first-order Taylor expansion
\[
f(x)\approx f(x_t)+\nabla f(x_t)^\mathsf{T}(x-x_t).
\]
This gives the factorized proposal for \(x^*\):
\[
Q(x^*|z_t;x_t)\propto
\exp\!\left(\nabla f(x_t)^\mathsf{T}(x^*-x_t)-\frac{\|z_t-x^*\|^2}{2\delta^2}\right),
\]
which further factorizes over the \(d\) coordinates and is easily sampled.

After drawing \(x^*\), the momentum is updated in two stages. First,
\[
p^{*(0)}=-p_{t+\frac12}+\frac{x_t-x^*}{\delta}.
\]
Then a gradient-correction term, described as analogous to a single leapfrog update, is added:
\[
p^*=p^{*(0)}+\phi\,[\nabla f(x^*)-\nabla f(x_t)],\qquad \phi\ge 0.
\]

O-DHAMS does not sample \(x^*\) independently from \(Q(\cdot|z_t;x_t)\). Instead it applies a discrete over-relaxation kernel with reference \(Q(\cdot|z_t;x_t)\). For each coordinate \(i=1,\dots,d\), let \(F_i\) be the CDF of the univariate reference \(Q_i(\cdot|z_t,x_t)\); draw
\[
w_i\sim \mathrm{Uniform}[F_i(x_{t,i}^{-}),F_i(x_{t,i})),
\qquad
\eta_i\sim \mathrm{Uniform}[0,1),
\]
set
\[
w_i'=(( -w_i+\beta\,\eta_i)\bmod 1),
\]
and then define
\[
x_i^*=F_i^{-1}(w_i').
\]
The parameter \(\beta\in[-1,1]\) tunes the degree of over-relaxation, and Vanilla DHAMS (V-DHAMS) arises by setting the over-relaxation parameter \(\beta=\pm 1\) [2507.09807].

## 3. Acceptance rule, generalized detailed balance, and rejection-free cases

DHAMS composes auto-regression, over-relaxation on \(x\), momentum negation, and gradient correction into a joint proposal kernel \(K\). The proposal is accepted with probability
\[
\alpha=
\min\!\left\{
1,\,
\frac{\pi(x^*,-p^*)\,Q(x_t,-p_{t+\frac12}|x^*,-p^*)}
{\pi(x_t,p_{t+\frac12})\,Q(x^*,p^*|x_t,p_{t+\frac12})}
\right\},
\]
and otherwise the chain rejects and sets
\[
(x_{t+1},p_{t+1})=(x_t,-p_{t+\frac12}).
\]
With this momentum-negation Metropolis step, the chain satisfies the generalized detailed balance relation
\[
\pi(x_t,p_{t+\frac12})\,K(x_{t+1},p_{t+1}|x_t,p_{t+\frac12})
=
\pi(x_{t+1},-p_{t+1})\,K(x_t,-p_{t+\frac12}|x_{t+1},-p_{t+1}),
\]
which implies stationarity of \(\pi(x,p)\) [2507.09807].

The theoretical guarantees stated for DHAMS include ergodicity and irreversibility. Auto-regression with \(\epsilon<1\) ensures the \(p\)-marginal remains Gaussian and the chain is aperiodic/span-connected in \(x\). Momentum negation produces non-zero net circulation in state space, accelerating exploration [2507.09807]. In the terminology of the paper, Discrete-HAMS leverages both momentum and over-relaxation to suppress random-walk behavior.

A notable exact case is the linear-potential regime. If
\[
U(x)=-a^\mathsf{T}x,
\]
then \(\nabla f(x)=a\) is constant and the gradient correction vanishes. The paper states that one checks algebraically that the Metropolis ratio reduces to \(1\) for every proposal, so \(\alpha\equiv 1\) and the chain is rejection-free [2507.09807]. This rejection-free result is one of the two distinctive properties emphasized in the abstract.

## 4. Relation to HAMS and second-order extensions

DHAMS is explicitly motivated by HAMS. In the continuous setting, HAMS uses an augmented target density similarly as in HMC, but involves a flexible proposal scheme and a carefully formulated acceptance-rejection scheme to achieve generalized reversibility [2106.03012]. The continuous theory also shows that, as the step size tends to \(0\), the HAMS proposal satisfies a class of stochastic differential equations including Langevin dynamics as a special case, and that various relatively recent algorithms for Langevin dynamics fall in the class of HAMS proposals up to negligible differences [2106.03012]. Within this lineage, DHAMS is presented as a discrete sampler which, for the first time, not only exploits gradient information but also incorporates a Gaussian momentum variable and samples a Hamiltonian as an augmented distribution [2507.09807].

A second-order extension, Preconditioned Discrete-HAMS (PDHAMS), modifies the first-order Taylor approximation used by DHAMS. The PDHAMS paper states that first-order DHAMS uses only
\[
f(s)\approx f(s_t)+\nabla f(s_t)^T(s-s_t),
\]
which treats each coordinate independently and neglects curvature interactions in \(f\). PDHAMS instead incorporates a second-order, quadratic approximation of the potential function and uses Gaussian integral trick to avoid directly sampling a pairwise Markov random field [2507.21982]. In this construction, the surrogate
\[
f(s)\approx f(s_t)+\nabla f(s_t)^T(s-s_t)+\tfrac12(s-s_t)^T W (s-s_t)
\]
injects curvature information via \(W\), and both vanilla and over-relaxed PDHAMS satisfy generalized detailed balance. The paper further states a stronger exactness result than first-order DHAMS: PDHAMS is rejection-free for a target distribution with a quadratic potential function [2507.21982].

This suggests a natural taxonomy within the discrete HAMS family: first-order DHAMS achieves rejection-free sampling under linear potential, whereas second-order PDHAMS achieves rejection-free sampling under quadratic potential. That implication follows directly from the exact regimes stated in [2507.09807] and [2507.21982].

## 5. Empirical behavior and comparative performance

The empirical evaluation reported for DHAMS covers both ordinal and binary distributions. For a discrete Gaussian with ordinal state and \(d=8\), O-DHAMS and V-DHAMS achieve faster TV-convergence on 2D/4D marginals, smaller bias/variance in moment estimates, and ESS improvements of \(20\)–\(50\%\) over NCG/AVG [2507.09807]. For a quadratic mixture described as multi-modal, the reported ranking is
\[
\text{O-DHAMS}>\text{V-DHAMS}\gg \text{NCG}>\text{AVG}>\text{MH}>\text{GWG}
\]
in both TV and ESS metrics. For Bayesian sparse regression with binary mask and \(d=1200\), Discrete-HAMS samplers mix more rapidly between competing models, with higher flip rates and lower ACF, and yield tighter posterior-inclusion-probability estimates [2507.09807].

The PDHAMS study places first-order DHAMS in a broader comparison against second-order methods. It reports three benchmarks—an 8-dimensional discrete Gaussian, a 10-dimensional nine-component quadratic mixture, and a \(20\times 20\), \(q=7\) clock-Potts model—against NCG, AVG, DHAMS, and PAVG [2507.21982]. The qualitative ranking given there is that TV-distance to true marginals shrinks fastest for O-PDHAMS, then V-PDHAMS, then PAVG, then DHAMS variants, then NCG/AVG, then naïve Metropolis; ESS values are highest for O-PDHAMS, then V-PDHAMS, then PAVG; and trace plots and autocorrelation-function plots confirm dramatically reduced lag-1 and longer-lag correlations under PDHAMS [2507.21982].

Taken together, these experiments place DHAMS as a strong first-order nonreversible discrete sampler and position over-relaxation as a practically important component. The ranking O-DHAMS \(>\) V-DHAMS in the reported first-order experiments indicates that the over-relaxed kernel is not merely a formal variant but a consequential design choice [2507.09807].

## 6. Nomenclature, neighboring literatures, and common ambiguities

The acronym "DHAMS" is not unique across mathematical and computational literatures. In discrete variational analysis, "Continuous versus discrete structures II -- Discrete Hamiltonian systems and Helmholtz conditions" defines discrete Hamiltonian systems in the framework of discrete embeddings, with \(\Delta\)–\(\nabla\) equations
\[
\Delta Q_k=\frac{\partial H}{\partial P}(Q_k,P_k),
\qquad
\nabla P_k=-\frac{\partial H}{\partial Q}(Q_k,P_k),
\]
and develops discrete Helmholtz conditions for deciding when a first-order difference system is Hamiltonian [1501.03203]. In integrable systems, "Discrete Hamiltonians of discrete Painlevé equations" expresses discrete Painlevé equations as discrete Hamiltonian systems, where the discrete Hamiltonian systems mean the canonical transformations defined by generating functions, and the discrete Hamiltonians are written in the logarithm and dilogarithm functions [2001.02535]. These usages concern discrete Hamiltonian structure, not Hamiltonian-assisted Metropolis sampling.

A separate nearby acronym is "DHAMs" for discrete hard attention mechanisms. In "QAHAN: A Quantum Annealing Hard Attention Network," hard attention is formulated as a QUBO and mapped to an Ising Hamiltonian for quantum annealing, with applications to MNIST and CIFAR-10 [2412.20930]. Despite the shared use of discrete state variables, Hamiltonians, and augmented optimization or sampling procedures, that line of work is about attention selection rather than MCMC.

This suggests that the topic "Discrete HAMS (DHAMS)" is most precisely identified by its full expansion, Discrete Hamiltonian-Assisted Metropolis Sampling. In current usage represented by [2507.09807] and [2507.21982], it denotes a family of gradient-based MCMC algorithms for discrete distributions that combine auxiliary-variable proposals, momentum updates, gradient corrections, and momentum-negation Metropolis steps under generalized detailed balance.

Source: https://www.emergentmind.com/topics/discrete-hams-dhams