run_ns_multi_gpu¶
- jaxrens.sampling.nested_sampling.run_ns_multi_gpu(positions, types, energies, cells, init_fn, step_fn, rng_keys, n_gpu, n_per_gpu, n_walkers=None, max_iterations=10000, n_mcmc_steps=20, n_extra=0, n_cull=1, convergence_threshold=0.1, initial_step_size=0.1, target_acceptance=0.5, callbacks=None, termination_criteria=None, ensemble_params_per_run=None, per_move_fns=None, move_descriptors=None, adjust_interval=0, adjust_n_samples=50, adjust_max_rounds=15, adjust_factor=1.5, trial_batch_size=None, restart_states=None, inter_re_config=None, backend=None, max_neighbors_list=(30, 35, 40, 45, 50), max_neighbors_offset=5, max_neighbors_shrink_dwell=0, initial_max_neighbor_counts=None, batcher=None)[source]¶
Run NS with
shard_map(vmap(ns_step))dispatch across G GPUs × P runs each.Shape convention:
(G, P, ...)where G=n_gpu, P=n_per_gpu.- Parameters:
positions (Array) –
(G*P, n_walkers, n_atoms, 3)or(G, P, n_walkers, n_atoms, 3).types (Array) –
(n_atoms,)shared, or(G*P, n_walkers, n_atoms).energies (Array) –
(G*P, n_walkers)or(G, P, n_walkers).cells (Array | None) –
(G*P, n_walkers, 3, 3)/(G, P, n_walkers, 3, 3)or None.init_fn (Callable) – MCState constructor from
build_mwg().step_fn (Callable) – MCMC step function from
build_mwg().rng_keys (Array) –
(G*P,)or(G, P)per-run PRNG keys.n_gpu (int) – Number of GPU devices to use (G). Must satisfy
n_gpu >= 1andn_gpu <= len(jax.devices()).n_per_gpu (int) – Number of independent NS runs per GPU (P). Must be
>= 1.n_walkers (int | None) – Inferred from positions if None.
max_iterations (int) – Max NS iterations per run.
n_mcmc_steps (int) – MCMC steps per walker (static).
n_extra (int) – Extra walkers to walk per iteration (static).
n_cull (int) – Walkers culled per iteration (static).
convergence_threshold (float) – For
PriorMassTermination.initial_step_size (float) – Starting step size.
target_acceptance (float) – Kept for interface parity; unused directly.
callbacks (list[Any] | None) – List of callback objects with optional
on_iteration/on_finishmethods. Callbacks receive the(G, P, ...)-shapedNSStatedirectly. Eachinfodict containsinfo["_batcher"] = PmapVmapRuns(n_gpu, n_per_gpu)so callbacks can identify the batch shape viainfo["_batcher"].is_batched.log_evidencein the associatedNSStatehas shape(G, P).termination_criteria (list[TerminationCriterion] | None) – Optional. Defaults to
[IterationTermination(max_iterations), PriorMassTermination(n_walkers, convergence_threshold)].ensemble_params_per_run (list[dict] | None) – Flat list of
G*Pdicts, orNone.per_move_fns (list[Callable] | None) – Per-move step functions for bisection adaptation.
move_descriptors (list | None) –
MoveKerneldescriptors carrying rate bounds + max ss.adjust_interval (int) – Adapt every N iters. 0 = no adaptation.
adjust_n_samples (int) – Walkers sampled per bisection trial round (static).
adjust_max_rounds (int) – Max bisection rounds per adjust call (static).
adjust_factor (float) – Multiplicative bisection factor (static).
restart_states (list[list] | None) –
(G, P)nested list ofRestartBundle | None. PassNone(default) for a fresh start on all runs. Mixed restart (some checkpointed, some fresh) is supported within a single call.trial_batch_size (int | None)
max_neighbors_offset (int)
max_neighbors_shrink_dwell (int)
initial_max_neighbor_counts (Array | None)
batcher (PmapVmapRuns | None)
- Returns:
log_evidence,n_dead,iteration→(G, P);dead_energies→(G, P, max_dead);positions→(G, P, n_walkers, n_atoms, 3); etc.- Return type:
Dict with shapes
(G, P, ...)on all array fields- Raises:
ValueError – If
n_gpu < 1,n_per_gpu < 1, orn_gpu > len(jax.devices()).