jaxrens.sampling.batch_descriptor¶
Execution-topology descriptors for the NS outer loop.
Four execution topologies exist — SingleRun, VmapRuns,
PmapVmapRuns, ShardedSingleRun — encapsulating the shape/RNG/
reduction bookkeeping so _run_loop (run_loop.py) and its callbacks
can share one orchestration body without per-topology isinstance
branching for most concerns:
wrap_step — JIT-compiles (and vmaps/shard_maps as appropriate) the NS step.
split_keys — Splits a PRNG key appropriately for the batch shape.
reduce_for_termination — Reduces batched scalars to a single scalar for
PriorMassTermination/IterationTermination.
BatchDescriptor (bottom of this module) is the SingleRun | VmapRuns |
PmapVmapRuns | ShardedSingleRun type used to annotate “any of the four” —
not a base class. SingleRun, VmapRuns, and PmapVmapRuns share a
concrete (non-abstract) base, _UniformBatcher, because they genuinely
share behavior: each satisfies n_runs == prod(shape_prefix) and treats
its leading shape axes as independent-replica axes. ShardedSingleRun
does not inherit from it — its shape_prefix = (n_gpu,) is a
sharding axis, not a replica axis (n_runs is always 1), so several of
_UniformBatcher’s methods don’t apply to it as written (see its own
docstring). Rather than force it to override most of a shared contract to
fit a hierarchy whose invariants it breaks, it stands alone with its own
implementations — some duplicated from _UniformBatcher where the
generic, shape_prefix-driven logic happens to still be correct for it.
Module Attributes
Any of the four execution topologies (a type alias, not a base class). |
Functions
Return the batcher whose |
Classes
Descriptor for |
|
Descriptor for a single NS run sharded across |
|
Descriptor for a single NS run (no batching). |
|
Descriptor for n_runs independent NS runs batched via |