Skip to main content

DISCO-EB logo

DISCO-EB

tests coverage lint types PyPI Downloads Python JAX arXiv Conventional Commits License: MIT

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 RECFAST module (recfast.py) adapts code from RECFAST, whose UBC license is included in our version.

Metadata

Release files for disco-eb 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disco-eb 2.5.0
File Size Uploaded Provenance Actions
disco_eb-2.5.0.tar.gz 119.0 kB With provenance Details for disco_eb-2.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for disco-eb 2.5.0
File Interpreter ABI Platform Actions
disco_eb-2.5.0-py3-none-any.whl Python 3 none any Details for disco_eb-2.5.0-py3-none-any.whl

Total release size: 203.0 kB

Release files / disco_eb-2.5.0.tar.gz

Download URL disco_eb-2.5.0.tar.gz
Size 119.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d365a6c0187346e6b0b73cfa52dad6020cddee3b4a63662abc3f76d8590e6eee
BLAKE2b-256 checksum
How to use checksums
dd89d8067fbe50ddbb182c099323dcd6aefc7928317ca5cc8357a45905eb8c55
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 29, 2026.

Transparency log

Release files / disco_eb-2.5.0-py3-none-any.whl

Download URL disco_eb-2.5.0-py3-none-any.whl
Size 84.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f69c759b6167a05da948c428e8d38ef91004c4d348fe938daa63afeaa1130d29
BLAKE2b-256 checksum
How to use checksums
bdc081d31ef45000802661f718f508da5125c035946c432cd7187720d4a63eba
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 29, 2026.

Transparency log

Security for disco-eb 2.5.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.

Select from 2 files

Attestation for disco_eb-2.5.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 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page