Skip to content

Releases

v1.0.0

Choose a tag to compare

@github-actions github-actions released this 29 Nov 03:46

21cmCU v1.0.0

Documentation, Wiki & Discovery Metadata

Hardened Inference, Samplers & Audit Correctness

  • Added -fno-finite-math-only alongside -ffast-math in build_cffi.py and finite guards in inference_samplers.c so non-finite -inf / NaN log-likelihoods never collapse Skilling quadrature to NaN, and fixed p21_mcmc_split_rhat / p21_mcmc_iat to report inf/nan instead of 1.0 on zero within-chain variance.
  • Fixed NativeNestedSampler to bulk-evict equal-likelihood plateaus (both -inf and finite constant floors) via variable-$n_{\mathrm{live}}$ Skilling quadrature without shrinking prior volume during plateau replenishment, and validated config fingerprints plus likelihood re-evaluation probes before honoring resume=True checkpoints in both NativeNestedSampler and NativeEnsembleMCMC.
  • Updated NativeEnsembleMCMC to scale ess by N_samples / max(IAT) and mark zero-acceptance / zero-variance stuck chains with diagnostics_ok=False and ess=0.0.
  • Fixed Likelihood21cm cov_inv missing-bin marginalization to use a scale-invariant relative tolerance instead of np.allclose(..., atol=1e-8), matching covariance when precision matrix entries are small (~1e-9).
  • Fixed Likelihood21cm so model_error_frac > 0 includes exact Gaussian normalization (-sum log sigma / -0.5 log det Sigma_eff) and simulate() / simulate_batch() resolve identical default out_redshift in coeval mode.
  • Fixed audit_posterior_native and PosteriorAuditResult to evaluate errors against fixed required observation bins and record explicit n_failed_draws / failure_rate / bin_failure_rate (returning NaN summary errors instead of zero on failed draws).

Dynamic-dlopen NCCL 2.x Collective Backend & Distributed API (Phase 16)

  • Added src/py21cmfast/src/cuda/cuda_nccl.cuh loading libnccl.so.2 ($\ge 2.7$) dynamically via dlopen/dlsym (P21_NCCL_LIB, RTLD_DEFAULT) with zero compile-time libnccl dependency.
  • Integrated intra-process clique caching and P21_CUDA_MGPU_BACKEND=auto|nccl|p2p|host into cuda_mgpu.cu and cuda_runtime.cu, adding 7 C/CFFI collective symbols (p21_cuda_nccl_available, version, get_unique_id, comm_init_rank, comm_destroy, alltoall_f32, allreduce_f64; 90 CUDA APIs / 54 CFFI exports).
  • Added src/py21cmcu/distributed.py (NcclContext, nccl_available, nccl_version, nccl_unique_id, nccl_alltoall_f32, nccl_allreduce_f64, distributed_batch_partition, reduce_fisher_results), top-level exports, doctor() diagnostics, and tests/native/test_21cmcu_phase16_nccl_v100.py.

256³–1024³ Multi-Probe Benchmark & Paper Finalization

Bug Fixes

  • Fixed degenerate Fisher matrices in src/py21cmcu/fisher.py reporting spurious finite marginalized uncertainties from pinv; unconstrained eigenvectors now yield sigma_marginalized = inf, cov diagonal inf, fom = 0.0, and explicit degeneracy metadata, and fixed 1D Fisher auto-noise conversion to evaluate sigma_delta_sq at the exact unweighted power_spectrum_1d bin centers k.
  • Fixed weighted galaxy shot noise subtraction in cross_power_21cm_galaxy to use $V \sum w_i^2 / (\sum w_i)^2$ for both Mapping["masses"] and explicit weights catalogs.
  • Fixed Likelihood21cm to fix the observed-data mask at construction time, return -inf whenever any required observed bin evaluates to non-finite in the model, properly marginalize/slice missing data bins on cov_inv (Schur complement) and covariance (sub-block inversion), and apply apply_wedge_filter_3d in mode="lightcone" when wedge_filter=True.
  • Fixed batch.py and analysis.py so resume=True validates full input and BatchTask parameter fingerprints (SHA-256) instead of keying solely on task_id, and unified lightcone chunk slicing across raw and post-processed (noise_sigma_mk, wedge_filter, instrument) execution paths.

