MEADS sets, from the neighbouring fold: per-dimension scales σ^d; step size ϵ=min{1,0.5/λmax(−Hˉ)} with −Hˉ estimated by the gradient outer product; damping γ=max{1/(tϵ),1/λmax(Σ^)} and α=1−e−2ϵγ; and slice drift δ=α/2. Largest eigenvalues are estimated by the ratio tr(Σ2)/tr(Σ), computable in O(N2D) 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 σ^d from a fold’s states and multiply the neighbour fold’s per-dimension step size by σ^d. Subsequent formulas use transformed variables and gradients θˉd=θd/σ^d, gˉd=∇θdlogp(θ)σ^d.
4.2 Step size
Leapfrog stability on Gaussians
For a quadratic potential 21θ⊤Hθ (Gaussian target with covariance H−1) leapfrog stability requires ϵ≤2/λmax(H) (Leimkuhler and Reich 2004). The accuracy of uncorrected underdamped Langevin MCMC likewise needs ϵ∝1/λmax(−Hˉ) (Dalalyan and Riou-Durand 2020).
MEADS sets ϵ:=21λmax(−Hˉ)1, with Hˉ≜∫p(θ)∇2logp(θ)dθ the average Hessian (the 21 is a safety margin; Appendix A shows low sensitivity).
Hessian from gradients (eq. 4; proof in Appendix E)
−∫p(θ)∂θ∂θ⊤∂2logpdθ=∫p(θ)(∂θ∂logp)⊤∂θ∂logpdθ, 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 −H^=N1∑ngˉk,ngˉk,n⊤ from the N transformed gradients of fold k; no second derivatives needed.
4.3 Damping factor and slice drift
Momentum memory and damping
Ignoring leapfrog half-steps, mt+i≈(1−α)i/2mt+∑j=1iϵ∇logp(θt+j)+αξj with ξj∼N(0,I) (eq. 5): the influence of mt decays exponentially in i. We want to forget momentum once the chain has had time to traverse the highest-variance direction. On a Gaussian with covariance Σ leapfrog needs O(λmax(Σ)/ϵ) steps (in the paper’s notation; dimensionally this is the largest scale) to progress along the least-constrained direction, so choose −21log(1−α)∝ϵ/λmax, i.e. for small α
γ:=1/λmax(Σ^),α=1−e−2ϵγ(eq. 6).
Σ^ is the empirical covariance of the neighbour fold’s (preconditioned) states θˉ. Note. Algorithm 3 line 9 implements γ=1/MAX_EIG(θˉ), 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 γt≥1/(tϵt) early on: if the optimal damping would have the chain forget momentum after more than t steps and fewer than t 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 u stable long enough to travel far without rejecting, but not slower to mix than θ,m. Set δ:=α/2, giving u a period of 4/α steps, after which the decay factor (1−α)2/α≈e−2≈0.14: 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 λmax(Σ) (biased upward for small N).
Ratio estimator (eq. 7, Algorithm 2)
tr(Σ2)/tr(Σ)=∑dλd2/∑dλd. If all eigenvalues are 0 or λmax this equals λmax; it approximates λmax unless there are many “small-but-not-tiny” eigenvalues. For X∈RN×D with rows of covariance Σ: S=XX⊤; λ⋅=tr(S)/N; λ⋅2=N(N−1)1∑n=n′Sn,n′2; return λ⋅2/λ⋅. It uses E[Sn,n′2]=E[xn⊤xn′xn′⊤xn]=tr(E[X⊤X]2) for n=n′ (note E[X⊤X]=NΣ in the paper’s normalisation) and costs O(N2D), dominated by the N gradient evaluations in practice.
Algorithm 3 (MEADS), in words
Inputs: K folds of N initial states. Initialise u∼Uniform(−1,1), m∼N(0,I). For t=1..T, for each fold k=tmodK: estimate μ^,σ^ from fold (k−1)modK; standardise states and gradients (θˉ,gˉ); ϵt,k=min{1,0.5/max_eig(gˉ)}; γt,k=max{1/(tϵt,k),1/max_eig(θˉ)}; αt,k=1−e−2ϵt,kγt,k, δt,k=αt,k/2; run pers_ghmc with step sizes ϵt,kσ^t,k, damping αt,k, drift δt,k on fold k‘s chains.
Appendix C: behaviour of the estimator
N×D matrix X with Xn,d∼N(0,σd), D=100, four spectra each with maxσd2=1: identity; log-spaced σ from 0.1 to 1; linear-spaced from 0.1 to 1; bimodal (σd=0 for d≤D/2, 1 otherwise). Small N 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 N→∞ the ratio converges to ∑σd4/∑σd2, a bit below σmax2.
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 N=16,64,256,1024 while the naive top eigenvalue of X⊤X/N gave 3.24, 1.81, 1.22, 1.13 against a true λmax=1.
import numpy as npdef 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, jaxwarmup = 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