adjust_step_size_sharded

jaxrens.sampling.adaptation.stepsize_handler.adjust_step_size_sharded(population, move_fn, step_size, emax, rng_key, n_samples, min_rate, max_rate, adjust_factor, max_step_size, max_rounds, *, trial_batch_size=None, axis_name=None)[source]

Adjust step size with the population sharded across n_gpu GPUs.

Sibling of adjust_step_size(). Must be called inside a jax.shard_map over the "shard" mesh axis (see ShardedSingleRun.wrap_for_batch()).

Sampling strategy: each shard independently samples n_samples walkers from its local (K_per_gpu, ...) slice. Effective trial-pool size is therefore G * n_samples per round — larger than SingleRun(K=G*K_per_gpu) would use at the same adjust_n_samples config. Statistically valid (samples are independent across shards).

Aggregation: per-shard accepted / reasons / eval counters are lax.psum’d across the shard axis inside the bisection lax.while_loop body, before the rate-vs-window comparison. All shards see identical rate → identical _process_rate_jax decisions → identical updated ss → bisection paths stay coherent across shards.

Returns (final_ss, final_rate, final_counts, n_rounds, converged, cap_hits, floor_hits, bracket_detected, trial_n_evals, trial_n_grad_evals) — values are identical on every shard.

Parameters:
  • axis_name (str | None) – Mesh axis name to run under ("shard" in production — see jaxrens.sampling.mesh). None (default) is for testing this function outside a mapped context. When set, cap_hits/floor_hits are pre-cast to the varying VMA type via jax.lax.pcast. Unlike adjust_step_size(), most carry entries here (rate_prev, converged, saw_too_high, saw_too_low) do not need this: rate is lax.psum-reduced every round, so everything derived purely from rate stays the “reduced” VMA type and already matches its constant initial value. Only cap_hits/ floor_hits also depend on step_size itself, which enters this function as a genuinely varying-typed value (it’s merely numerically identical across shards “by construction”, not collective-proven so) – see experiments/shard_map_rewrite.md for the distinction.

  • population (Any)

  • move_fn (Callable)

  • step_size (Float[jaxlib._jax.Array, ''])

  • emax (Float[jaxlib._jax.Array, ''])

  • rng_key (Key[jaxlib._jax.Array, ''])

  • n_samples (int)

  • min_rate (float)

  • max_rate (float)

  • adjust_factor (float)

  • max_step_size (float)

  • max_rounds (int)

  • trial_batch_size (int | None)

Return type:

tuple[Float[jaxlib._jax.Array, ’’], Float[jaxlib._jax.Array, ’’], Int[jaxlib._jax.Array, ’4’], Int[jaxlib._jax.Array, ’’], Bool[jaxlib._jax.Array, ’’], Int[jaxlib._jax.Array, ’’], Int[jaxlib._jax.Array, ’’], Bool[jaxlib._jax.Array, ’’], Int[jaxlib._jax.Array, ’’], Int[jaxlib._jax.Array, ’’]]