Native Compiled Inference, Multi-Probe Likelihood & PCA Foreground Removal (Phase 14)

  • Added pure-C99 compiled sampler & optical-depth core src/py21cmfast/src/inference_samplers.c (automatically compiled into c_21cmfast by build_cffi.py, zero external library dependencies): recursive k-means++ multi-ellipsoid clustering (p21_ns_propose_multi_ellipsoid_batch), differential hit-and-run slice proposals (p21_ns_propose_slice_batch), log-sum-exp Skilling evidence quadrature (p21_ns_compute_evidence), Goodman-Weare Stretch + DE-MC hybrid ensemble MCMC (p21_mcmc_propose_batch / p21_mcmc_accept_batch), split-$\widehat{R}$ (p21_mcmc_split_rhat), Sokal-windowed IAT (p21_mcmc_iat), and CMB Thomson optical depth $\tau_e$ integration (p21_compute_tau_e).
  • Added src/py21cmcu/samplers.py: zero-dependency NativeNestedSampler / run_nested_sampling and NativeEnsembleMCMC / run_native_mcmc with atomic HDF5 checkpoint/resume, ParameterPrior / PriorTransform, unified run_21cmmc (native_ns, native_mcmc, plus optional ultranest, emcee, 21cmmc backends), and drop-in Core21cmCU / Likelihood21cmCU.
  • Upgraded src/py21cmcu/inference.py and src/py21cmcu/observables.py with vectorized multi-GPU Likelihood21cm (model_error_frac), multi-probe JointLikelihood, compute_tau_e, audit_posterior_native (PosteriorAuditResult), and blind PCA/SVD foreground subtraction (remove_foreground_pca_3d).
  • Added 21cmcu infer CLI command in src/py21cmcu/cli.py, example examples/10_ultranest_and_21cmmc_inference.py, and unit tests tests/native/test_21cmcu_phase14_cmmc_ultranest.py.

Direction P — Distributed Multi-GPU EoR & Sub-160 GiB 2048³ 2LPT Streaming

  • Shared k-space filter weights in cuda_filters.cuh across cuda_cufft.cu and cuda_mgpu.cu; added p21_mgpu_r2c_from_device, p21_mgpu_filter_yslabs, p21_mgpu_c2r_to_device, P21_CUDA_MGPU_VIRTUAL_RANKS, and p21_cuda_mgpu_filter_box_host (83 CUDA APIs / 47 CFFI exports).
  • Upgraded cuda_ic.cu host-accumulated 2LPT (P21_CUDA_MGPU_2LPT_HOST_STREAM=1) to stream diagonals a=0, 1, 2 strip-by-strip through a single auxiliary buffer, reuse h_saved_input in single_slab_mode, and work cleanly with PERTURB_ON_HIGH_RES=False (<160 GiB peak host RAM at 2048³).
  • Wired distributed Y-slab filtering into cuda_ionization.cu and cuda_radiation.cu behind p21_mgpu_eor_enabled, updated src/py21cmcu/doctor.py, and added virtual-rank parity coverage in tests/native/test_21cmcu_phase15_direction_p.py.

