Hoffman 2022 - GHMC and Neal Persistent Slice Sampling

Summary

GHMC partially refreshes the momentum every iteration, , takes one leapfrog step and negates momentum on rejection. It tends to underdamped Langevin dynamics for small , but suffers a “gauntlet of rejections” that forces tiny steps. Neal’s (2020) persistent slice scheme keeps a slice variable that drifts non-reversibly as a triangle wave so rejections cluster in time, which makes GHMC competitive.

Overview

Notation: target unnormalised on ; momentum with ; potential , kinetic .

Main Content

HMC proposal and leapfrog (Sec. 2.1)

With per-dimension step sizes the leapfrog integrator is: ; ; (Algorithm 1, function leapfrog). Reject a proposal with probability . Per-dimension step sizes are equivalent to a diagonal mass matrix or to rescaling (Neal 2011).

Generalized HMC (Horowitz 1991), eq. 1 and following text

Each iteration: (1) partially update momentum with . This leaves invariant, since it adds variance to variance . (2) Propose by one or more leapfrog steps followed by momentum negation and accept with the usual Metropolis ratio. (3) Unconditionally negate the momentum: after an accepted move this undoes the earlier negation; after a rejection it makes the chain “bounce” and reverse, preventing the chain from undoing progress. With this is ordinary one-step HMC. In the limit of small with one leapfrog step per iteration all proposals are accepted and the dynamics simulate underdamped Langevin

(The relation follows from matching with ; consistent with the paper’s later .)

The rejection gauntlet (eq. 2)

Suppose HMC and GHMC both need leapfrog steps without a rejection to make optimal progress, with energy after steps. GHMC accepts every step independently, so

GHMC pays each time energy increases even if later offset, whereas HMC is robust to fluctuations around a stable mean. Symplectic integrators produce stable fluctuations rather than accumulating error, so HMC enjoys them; GHMC must use a much smaller step size to avoid random-walk behaviour from rejections.

Persistent slice-sampling GHMC (Neal 2020), Algorithm 1

Augment with a slice variable so . Hold fixed: propose and accept iff . If is resampled each step this is ordinary GHMC; if is held for steps then all steps are accepted as long as energy never rises by more than , so accept/reject decisions cluster in time. Work with the reparameterised and update it non-reversibly: in the absence of energy fluctuations traces a triangle wave of frequency set by . pers_ghmc: sample ; set ; . If return ; else return .

Why tuning is hard (end of Sec. 2.2). In HMC, targets an acceptance rate, but with small GHMC may need a much higher nominal acceptance rate and the persistent scheme complicates its interpretation; NUTS/ChEES use ESJD against a reference state at the start of a trajectory, with no analogue in GHMC; and the drift has no HMC counterpart.

# Persistent-MH GHMC step for a batch of chains (numpy, tested on N(0, diag(1, .5, 2)^2): sd recovered to ~2%)
import numpy as np
rng = np.random.default_rng(1)
def pers_ghmc(th, m, u, eps, alpha, delta, logp, grad):
    mt = m*np.sqrt(1-alpha) + np.sqrt(alpha)*rng.normal(size=m.shape)
    ut = ((u + 1 + delta) % 2) - 1
    m1 = mt + 0.5*eps*grad(th); th1 = th + eps*m1; m2 = m1 + 0.5*eps*grad(th1)
    lr = logp(th1) - 0.5*np.sum(m2**2, -1) - logp(th) + 0.5*np.sum(mt**2, -1)
    ok = np.abs(ut) <= np.exp(np.minimum(lr, 0))
    ratio = np.exp(np.clip(lr, -50, 50))
    return (np.where(ok[:, None], th1, th),
            np.where(ok[:, None], m2, -mt),
            np.where(ok, ut*ratio, ut))

Examples

With , , on a 3-D Gaussian with , 2000 chains for 2000 iterations gave empirical standard deviations against truth : GHMC with the persistent slice update leaves the target invariant (this was run in numpy as a check).

Connections

Hoffman 2022 - Ensemble-Chain Adaptation and Parallelism explains how to tune from other chains; Hoffman 2022 - MEADS Heuristics - Step Size, Damping, Drift and Eigenvalue Estimation gives the heuristics. Neal (2020) also interleaves GHMC with Gibbs updates for discrete latents, relevant to Marginalising Discrete Latents - Why NUTS Cannot Sample Discrete Parameters. Background: Efficient MCMC.

See Also

Hoffman 2022 - MEADS - Overview, Hoffman 2021 - HMC Background and the GPU Problem for NUTS