jaxdem.analysis.engine#
JAX accumulation of pure pair kernels into analysis bins.
Precompute pair indices and bin identifiers on the host, vmap a pure kernel
over pairs, and reduce into bins with jax.ops.segment_sum.
Functions
Clear analysis-owned compiled-function references. |
|
|
Run a kernel over bins and average the results in JAX. |
Classes
|
Binned accumulation output. |
- jaxdem.analysis.engine.clear_jit_cache() None[source]#
Clear analysis-owned compiled-function references.
This does not clear JAX’s process-wide compilation caches.
- class jaxdem.analysis.engine.Binned(sums: Any, counts: Array, mean: Any, pairs: Pairs)#
Bases:
objectBinned accumulation output.
- Variables:
sums (Any) – pytree with each leaf shaped (B, …)
counts (jax.Array) – integer array shape (B,)
mean (Any) – pytree with each leaf shaped (B, …)
pairs (jaxdem.analysis.pairs.Pairs) – flattened pair representation used for the run (host arrays)
- sums: Any#
- counts: Array#
- mean: Any#
- jaxdem.analysis.engine.evaluate_binned(kernel: Any, arrays: Mapping[str, Any], binspec: BinSpec, *, kernel_kwargs: dict[str, Any] | None = None, jit: bool = True, chunk_size: int | None = None, max_pairs: int | None = None) Binned[source]#
Run a kernel over bins and average the results in JAX.
- Parameters:
kernel – pure function called as kernel(arrays, t0, t1, **kernel_kwargs).
arrays – mapping of field name -> array with leading time axis, e.g. pos: (T,N,d) or (T,S,N,d). At least one frame is required to infer kernel outputs, including for an empty pair selection.
binspec – bin specification built on the host. Defines which indices to use.
kernel_kwargs – extra keyword arguments for the kernel.
jit – whether to jit the core compute.
chunk_size – optional maximum number of pairs transferred to the device and evaluated per chunk. With the default None, one
jax.vmapcall processes all pairs. Set a positive integer to process pairs in chunks with repeated compiled calls. Chunking keeps peak device pair storage proportional to chunk_size. The returnedpairsarrays still retain one host index triple per pair.max_pairs – optional bound on the number of host pair-index triples. The default
Noneretains all pairs without a host-memory bound. The estimate is checked before allocation and the bound is also enforced while enumerating custom bin specifications.