Skip to content

Self-tuning sampler: AdaptiveMALA (dual-averaging warmup + diagonal metric) - #51

Merged
davidkhjo merged 3 commits into
mainfrom
adaptive-samplers
Aug 20, 2026
Merged

Self-tuning sampler: AdaptiveMALA (dual-averaging warmup + diagonal metric)#51
davidkhjo merged 3 commits into
mainfrom
adaptive-samplers

Conversation

@davidkhjo

Copy link
Copy Markdown
Owner

AdaptiveMALA(MALA) — a MALA that removes the step_size sweep.

What

  • Dual-averaging warmup (Nesterov, Hoffman & Gelman 2014): drives the smooth acceptance probability ᾱ = mean min(1, e^{logα}) to the MALA-optimal 0.574, then freezes the averaged ε and samples unbiasedly. The passed step_size is only a starting guess.
  • Optional diagonal metric (precondition=True): estimates a per-coordinate metric M (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 exactly p ∝ exp(-E) — ill-conditioned targets mix at a much larger usable step.

Validation (closed-form / distributional)

  • Correlated Gaussian: acceptance → 0.574 from a 9×-wrong initial step; covariance recovered.
  • diag(25, 0.25) (condition number 100): learned metric ratio ≈ 100; per-axis std recovered; acceptance still on target.

Notes

  • NUTS is intentionally deferred to a follow-up. A correct batched NUTS needs per-chain data-dependent termination that's easy to get subtly (silently) biased; shipping that would betray the library's correctness-first stance. AdaptiveMALA already delivers the "self-tuning samplers" goal. The verified NUTS reference spec is preserved for a later PR.
  • torch-only; public API preserved; accumulates under the unreleased 0.15.0 (no version bump).

🤖 Generated with Claude Code

davidkhjo and others added 3 commits August 20, 2026 16:33
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>
@davidkhjo
davidkhjo merged commit 61d398b into main Aug 20, 2026
5 checks passed
@davidkhjo davidkhjo mentioned this pull request Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant