DISCO-EB
Installation • Quickstart • Documentation • Paper • Citation
DISCO-EB is a differentiable linear Einstein-Boltzmann solver for cosmology, and the Einstein-Boltzmann module of the DISCO-DJ framework (DIfferentiable Simulations for COsmology, Done with Jax). It evolves the background, the recombination history and the linear perturbations of every wave mode of a batch of cosmologies in one GPU launch. DISCO-EB supports models including: flat or curved ΛCDM, a CPL dark-energy fluid $(w_0, w_a)$ and massive neutrinos.
Installation
pip install "disco-eb[cuda13]" # or [cuda12], which Python 3.10 or older GPUs need
A GPU is required to run the E-B solve. Whilst the matter power spectrum is included in this package, CMB observables live in a separate package, DISCO-CMB.
Quickstart
A particular cosmology is defined as an instance of a DISCO-EB cosmological model initialised with particular cosmological parameters. In the following example we set up two LCDM cosmologies and configure the solver to return the comoving curvature perturbation $\mathcal{R}$ and the CDM overdensity, for 64 wave modes at 100 scale factors:
import numpy as np
from discoeb import LCDM, solve_eb
planck = LCDM.from_density_parameters(
Omega_m=0.3142, Omega_b=0.0494, H_0=67.32,
A_s=2.1e-9, n_s=0.966, T_cmb=2.7255, Y_He=0.2454, N_eff=3.046,
)
k = np.geomspace(1e-4, 1.0, 64) # 1/Mpc
a = np.geomspace(1e-6, 1.0, 100) # scale factors, the last one today
values = solve_eb([planck, planck.replace(omega_c=0.125)], k, a, keep=("R", "delta_c"))
R = values[:, 0] # (2, 64, 100): cosmologies, wave modes, scale factors
Cosmologies are described by their physical density parameters, omega_b, omega_c and
omega_de ($\omega = \Omega h^2$), or by the density fractions Omega_m and Omega_b ($\Omega = \rho / \rho_\text{crit}$) and the Hubble constant H_0 using from_density_parameters. One GPU solve integrates the background and recombination once per cosmology and the perturbations of every wave mode against them, so nothing is tabulated before the solve. The solver is JIT-compiled and runs on the GPU, so it is fast and differentiable in the cosmological parameters. Users can choose which quantities to keep at which times, and the GPU kernel evaluates them on the fly. The integration runs using a modax Rodas5P GPU kernel.
Development
The repository uses uv:
git clone https://github.com/cosmo-sims/DISCO-EB.git && cd DISCO-EB
uv sync --extra cuda13 # or --extra cuda12
uv run pytest tests -rs # includes GPU tests, -rs shows skipped CLASS comparisons
uv run pytest tests -m "not gpu" -n auto # host only tests, parallelised across CPU cores
uv run ruff format && uv run ruff check --fix # format and lint
uv run ty check # type check
uv run pre-commit install # formatting, linting and type checking on commit
The documentation (Sphinx with MyST and autodoc) builds in its own environment:
export UV_PROJECT_ENVIRONMENT=.venv-docs
uv sync --no-default-groups --group docs
uv run --no-sync sphinx-autobuild docs docs/_build/html # live preview
uv run --no-sync sphinx-build -W docs docs/_build/html # what CI runs
Citation
If you use DISCO-EB in your research, please cite the JCAP article:
@article{DISCO-EB:2024,
author = "Hahn, Oliver and List, Florian and Porqueres, Natalia",
title = "{DISCO-DJ I: a differentiable Einstein-Boltzmann solver for cosmology}",
eprint = "2311.03291",
archivePrefix = "arXiv",
primaryClass = "astro-ph.CO",
doi = "10.1088/1475-7516/2024/06/063",
journal = "JCAP",
volume = "06",
pages = "063",
year = "2024"
}
License
DISCO-EB uses the MIT License. The recombination module adapts code from RECFAST, whose UBC license is included in our version.
Metadata
Release files for disco-eb 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| disco_eb-2.2.0.tar.gz | 116.0 kB | With provenance | Details for disco_eb-2.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| disco_eb-2.2.0-py3-none-any.whl | Python 3 | none | any | Details for disco_eb-2.2.0-py3-none-any.whl |
Total release size: 197.6 kB
Release files / disco_eb-2.2.0.tar.gz
| Download URL | disco_eb-2.2.0.tar.gz |
|---|---|
| Size | 116.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bfa7ff790c40120954f4d4ae2de509476c5d4e9067e7c88e6d34abea37e3dfe
|
|
BLAKE2b-256 checksum How to use checksums |
cd082190ccf4cf4a5668c29f420685f544c4f16e30f87f15eb59ea499102373e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / disco_eb-2.2.0-py3-none-any.whl
| Download URL | disco_eb-2.2.0-py3-none-any.whl |
|---|---|
| Size | 81.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
147f5559c7c24402e11dbdb789b53f3ba25677dd2c0723f97358ffcdb1b16bbe
|
|
BLAKE2b-256 checksum How to use checksums |
8675e517c9ddfb137ba3202a40de242f8962b9f537883d9e31ae27e26513b7ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for disco-eb 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for disco_eb-2.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.