Hoffman 2022 - MEADS Heuristics - Step Size, Damping, Drift and Eigenvalue Estimation

Summary

MEADS sets, from the neighbouring fold: per-dimension scales ; step size with estimated by the gradient outer product; damping and ; and slice drift . Largest eigenvalues are estimated by the ratio , computable in without an eigendecomposition.

Overview

GHMC (via persistent slice sampling) has four tunable pieces: diagonal preconditioner, , , . All are derived below from statistics of one fold, used for the neighbouring fold (see Hoffman 2022 - Ensemble-Chain Adaptation and Parallelism).

Main Content

4.1 Diagonal preconditioning

Estimate marginal standard deviations from a fold’s states and multiply the neighbour fold’s per-dimension step size by . Subsequent formulas use transformed variables and gradients , .

4.2 Step size

Leapfrog stability on Gaussians

For a quadratic potential (Gaussian target with covariance ) leapfrog stability requires (Leimkuhler and Reich 2004). The accuracy of uncorrected underdamped Langevin MCMC likewise needs (Dalalyan and Riou-Durand 2020). MEADS sets , with the average Hessian (the is a safety margin; Appendix A shows low sensitivity).

Hessian from gradients (eq. 4; proof in Appendix E)

, i.e. the expected negative Hessian equals the expected outer product of the score (the Fisher-information identity applied to the log-density), under mild conditions. Hence from the transformed gradients of fold ; no second derivatives needed.

4.3 Damping factor and slice drift

Momentum memory and damping

Ignoring leapfrog half-steps, with (eq. 5): the influence of decays exponentially in . We want to forget momentum once the chain has had time to traverse the highest-variance direction. On a Gaussian with covariance leapfrog needs steps (in the paper’s notation; dimensionally this is the largest scale) to progress along the least-constrained direction, so choose , i.e. for small

is the empirical covariance of the neighbour fold’s (preconditioned) states . Note. Algorithm 3 line 9 implements , i.e. the inverse of the largest scale rather than of the largest variance; eq. 6 as typeset omits the square root, so follow Algorithm 3.

Early-iteration damping floor

For stability enforce early on: if the optimal damping would have the chain forget momentum after more than steps and fewer than steps have elapsed, the covariance estimate is not yet trustworthy because chains arrive at the typical set at different rates; those differences must be damped away before a very small damping factor is safe.

Slice drift

Want stable long enough to travel far without rejecting, but not slower to mix than . Set , giving a period of steps, after which the decay factor : the previous period’s momentum has mostly been forgotten.

4.4 Largest eigenvalue estimation

The largest eigenvalue of an unbiased estimate can be a highly biased estimate of (biased upward for small ).

Ratio estimator (eq. 7, Algorithm 2)

. If all eigenvalues are 0 or this equals ; it approximates unless there are many “small-but-not-tiny” eigenvalues. For with rows of covariance : ; ; ; return . It uses for (note in the paper’s normalisation) and costs , dominated by the gradient evaluations in practice.

Algorithm 3 (MEADS), in words

Inputs: folds of initial states. Initialise , . For , for each fold : estimate from fold ; standardise states and gradients (); ; ; , ; run pers_ghmc with step sizes , damping , drift on fold ‘s chains.

Appendix C: behaviour of the estimator

matrix with , , four spectra each with : identity; log-spaced from 0.1 to 1; linear-spaced from 0.1 to 1; bimodal ( for , otherwise). Small biases both the naive top eigenvalue and the ratio upward but the ratio’s bias decays faster. The price is a small asymptotic bias for the log- and linear-spaced spectra: as the ratio converges to , a bit below .

Asymptotes and a small-sample check (numpy)

Computed asymptotes: identity 1.000; log-spaced 0.517; linear-spaced 0.606; bimodal 1.000. For the log-spaced spectrum the ratio estimator gave 0.45, 0.53, 0.50, 0.52 at while the naive top eigenvalue of gave 3.24, 1.81, 1.22, 1.13 against a true .

import numpy as np
def max_eig(X):                 # Algorithm 2; X is (N, D)
    N = X.shape[0]; S = X @ X.T
    lam1 = np.trace(S)/N
    off = S**2; np.fill_diagonal(off, 0.0)
    return (off.sum()/(N*(N-1))) / lam1

Examples (PyMC-style)

Untested sketch for E86 using blackjax’s MEADS adaptation (names may differ by version):

import blackjax, jax
warmup = blackjax.meads_adaptation(logdensity_fn, num_chains=128)
(last_states, parameters), _ = warmup.run(jax.random.key(0), initial_positions, num_steps=2000)
# parameters hold per-chain step_size, momentum_inverse_scale, alpha, delta for the GHMC kernel

Connections

Hoffman 2022 - MEADS - Experiments and Ablations evaluates this recipe; Hoffman 2022 - Appendix - Hogwild Counterexample and Hessian Identity Proof proves eq. 4. Compare with ChEES’s trajectory-length adaptation in Hoffman 2021 - ChEES Criterion and Algorithm 1.

See Also

Hoffman 2022 - MEADS - Overview, Hoffman 2022 - GHMC and Neal Persistent Slice Sampling