Repository navigation
Releases
Releases · HainaHuang729/21cmCU
v1.0.0
21cmCU v1.0.0
Documentation, Wiki & Discovery Metadata
- Upgraded
docs/USER_GUIDE.mdanddocs/wiki/to fullv1.0.0coverage, adding dedicated guidesBayesian-Inference-and-Samplers.md,Multi-Probe-Fisher-and-Topology.md, andDistributed-NCCL-and-Multi-Node.md. - Added
CITATION.cff,.zenodo.json, andllms.txtfor reproducible software citation, Zenodo DOI archival, and machine-readable indexing.
Hardened Inference, Samplers & Audit Correctness
- Added
-fno-finite-math-onlyalongside-ffast-mathinbuild_cffi.pyand finite guards ininference_samplers.cso non-finite-inf/NaNlog-likelihoods never collapse Skilling quadrature toNaN, and fixedp21_mcmc_split_rhat/p21_mcmc_iatto reportinf/naninstead of1.0on zero within-chain variance. - Fixed
NativeNestedSamplerto bulk-evict equal-likelihood plateaus (both-infand 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 honoringresume=Truecheckpoints in bothNativeNestedSamplerandNativeEnsembleMCMC. - Updated
NativeEnsembleMCMCto scaleessbyN_samples / max(IAT)and mark zero-acceptance / zero-variance stuck chains withdiagnostics_ok=Falseandess=0.0. - Fixed
Likelihood21cmcov_invmissing-bin marginalization to use a scale-invariant relative tolerance instead ofnp.allclose(..., atol=1e-8), matchingcovariancewhen precision matrix entries are small (~1e-9). - Fixed
Likelihood21cmsomodel_error_frac > 0includes exact Gaussian normalization (-sum log sigma/-0.5 log det Sigma_eff) andsimulate()/simulate_batch()resolve identical defaultout_redshiftin coeval mode. - Fixed
audit_posterior_nativeandPosteriorAuditResultto evaluate errors against fixed required observation bins and record explicitn_failed_draws/failure_rate/bin_failure_rate(returningNaNsummary 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.cuhloadinglibnccl.so.2($\ge 2.7$ ) dynamically viadlopen/dlsym(P21_NCCL_LIB,RTLD_DEFAULT) with zero compile-timelibnccldependency. - Integrated intra-process clique caching and
P21_CUDA_MGPU_BACKEND=auto|nccl|p2p|hostintocuda_mgpu.cuandcuda_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;90CUDA APIs /54CFFI 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, andtests/native/test_21cmcu_phase16_nccl_v100.py.
256³–1024³ Multi-Probe Benchmark & Paper Finalization
- Added
benchmarks/bench_multiprobe_v100.py,benchmarks/reproduce_v100_tables.py, and verified live Colab Tesla T4 (CUDA 13.0, NCCL2.28.3,23/23GPU tests passing) results inbenchmarks/results_t4_v100.json, generatingdocs/paper/tables/table_v100_multiprobe.texanddocs/figures/v100_multiprobe_scaling.png. - Finalized
docs/paper/21cmcu_paper.tex,docs/paper/21cmcu_paper.md,docs/paper/refs.bib,README.md, anddocs/ROADMAP.mdforv1.0.0, verified cleanly withpdflatex+bibtex.
Bug Fixes
- Fixed degenerate Fisher matrices in
src/py21cmcu/fisher.pyreporting spurious finite marginalized uncertainties frompinv; unconstrained eigenvectors now yieldsigma_marginalized = inf,covdiagonalinf,fom = 0.0, and explicit degeneracy metadata, and fixed 1D Fisher auto-noise conversion to evaluatesigma_delta_sqat the exact unweightedpower_spectrum_1dbin centersk. - Fixed weighted galaxy shot noise subtraction in
cross_power_21cm_galaxyto use$V \sum w_i^2 / (\sum w_i)^2$ for bothMapping["masses"]and explicitweightscatalogs. - Fixed
Likelihood21cmto fix the observed-data mask at construction time, return-infwhenever any required observed bin evaluates to non-finite in the model, properly marginalize/slice missing data bins oncov_inv(Schur complement) andcovariance(sub-block inversion), and applyapply_wedge_filter_3dinmode="lightcone"whenwedge_filter=True. - Fixed
batch.pyandanalysis.pysoresume=Truevalidates full input andBatchTaskparameter fingerprints (SHA-256) instead of keying solely ontask_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 intoc_21cmfastbybuild_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-dependencyNativeNestedSampler/run_nested_samplingandNativeEnsembleMCMC/run_native_mcmcwith atomic HDF5 checkpoint/resume,ParameterPrior/PriorTransform, unifiedrun_21cmmc(native_ns,native_mcmc, plus optionalultranest,emcee,21cmmcbackends), and drop-inCore21cmCU/Likelihood21cmCU. - Upgraded
src/py21cmcu/inference.pyandsrc/py21cmcu/observables.pywith vectorized multi-GPULikelihood21cm(model_error_frac), multi-probeJointLikelihood,compute_tau_e,audit_posterior_native(PosteriorAuditResult), and blind PCA/SVD foreground subtraction (remove_foreground_pca_3d). - Added
21cmcu inferCLI command insrc/py21cmcu/cli.py, exampleexamples/10_ultranest_and_21cmmc_inference.py, and unit teststests/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.cuhacrosscuda_cufft.cuandcuda_mgpu.cu; addedp21_mgpu_r2c_from_device,p21_mgpu_filter_yslabs,p21_mgpu_c2r_to_device,P21_CUDA_MGPU_VIRTUAL_RANKS, andp21_cuda_mgpu_filter_box_host(83CUDA APIs /47CFFI exports). - Upgraded
cuda_ic.cuhost-accumulated2LPT(P21_CUDA_MGPU_2LPT_HOST_STREAM=1) to stream diagonalsa=0, 1, 2strip-by-strip through a single auxiliary buffer, reuseh_saved_inputinsingle_slab_mode, and work cleanly withPERTURB_ON_HIGH_RES=False(<160 GiBpeak host RAM at2048³). - Wired distributed Y-slab filtering into
cuda_ionization.cuandcuda_radiation.cubehindp21_mgpu_eor_enabled, updatedsrc/py21cmcu/doctor.py, and added virtual-rank parity coverage intests/native/test_21cmcu_phase15_direction_p.py.
Architecture Modernization
- Split
cuda_analysis.cu(3,056lines) into four domain translation units (cuda_lightcone_ps.cu,cuda_observables.cu,cuda_topology.cu,cuda_multiprobe.cu) backed by shared RAII + grid-stride headercuda_analysis_common.cuh. - Upgraded
build_cffi.pywith concurrentnvcccompilation (P21_NVCC_JOBS) andbuild/compile_commands.jsongeneration, and addedscripts/check_cuda_abi.py(--stub-skeleton) wired into CI for 1:1cuda_api.h/cuda_stubs.c/cuda/*.cuparity. - Consolidated cross-module Python helpers into
src/py21cmcu/_internal.pyand upgraded spectral/topological/multi-probe outputs toMapping-compatible frozen dataclasses insrc/py21cmcu/_results.py(res["k"]andres.k).
v0.9.0
21cmCU v0.9.0
Added & Improved
-
Architecture Modernization, Packaging & Automated Release:
- Adopted PEP 621 dynamic single-source versioning (
src/py21cmcu/_version.py), PEP 561py.typedmarker, modular runtime facade (src/py21cmcu/_runtime.py+cuda_api_count()), and PEP 562 lazy top-level imports insrc/py21cmcu/__init__.py. - Hardened
src/py21cmcu/cli.pyandsrc/py21cmcu/doctor.pywith21cmcu version [--as-json],api_countreporting, and non-editable wheel guardrails in21cmcu bench. - Added Python
3.12/3.13CI matrix +packaging-smokewheel job (.github/workflows/ci.yml), tag-triggered wheel & release automation (.github/workflows/release.yml), andscripts/build_wheels.sh. - Updated
docs/paper/21cmcu_paper.tex,docs/paper/21cmcu_paper.md,benchmarks/results_t4_v090.json,benchmarks/reproduce_v090_tables.py, andnotebooks/21cmCU_GPU_Verify.ipynbtov0.9.0.
- Adopted PEP 621 dynamic single-source versioning (
-
Phase 11 (
v0.9.0) — CRN Fisher Forecaster & Multi-Probe Cross-Correlations (86CUDA APIs):- Verified Colab Tesla T4
256³1M-particle benchmarks:cic_deposit_3d1.4336 s -> 0.0365 s(39.29×,max_abs_diff = 3.81e-6),cross_power_21cm_galaxy4.8076 s -> 0.2324 s(20.68×,max_abs_rk_diff = 2.91e-8),phase137 passed, 0 skippedon T4 &97 passed, 64 skippedin 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 for256³+volumes above65535 × 256threads. - 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, andksz_momentum_map. - Added
src/py21cmcu/fisher.pyandsrc/py21cmcu/viz.py:FisherForecaster,FisherForecastResult,fisher_forecast_21cm(Common-Random-Number low-variance derivatives + marginalized$1\sigma$ forecasts), andplot_fisher_contours. - Added runnable
examples/09_fisher_and_multiprobe_forecast.pyandtests/native/test_21cmcu_phase13_fisher_multiprobe.py, wired into exports and GitHubCPU CI.
- Verified Colab Tesla T4
-
Phase 10 & Direction R GPU Verification + Early Unit-Test / Warning Fixes:
- Verified Phase 10 (
bispectrum_3d6.21×at128³/26.64×at256³,bubble_size_distribution_mfp72.87×at128³/62.53×at256³,minkowski_functionals_3d8.28×–8.48×) and Direction R (BatchPool2.368×overall /1.27 swarm round 4; zero-diskOnlineSBIDatasetCUDA tensor stream) on Colab Tesla T4 (10 passed,0 skipped). - Fixed
OnlineSBIDatasetinfinite Sobol stream refill (sobol.random(1 << chunk_m)),observables.pySobol power-of-two sampling,interop.pyPyCapsule_*ctypes isolation (zeroPytestUnraisableExceptionWarning), andcli.py| Nonetype mapping for Click.
- Verified Phase 10 (
-
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) insrc/py21cmfast/src/cuda/cuda_analysis.cu,cuda_api.h,_functionprototypes_wrapper.h, andcuda_stubs.c. - Added
src/py21cmcu/topology.pyexportingbispectrum_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), andminkowski_functionals_3d(exact cubical-complex$V_0, V_1, V_2, V_3$ & Euler$\chi$ ). - Added
SBISimulator(..., summary="nongaussian")insrc/py21cmcu/inference.py,examples/08_nongaussian_topology_sbi.py, andtests/native/test_21cmcu_phase12_topology.py(85 passed, 54 skipped (GPU)across 11 native suites on clusterb1;128³CPU timings0.523 sBispectrum /0.037 s50k-ray MFP BSD /0.173 s15-threshold Minkowski).
- Added native CUDA APIs
-
Direction R (
v0.8.0-dev) — Persistent Multi-GPU cuFFT Plan Cache, WarmBatchPool& 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 intop21_cuda_cleanup()). - Added warm persistent
BatchPool(map,imap(ordered=...), context manager, periodic registry clearing) and extendedBatchTask/BatchResult(instrument,lazy_d2h,compute_moments,oblique_lightcone,worker_pid, HDF5 moments persistence). Measured2.643×speedup across 4 repeated 4-task128/64SKA1-Lowrounds (20.439 scold / 16 PIDs →7.733 swarm / 4 PIDs; warm rounds1.227–1.343 svs5.332–5.647 s). - Added
OnlineSBIDataset(torch.utils.data.IterableDataset-compatible when PyTorch is installed, zero hard dependency) and upgradedSBISimulatorwithinstrument+batch_poolbatching and zero-disk Sobol/Uniform Tensor/NumPy streaming. - Added
examples/07_online_sbi_zero_disk.pyandtests/native/test_21cmcu_phase11_batchpool_sbi.py(81 passed, 53 skipped (GPU)across 10 native suites; wired into.github/workflows/ci.yml).
- Added a 64-entry concurrency-safe per-device cuFFT LRU cache across Y-slab 2D R2C/C2R and 1D C2C transforms in
-
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-slotfftwf_mallocscratch pool (P21_CPU_SCRATCH_POOL=1,P21_CPU_SCRATCH_POOL_MB=2048) insrc/py21cmfast/src/dft.c/dft.hwired intoIonisationBox.c,RadiationFields.c, andPerturbedField.c, both cleaned inclean_fftw(). - Added hoisted-switch multi-box fused
k-space filtering (p21_filter_boxes_fusedinsrc/py21cmfast/src/filtering.c,IonisationBox.c, andRadiationFields.cmulti_shell_filter, toggled viaP21_CPU_FILTER_FUSED=1) and opt-in-march=native(P21_CPU_NATIVE=1inbuild_cffi.py). - Verified full 16-core CPU coeval speedups with strict
max_abs = 0.0across every output array:1.227×on256/128E-INTEGRAL + TS + RECOMB(9.0989 s → 7.4172 s,plan_cache=(494,6,6),scratch_pool=(172,4,4)),1.205×on256/128L-INTEGRAL + TS + MCGS + EXP(11.6838 s → 9.6985 s,plan_cache=(814,8,8),scratch_pool=(259,8,8)), and1.114×on512/256E-INTEGRAL + TS + RECOMB(63.2424 s → 56.7649 s). - Added native C/OpenMP column-parallel
apply_rsds/rsds_shiftkernels (p21_cpu_rsds_shift_f32/p21_cpu_rsds_shift_f64) insrc/py21cmfast/src/rsds_cpu.candsrc/py21cmfast/rsds.py(P21_CPU_RSDS_NATIVE=1default) under strict non-FMA/non-reassociate FP guards (#pragma STDC FP_CONTRACT OFFandno-fast-math), accelerating128 × 128 × 51216-core CPUapply_rsdsfrom38.2230 s → 0.0967 s(395.26×) withmax_abs = 0.0. - Added
tests/native/test_21cmcu_phase10_cpu_opt.py(69 passed, 23 skippedacross CPU native suitesphase0/3_d/9/10on cluster; wired into.github/workflows/ci.yml).
- Added a 32-entry thread-safe aligned FFTW plan LRU cache (
-
Anti-Repetition Oblique Lightcones (
9b86822):- Added
ObliqueRectilinearLightconerandquick_lightcone(..., oblique=True)with GPU/CPU parity, using periodic oblique line-of-sight traversal (direction=(3, 5, 11)) to extend non-repeating path length by12.45×.
- Added
-
Upstream Comparison & 21cmFAST-Aligned Showcase (
3cf3700,b58d8cd):- Added
docs/UPSTREAM_AND_OPTIMIZATION.md, corresponding Wiki documentation, and 21cmFASTEoR/viridis-aligned 2D/3D showcase figures inREADME.md.
- Added