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_gpuGPUs.Sibling of
adjust_step_size(). Must be called inside ajax.shard_mapover the"shard"mesh axis (seeShardedSingleRun.wrap_for_batch()).Sampling strategy: each shard independently samples
n_sampleswalkers from its local(K_per_gpu, ...)slice. Effective trial-pool size is thereforeG * n_samplesper round — larger thanSingleRun(K=G*K_per_gpu)would use at the sameadjust_n_samplesconfig. Statistically valid (samples are independent across shards).Aggregation: per-shard accepted / reasons / eval counters are
lax.psum’d across the shard axis inside the bisectionlax.while_loopbody, before the rate-vs-window comparison. All shards see identicalrate→ identical_process_rate_jaxdecisions → identical updatedss→ 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 — seejaxrens.sampling.mesh).None(default) is for testing this function outside a mapped context. When set,cap_hits/floor_hitsare pre-cast to thevaryingVMA type viajax.lax.pcast. Unlikeadjust_step_size(), most carry entries here (rate_prev,converged,saw_too_high,saw_too_low) do not need this:rateislax.psum-reduced every round, so everything derived purely fromratestays the “reduced” VMA type and already matches its constant initial value. Onlycap_hits/floor_hitsalso depend onstep_sizeitself, which enters this function as a genuinely varying-typed value (it’s merely numerically identical across shards “by construction”, not collective-proven so) – seeexperiments/shard_map_rewrite.mdfor 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, ’’]]