jaxrens.sampling.bucket_manager

Neighbor-bucket ladder management shared by the NS loop and burn-in.

Both _run_loop (NS proper) and initial_walk (burn-in) advance MCMC state in steps that can overflow the per-walker neighbor budget configured via max_neighbors on the population. When that happens the outer Python loop has to:

  1. Roll back to the pre-step ns_state,

  2. Grow the bucket to the next ladder entry,

  3. Retry the same step (the JAX cache hands us the kernel compiled for the new bucket, or compiles it once on first hit).

Optionally — when shrink_dwell > 0 — the loop also tracks how long the observed neighbor peak has stayed below the next-smaller ladder entry (modulo the offset headroom) and steps the bucket back down once the dwell is satisfied. Temporal hysteresis via shrink_dwell and the offset slack already keep the bucket from thrashing at a boundary; no extra shrink-side margin is needed on top.

Both pickers (_pick_next_bucket / _pick_prev_bucket) and the BucketManager orchestrator live here; the two outer loops own only the Python control flow that decides when to call them.

Classes

BucketManager

Outer-loop helper that owns low_count and the picker calls.