Architecture Modernization

  • Split cuda_analysis.cu (3,056 lines) into four domain translation units (cuda_lightcone_ps.cu, cuda_observables.cu, cuda_topology.cu, cuda_multiprobe.cu) backed by shared RAII + grid-stride header cuda_analysis_common.cuh.
  • Upgraded build_cffi.py with concurrent nvcc compilation (P21_NVCC_JOBS) and build/compile_commands.json generation, and added scripts/check_cuda_abi.py (--stub-skeleton) wired into CI for 1:1 cuda_api.h / cuda_stubs.c / cuda/*.cu parity.
  • Consolidated cross-module Python helpers into src/py21cmcu/_internal.py and upgraded spectral/topological/multi-probe outputs to Mapping-compatible frozen dataclasses in src/py21cmcu/_results.py (res["k"] and res.k).

v0.9.0

Choose a tag to compare

@github-actions github-actions released this 28 Nov 13:46

21cmCU v0.9.0

Added & Improved

  • Architecture Modernization, Packaging & Automated Release:
  • Phase 11 (v0.9.0) — CRN Fisher Forecaster & Multi-Probe Cross-Correlations (86 CUDA APIs):
    • Verified Colab Tesla T4 256³ 1M-particle benchmarks: cic_deposit_3d 1.4336 s -> 0.0365 s (39.29×, max_abs_diff = 3.81e-6), cross_power_21cm_galaxy 4.8076 s -> 0.2324 s (20.68×, max_abs_rk_diff = 2.91e-8), phase13 7 passed, 0 skipped on T4 & 97 passed, 64 skipped in CPU CI.
    • Added native 86th CUDA API p21_cuda_cic_deposit_3d (src/py21cmfast/src/cuda/cuda_analysis.cu, cuda_api.h, _functionprototypes_wrapper.h, cuda_stubs.c) with periodic 3D Cloud-in-Cell deposition, optional overdensity normalization, $\mathrm{sinc}^2$ window deconvolution, and grid-stride loops for 256³+ volumes above 65535 × 256 threads.
    • Added src/py21cmcu/multiprobe.py: cic_deposit_3d, load_gravitycu_halos (GravityCU HDF5 + NumPy catalog support), cross_power_21cm_galaxy, cross_power_21cm_galaxy_error, and ksz_momentum_map.
    • Added src/py21cmcu/fisher.py and src/py21cmcu/viz.py: FisherForecaster, FisherForecastResult, fisher_forecast_21cm (Common-Random-Number low-variance derivatives + marginalized $1\sigma$ forecasts), and plot_fisher_contours.
    • Added runnable examples/09_fisher_and_multiprobe_forecast.py and tests/native/test_21cmcu_phase13_fisher_multiprobe.py, wired into exports and GitHub CPU CI.
  • Phase 10 & Direction R GPU Verification + Early Unit-Test / Warning Fixes:
    • Verified Phase 10 (bispectrum_3d 6.21× at 128³ / 26.64× at 256³, bubble_size_distribution_mfp 72.87× at 128³ / 62.53× at 256³, minkowski_functionals_3d 8.28×–8.48×) and Direction R (BatchPool 2.368× overall / 1.27 s warm round 4; zero-disk OnlineSBIDataset CUDA tensor stream) on Colab Tesla T4 (10 passed, 0 skipped).
    • Fixed OnlineSBIDataset infinite Sobol stream refill (sobol.random(1 << chunk_m)), observables.py Sobol power-of-two sampling, interop.py PyCapsule_* ctypes isolation (zero PytestUnraisableExceptionWarning), and cli.py | None type mapping for Click.
  • Phase 10 (v0.9.0-dev) — Higher-Order Non-Gaussian & Morphological Topology:
    • Added native CUDA APIs #83–#85 (p21_cuda_bispectrum_3d, p21_cuda_mfp_bsd, p21_cuda_minkowski_3d) in src/py21cmfast/src/cuda/cuda_analysis.cu, cuda_api.h, _functionprototypes_wrapper.h, and cuda_stubs.c.
    • Added src/py21cmcu/topology.py exporting bispectrum_3d (equilateral/squeezed/folded/isosceles/custom triangles with 3-slot shell caching), bubble_size_distribution_mfp (warp-compacted Philox ray-traced MFP BSD + vectorized CPU fallback), and minkowski_functionals_3d (exact cubical-complex $V_0, V_1, V_2, V_3$ & Euler $\chi$).
    • Added SBISimulator(..., summary="nongaussian") in src/py21cmcu/inference.py, examples/08_nongaussian_topology_sbi.py, and tests/native/test_21cmcu_phase12_topology.py (85 passed, 54 skipped (GPU) across 11 native suites on cluster b1; 128³ CPU timings 0.523 s Bispectrum / 0.037 s 50k-ray MFP BSD / 0.173 s 15-threshold Minkowski).
  • Direction R (v0.8.0-dev) — Persistent Multi-GPU cuFFT Plan Cache, Warm BatchPool & Zero-Disk Online SBI Pipeline:
    • Added a 64-entry concurrency-safe per-device cuFFT LRU cache across Y-slab 2D R2C/C2R and 1D C2C transforms in src/py21cmfast/src/cuda/cuda_mgpu.cu (p21_mgpu_fft_clear_cache() wired into p21_cuda_cleanup()).
    • Added warm persistent BatchPool (map, imap(ordered=...), context manager, periodic registry clearing) and extended BatchTask / BatchResult (instrument, lazy_d2h, compute_moments, oblique_lightcone, worker_pid, HDF5 moments persistence). Measured 2.643× speedup across 4 repeated 4-task 128/64 SKA1-Low rounds (20.439 s cold / 16 PIDs → 7.733 s warm / 4 PIDs; warm rounds 1.227–1.343 s vs 5.332–5.647 s).
    • Added OnlineSBIDataset (torch.utils.data.IterableDataset-compatible when PyTorch is installed, zero hard dependency) and upgraded SBISimulator with instrument + batch_pool batching and zero-disk Sobol/Uniform Tensor/NumPy streaming.
    • Added examples/07_online_sbi_zero_disk.py and tests/native/test_21cmcu_phase11_batchpool_sbi.py (81 passed, 53 skipped (GPU) across 10 native suites; wired into .github/workflows/ci.yml).
  • Bit-Exact CPU Backend Optimizations (c010ce1 + Phase 10 Step 2):
    • Added a 32-entry thread-safe aligned FFTW plan LRU cache (P21_FFTW_PLAN_CACHE=1) and a 24-slot fftwf_malloc scratch pool (P21_CPU_SCRATCH_POOL=1, P21_CPU_SCRATCH_POOL_MB=2048) in src/py21cmfast/src/dft.c / dft.h wired into IonisationBox.c, RadiationFields.c, and PerturbedField.c, both cleaned in clean_fftw().
    • Added hoisted-switch multi-box fused k-space filtering (p21_filter_boxes_fused in src/py21cmfast/src/filtering.c, IonisationBox.c, and RadiationFields.c multi_shell_filter, toggled via P21_CPU_FILTER_FUSED=1) and opt-in -march=native (P21_CPU_NATIVE=1 in build_cffi.py).
    • Verified full 16-core CPU coeval speedups with strict max_abs = 0.0 across every output array: 1.227× on 256/128 E-INTEGRAL + TS + RECOMB (9.0989 s → 7.4172 s, plan_cache=(494,6,6), scratch_pool=(172,4,4)), 1.205× on 256/128 L-INTEGRAL + TS + MCGS + EXP (11.6838 s → 9.6985 s, plan_cache=(814,8,8), scratch_pool=(259,8,8)), and 1.114× on 512/256 E-INTEGRAL + TS + RECOMB (63.2424 s → 56.7649 s).
    • Added native C/OpenMP column-parallel apply_rsds / rsds_shift kernels (p21_cpu_rsds_shift_f32 / p21_cpu_rsds_shift_f64) in src/py21cmfast/src/rsds_cpu.c and src/py21cmfast/rsds.py (P21_CPU_RSDS_NATIVE=1 default) under strict non-FMA/non-reassociate FP guards (#pragma STDC FP_CONTRACT OFF and no-fast-math), accelerating 128 × 128 × 512 16-core CPU apply_rsds from 38.2230 s → 0.0967 s (395.26×) with max_abs = 0.0.
    • Added tests/native/test_21cmcu_phase10_cpu_opt.py (69 passed, 23 skipped across CPU native suites phase0/3_d/9/10 on cluster; wired into .github/workflows/ci.yml).
  • Anti-Repetition Oblique Lightcones (9b86822):
    • Added ObliqueRectilinearLightconer and quick_lightcone(..., oblique=True) with GPU/CPU parity, using periodic oblique line-of-sight traversal (direction=(3, 5, 11)) to extend non-repeating path length by 12.45×.
  • Upstream Comparison & 21cmFAST-Aligned Showcase (3cf3700, b58d8cd):