integrate_rejection_jax

JAX backend for rejection-sampling likelihood evaluation. Selected with REJECTION_BACKEND (see Rejection Sampling).

JAX backend for integrate_rejection likelihood calculations.

All computation — likelihood evaluation AND post-processing (temperature estimation, weighted sampling, evidence, CHI2) — is performed on-device. Only the tiny final arrays are transferred back to the host:

Old: (bsz, N) likelihood matrix → ~256 MB per batch (N=1 M, bsz=64) New: i_use + scalars → ~52 KB per batch (~5000× less)

This eliminates the PCIe bottleneck that made the old GPU path ~49× slower than CPU despite the faster kernel.

Usage

from integrate.integrate_rejection_jax import integrate_rejection_range_jax # or via integrate_rejection(backend=’jax’, …)

integrate.integrate_rejection_jax.integrate_rejection_range_jax(D, DATA, idx=[], N_use=None, id_use=[], ip_range=[], nr=1000, autoT=1, T_base=1, T_N_above=10, T_P_acc_level=0.2, progress_callback=None, Nbatch=64, **kwargs)

GPU-efficient JAX replacement for integrate_rejection_range.

Likelihood computation and all post-processing (temperature estimation, weighted sampling, evidence, CHI2) run on-device. Only the tiny final arrays are transferred back to the host per batch:

i_use (bsz × nr) ≈ 51 KB [was 256 MB for the likelihood matrix] T, EV, N_UNIQUE ≈ 1 KB CHI2 (bsz × Ndt) ≈ 1 KB

Full-covariance Gaussian and multinomial noise models fall back to the original NumPy implementations (their likelihoods are converted to JAX arrays once per batch before the on-device post-processing step).

Parameters:
  • D (list of ndarray — forward-modeled data per data type)

  • DATA (dict — observed data (same format as load_data))

  • idx (list — prior sample indices (empty = sequential))

  • N_use (int or None — max prior samples to evaluate)

  • id_use (list — data-type identifiers to include)

  • ip_range (list — data-point indices to invert)

  • nr (int — posterior samples per data point)

  • autoT (int — 1 = auto temperature, 0 = use T_base)

  • T_base (float — base temperature when autoT=0)

  • T_N_above (int — passed to logl_T_est (top-k for T est.))

  • T_P_acc_level (float — passed to logl_T_est (target P_acc))

  • progress_callback (callable — optional (current, total) callback)

  • Nbatch (int — data points per JAX batch (default 64))

  • **kwargs (use_N_best, showInfo, console_progress, useRandomData,) – normalize_likelihood (bool, default True — include the full Gaussian normalization constant; inert for P_acc/T/EV weighting, CHI2 is de-normalized back out), …

Returns:

  • Same 8-tuple as integrate_rejection_range

  • (i_use_all, T_all, EV_all, EV_post_all, EV_post_all_mean, – CHI2_all, N_UNIQUE_all, ip_range)