Self-tuning sampler: AdaptiveMALA (dual-averaging warmup + diagonal metric) - #51
Merged
Conversation
A MALA subclass that tunes its own step_size to the 0.574-optimal acceptance via Nesterov dual averaging (Hoffman & Gelman 2014), then freezes the averaged step and samples unbiasedly. precondition=True estimates a diagonal metric from a first warmup window and re-tunes ε under it (with a dual-averaging restart), so ill-conditioned targets mix at a far larger usable step while still targeting exactly p ∝ exp(-E). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Distribution tests on a correlated Gaussian (acceptance drives to 0.574 from a bad initial step, covariance recovered) and an ill-conditioned diag(25, 0.25) target (learned metric recovers the 100:1 ratio, per-axis std correct). Plus validation and zero-warmup passthrough (with return_trajectory) cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Example contrasts isotropic vs preconditioned AdaptiveMALA on a 100:1 ill-conditioned Gaussian (preconditioning lifts the usable step ~7×). README samplers row + examples list and the unreleased CHANGELOG updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AdaptiveMALA(MALA)— a MALA that removes thestep_sizesweep.What
ᾱ = mean min(1, e^{logα})to the MALA-optimal 0.574, then freezes the averagedεand samples unbiasedly. The passedstep_sizeis only a starting guess.precondition=True): estimates a per-coordinate metricM(geometric mean 1) from a first warmup window, then restarts dual averaging and re-tunesεunder it. The step and its noise rescale together (x ← x − εM∇E + √(2εM)ξ), so the chain still targets exactlyp ∝ exp(-E)— ill-conditioned targets mix at a much larger usable step.Validation (closed-form / distributional)
diag(25, 0.25)(condition number 100): learned metric ratio ≈ 100; per-axis std recovered; acceptance still on target.Notes
🤖 Generated with Claude Code