blackjax.adaptation.adjusted_mclmc_adaptation#
Attributes#
Functions#
|
Finds the optimal value of the parameters for the MH-MCHMC algorithm. |
|
Adapts the stepsize and L of the MCLMC kernel. Designed for adjusted MCLMC |
|
determine L by the autocorrelations (around 10 effective samples are needed for this to be accurate) |
|
if there are nans, let's reduce the stepsize, and not update the state. The |
Module Contents#
- adjusted_mclmc_find_L_and_step_size(mclmc_kernel, logdensity_fn, num_steps, state, rng_key, target, frac_tune1=0.1, frac_tune2=0.1, frac_tune3=0.0, diagonal_preconditioning=True, params=None, max='avg', num_windows=1, tuning_factor=1.3, target_num_integration_steps=2.0)[source]#
Finds the optimal value of the parameters for the MH-MCHMC algorithm.
- Parameters:
mclmc_kernel – The kernel function used for the MCMC algorithm. Must have signature
(rng_key, state, logdensity_fn, step_size, inverse_mass_matrix, integration_steps_params) -> (state, info).logdensity_fn – The log-density function of the target distribution. Passed to
mclmc_kernelon every adaptation step.num_steps – The number of MCMC steps that will subsequently be run, after tuning.
state – The initial state of the MCMC algorithm.
rng_key – The random number generator key.
target – The target acceptance rate for the step size adaptation.
frac_tune1 – The fraction of tuning for the first step of the adaptation.
frac_tune2 – The fraction of tuning for the second step of the adaptation.
frac_tune3 – The fraction of tuning for the third step of the adaptation.
diagonal_preconditioning – Whether to do diagonal preconditioning (i.e. a mass matrix)
params – Initial params to start tuning from (optional)
max – whether to calculate L from maximum or average eigenvalue. Average is advised.
num_windows – how many iterations of the tuning are carried out
tuning_factor – multiplicative factor for L
target_num_integration_steps –
The average number of leapfrog integration steps per MH proposal. The step-size DA is calibrated AT this trajectory length (avg-preserving):
Lis pinned totarget_num_integration_steps * step_sizeat entry and tracked throughout adaptation, so the step is calibrated against the sameavgthat the dynamic kernel will use at sampling time. The finalLis enforced totarget_num_integration_steps * step_sizeas an invariant (a near-NO-OP on the main path; it also fixes any final_da step/L bookkeeping desync and covers the frac_tune3 > 0 edge path).Why this matters at high d: without avg-preserving calibration, the step is calibrated against
avg ≈ 1(the √dim reset collapsesL/stepto 1 before pass-2 DA). Running the dynamic kernel atavg = 2with a step sized foravg = 1doubles the energy error → acceptance collapses at high dimensionality (d=300: ≈0.22; d=500: ≈0.21 vs target 0.65). With avg-preserving calibration, the step is correctly sized for the operating trajectory length across all d.Robustness evidence: across 7 models × 2 IMM regimes × 3 seeds,
avg = 2has zero silent failures (inadequate cases fail loudly via R̂/divergences/acceptance collapse), delivers ≈2× ESS vsavg ≈ 1(MALA), and ties a per-model ESS/grad search. Longer trajectories (avg = 8) silently under-sample variance at equal budget.Default
2.0is the robust sweet spot. Values below1.1(the_AVG_FLOOR) are not reachable with avg-preserving calibration — the clamp forcesstep ≤ L / 1.1and the step converges to zero. To recover near-MALA behaviour, use a value like1.2(just above the floor);1.0is not a valid choice with the avg-preserving tuner.
- Return type:
A tuple containing the final state of the MCMC algorithm and the final hyperparameters.
- adjusted_mclmc_make_L_step_size_adaptation(kernel, logdensity_fn, dim, frac_tune1, frac_tune2, target, diagonal_preconditioning, fix_L_first_da=False, max='avg', tuning_factor=1.0, target_num_integration_steps=None)[source]#
Adapts the stepsize and L of the MCLMC kernel. Designed for adjusted MCLMC
- Parameters:
target_num_integration_steps – When provided, pass-1 uses
fix_L=True(stable: L anchored at the entry-pinned value so step cannot diverge) and pass-2 starts with a re-pinL = target_num_integration_steps * stepto guarantee avg = target at the start of the avg-preserving DA. WhenNonethe pre-2c behaviour is preserved (fix_L_first_dacontrols pass-1).