petitRADTRANS 4: most notable changes#
Preface#
petitRADTRANS 4 is the first release series that replaces the legacy Fortran radiative-transfer backend with a JAX implementation. Compared to pRT3, this is a larger-than-usual upgrade: the numerical backend, the retrieval interface, the optional sampler stack, and several public parameter names all changed.
The JAX backend enables JIT compilation, automatic differentiation, and execution on CPUs, GPUs, and TPUs through the JAX ecosystem. It also means that pRT 4 is not numerically identical to version 3: small numerical differences relative to pRT 3 are expected, and the 4.0.0a31 release should still be treated as experimental.
Hereafter is a summary of the most important additions, behavioural changes, and migration points between pRT 3.3.3 and pRT 4.0.0a31.
Added#
- A JAX-based radiative-transfer backend. The translated core kernels now live
in
petitRADTRANS.radtrans_core, andRadtrans, chemistry, opacities, and math routines now operate on JAX arrays.
- Native support for JIT compilation, automatic differentiation, and
accelerator execution through JAX. This is the main architectural change in pRT 4 and is what enables GPU and TPU execution.
- Autodiff-oriented spectrum APIs with
Radtrans.calculate_flux_autodiff()andRadtrans.calculate_transit_radii_autodiff().
- A new retrieval layer built around
RetrievalRuntime. Forward models can now follow a JAX-friendly contract instead of relying only on the legacy mutable
Radtransretrieval pattern.
- A new retrieval layer built around
- Built-in differentiable JAX retrieval models exported from
petitRADTRANS.retrieval.models, together with dedicated tutorials foremission, transmission, and time-series retrievals.
- New retrieval samplers:
dynesty,jaxns,blackjaxHMC and NUTS, and
numpyroHMC and NUTS, in addition to the existing PyMultiNest and UltraNest workflows.
- New retrieval samplers:
- Ability to use optimal estimation to find the maximum a posteriori (MAP) solution
using optax,which supports both gradient-based optimization and gradient-free methods.
- A dedicated sampler layer that normalizes sampler selection, sample
archiving, and summary generation across backends.
- Covariance-aware retrievals, including Gaussian processes, automatic
covariance hyperparameters in
RetrievalConfig, and Cholesky-based likelihood evaluation throughLogLikelihood.
- The
RetrievalPlotterclass, which separates retrieval plotting from the core
Retrievalobject.
- The
- A new
petitRADTRANS.sbipackage scaffold for simulation-based inference, including simulators, training tasks, and normalising flow based SBI workflows.
- A new
- Time-variable retrieval support through
RetrievalConfig.add_time_series_data()and time-series model parameterizations.
- Additional physics and modelling options, including non-vertically
constant abundance profiles, isotope-ratio driven chemistry support for isotopologues, a JAX reimplementation of the exo-k correlated-k binning algorithm, Feautrier angle-dependent intensities, and JAX-compatible contribution-function evaluation.
- Retrieval output summaries now include more sampler-native products, and the
retrieval pipeline can compute model-selection diagnostics such as BIC, AIC, and BPIC.
- New tutorial and reference material covering the JAX runtime, sampler
choices, differentiable retrieval models, covariance-aware retrievals, and SBI.
Changed#
Radtransnow evaluates spectra through the JAX backend rather than thelegacy Fortran implementation. In practice, this is a backend replacement, not just an optimization pass.
radtrans.pyhas been substantially refactored. Many static helpers weremoved into dedicated modules, especially under
petitRADTRANS.radtrans_core, to separate physics kernels from the high-level API.
- Spectrum calculations sanitize and normalize inputs before evaluation so
they can be traced by JAX. This primarily affects users writing custom model wrappers or composing pRT inside larger JAX programs.
- The retrieval workflow now supports both the legacy retrieval interface and
the newer interface. The scalar and JAX execution paths now run through
RetrievalRuntimewhen possible.
- Memory management for line-by-line opacities and covariance handling has
been reworked: pRT delays some JAX conversions, loads lbl data more selectively, and uses Cholesky factorization for large covariance matrices.
- Transmission spectra and non-scattering emission calculations are now
compatible with 32-bit execution modes, which matters for accelerator workflows where
float32is often the default.
- Feautrier emission calculations can now skip the scattering solve when no
scattering opacity is present, and can optionally return angle-dependent intensities.
- Partial cloud coverage is now expressed through the patchy-cloud interface.
This is the main cloud-coverage surface documented in pRT 4.
- The tutorial set, retrieval examples, and public documentation now assume
the current v4 dataset-control names, the differentiable model examples, and the expanded sampler ecosystem.
- pRT 4 ships optional dependency groups for
[retrieval],[sbi], and [full], reflecting the broader runtime and inference stack introduced in this release line.
- pRT 4 ships optional dependency groups for
- The installation and runtime expectations changed with the new backend: pRT
4 depends on JAX, newer NumPy and Astropy versions, and a newer Python baseline.
- Because the numerical core was rewritten, small numerical differences
relative to the 3.x series are expected. The v4 documentation currently describes differences on the order of about 0.1 percent relative to earlier versions.
Breaking changes#
Python requirement: the minimum supported Python version is now 3.12.
- Backend expectation: custom code that relied on the old Fortran
execution model, mutable Fortran-side state, or NumPy-only execution assumptions must be updated for a JAX-based backend.
- Retrieval dataset controls renamed:
scale->scale_flux, scale_err->scale_uncertainties, andoffset_bool->fit_flux_offset.
- Retrieval dataset controls renamed:
- Emission geometry renamed:
emission_geometryis now irradiation_geometrythroughout the main radiative-transfer API.
- Emission geometry renamed:
- Cloud particle argument names standardized: canonical argument names now
use
cloud_particle_...instead ofcloud_particles_....
- Patchy-cloud controls updated:
complete_coverage_cloudsis no longer part of the canonical API. Use
patchy_cloudsto specify which clouds are patchy.
- Patchy-cloud controls updated:
- Chemistry module rename:
condensation_curves.pyis now vapour_pressures.py.
- Chemistry module rename:
- SpectralModel key rename: the canonical key in
SpectralModel.model_parametersis nowmodification_argumentsinstead ofmodification_parameters.
- Retrieval chi-squared interface changed:
Data.get_chi2has been removed; chi-squared and likelihood evaluation now live in
LogLikelihood.
- Retrieval chi-squared interface changed:
- Time-variable retrieval configuration moved: legacy variability
arguments were removed from
RetrievalConfig.add_data(); time-variable workflows must useadd_time_series_data().
- Sampler requirements changed: JAX-based samplers such as
jaxns, blackjax, andnumpyrorequire differentiable or otherwise JAX-traceable model groups. A legacy model that only works through the old mutable retrieval contract is not sufficient for every v4 sampler backend.
- Sampler requirements changed: JAX-based samplers such as
- Experimental status: pRT 4.0.0a31 is still an alpha release. Existing
pRT 3 production workflows should be revalidated after migration.
Removed#
Data.get_chi2has been removed in favour ofLogLikelihood.- Retrieval-time variability controls formerly passed through
RetrievalConfig.add_data()have been removed from that interface and replaced byadd_time_series_data().
- The pRT2 -> pRT3 opacity-conversion workflow is not part of the pRT4
migration story, because pRT4 does not introduce a new opacity file format.
Installation and runtime#
Upgrade to Python 3.12 or newer before migrating.
- Expect newer dependency floors, including NumPy 2.0+, Astropy 7.0+, and
JAX as a core dependency.
- Install a JAX build that matches your hardware target. CPU-only
installations work out of the box, while GPU or TPU execution depends on the JAX wheel you install.
- Choose the optional extras that match your workflow:
petitRADTRANS[retrieval]for retrievals,petitRADTRANS[sbi]for SBI, orpetitRADTRANS[full]for the full stack.
Updating forward models#
- If your custom code only calls
Radtrans.calculate_flux()or Radtrans.calculate_transit_radii(), the high-level usage pattern remains familiar, but the returned arrays now come from a JAX-based backend.
- If your custom code only calls
- If your forward model touches low-level internals, assumes NumPy-only
arrays, or depends on the old Fortran kernels, update it to be JAX-safe or explicitly convert outputs with
numpy.asarray(...)outside traced or JIT sections.
- For differentiable retrievals and JAX-native samplers, prefer the
differentiable model contract exposed through
RetrievalRuntimeand the built-in functions inpetitRADTRANS.retrieval.models.
Updating retrieval configurations#
- Rename dataset-control flags to
scale_flux,scale_uncertainties, and fit_flux_offset.
- Rename dataset-control flags to
- Replace
Data.get_chi2usage withLogLikelihoodor the higher-level Retrievalhelpers that now wrap it.
- Replace
- Use
add_time_series_data()instead of passing variability-specific arguments through
add_data().
- Use
- If you plan to use
jaxns,blackjax, ornumpyro, ensure that at least one model group is differentiable or otherwise fully JAX-traceable.
- If you plan to use
Updating physics and parameter names#
Rename
emission_geometrytoirradiation_geometry.- Rename
cloud_particles_*arguments and parameter keys to cloud_particle_*.
- Rename
Replace
complete_coverage_cloudswithpatchy_clouds.- Update imports from
petitRADTRANS.chemistry.condensation_curvesto petitRADTRANS.chemistry.vapour_pressures.
- Update imports from
- In
SpectralModel.model_parameters, usemodification_argumentsrather than
modification_parameters.
- In