Skip to main content

hyprfine

Authors: Harry T. J. Bevins
Version: 1.0.1
Homepage: https://github.com/htjb/hyprfine
License: MIT

GPU-accelerated simulation tools for the cosmological 21-cm signal from the Dark Ages (DA), Cosmic Dawn (CD) and Epoch of Reionization (EoR). hyprfine is built using JAX with the aim of building a signal model that runs on the GPU and is differentiable.

Currently, the code features an analytic model for the sky-averaged 21-cm signal from the dark ages through to low redshifts at the end of the EoR. At the moment only the dark ages part of the code is differentiable. The graph below is generated with the code in bin/benchmark_time.py and bin/benchmark_plot.py. It shows the relative performance on CPU and GPU as a function of batch size as well as a comparison with zeus21.

Benchmark

Installation

The code is pip installable with pip install hyprfine but for the latest version it is best to git clone the repo and install

git clone https://github.com/htjb/hyprfine
cd hyprfine
pip install .

For development:

pip install ".[dev]"
pre-commit install

Quick start

To generate a signal with the default parameters you can run

from jax import config
config.update("jax_enable_x64", True)

import jax.numpy as jnp
from hyprfine.analytic.main import generate_signal
from hyprfine.parameters import cosmology, astrophysics

f_grid = jnp.linspace(10.0, 100.0, 500)  # MHz
T21, xe, Tk = generate_signal(f_grid, cosmology(), astrophysics())

To change the default parameters you can specify

cosmo = cosmology(
    H0=67.36, # hubble's constant
    Omega_b=0.049, # Baryon density
    Omega_c=0.266, # Dark matter density
)

astro = astrophysics(
    epsilon=0.1, # normalisation of star formation efficiency
    alpha_star=0.5, # slope of low mass star formation efficiency model
    beta_star=-0.5, # slope of high mass sfe model
    M_pivot=3e11, # pivot mass of sfe model
)

for a full list of tunable parameters see hyprfine.parameters.

To take the derivatives across the Dark Ages global signal model you can run

from jax import config

config.update("jax_enable_x64", True)

import jax.numpy as jnp
import matplotlib.pyplot as plt

from hyprfine.analytic.main import generate_signal
from hyprfine.parameters import astrophysics, cosmology

fgrid = jnp.linspace(5, 50, 100)  # Frequency grid in MHz
dT21dcosmo, dxedcosmo, dTgasdcosmo = jax.jacfwd(generate_signal, argnums=1)(
    fgrid, cosmo
)

dT21dOmega_b = dT21dcosmo.Omega_b
dxedH0 = dxedcosmo.H0 # etc...

Documentation

Full documentation including tutorials can be built and served locally:

pip install ".[docs]"
mkdocs serve

Citation

If you use hyprfine in your research please link to this repo.

Metadata

Release files for hyprfine 1.0.1

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

Source distribution (sdist)

Source distribution for hyprfine 1.0.1
File Size Uploaded Provenance Actions
hyprfine-1.0.1.tar.gz 147.6 kB Without provenance Details for hyprfine-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hyprfine 1.0.1
File Interpreter ABI Platform Actions
hyprfine-1.0.1-py3-none-any.whl Python 3 none any Details for hyprfine-1.0.1-py3-none-any.whl

Total release size: 293.0 kB

Release files / hyprfine-1.0.1.tar.gz

Download URL hyprfine-1.0.1.tar.gz
Size 147.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7c45d18d1b5d764a0390a5754da7d67a4475881179544aa95281595a15787d61
BLAKE2b-256 checksum
How to use checksums
7e9c2a849242105919c519d2548b3e8fafea9361b7869914e208ae257c7fadbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / hyprfine-1.0.1-py3-none-any.whl

Download URL hyprfine-1.0.1-py3-none-any.whl
Size 145.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7571afc18386ca45435d7c3731ecfc6c5ab2ac401710d64765b313f96320f53f
BLAKE2b-256 checksum
How to use checksums
6a6b788c19a7054a1cce489760026f08316c40ef740196a3b44f6d2865c3d152
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Security for hyprfine 1.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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