Skip to main content

JAX implementation of AbstractCosmologicalEmulators.jl interface with artifact support

Project description

jaxace

Tests Documentation Documentation codecov

JAX/Flax implementation of cosmological emulators with automatic JIT compilation.

Installation

pip install -e .

Usage

import jaxace
import jax.numpy as jnp
import numpy as np

# Cosmology
cosmo = jaxace.w0waCDMCosmology(
    ln10As=3.044, ns=0.9649, h=0.6736,
    omega_b=0.02237, omega_c=0.1200,
    m_nu=0.06, w0=-1.0, wa=0.0
)

# Background functions
z = jnp.array([0.0, 0.5, 1.0])
growth = cosmo.D_z(z)
distance = cosmo.r_z(z)

# Neural network emulator
emulator = jaxace.init_emulator(nn_dict, weights, jaxace.FlaxEmulator)
output = emulator(input_data)  # Auto-JIT + batch detection

Included trained generic emulators

jaxace ships artifact definitions for the official 300303 trained GenericEmulator pair:

  • ACE_mnuw0wacdm_sigma8_basis
  • ACE_mnuw0wacdm_ln10As_basis

They can be loaded directly from the package artifact registry. The first call downloads and caches the emulator; later calls reuse the local cache.

import jaxace
import numpy as np

# Input order for the sigma8-basis emulator:
# z, sigma8, ns, H0, ombh2, omch2, Mnu, w0, wa
emu = jaxace.get_emulator("ACE_mnuw0wacdm_sigma8_basis")
params = np.array([0.5, 0.8, 0.96, 67.0, 0.022, 0.12, 0.06, -1.0, 0.0])
output = emu.run_emulator(params)

# The ln10As-basis emulator uses ln10As in the second slot instead of sigma8:
emu_ln10As = jaxace.get_emulator("ACE_mnuw0wacdm_ln10As_basis")
params_ln10As = np.array([0.5, 3.044, 0.96, 67.0, 0.022, 0.12, 0.06, -1.0, 0.0])
output_ln10As = emu_ln10As.run_emulator(params_ln10As)

Available artifact-backed emulators can be listed with:

jaxace.list_emulators()

Postprocessing API

jaxace 0.6.0 matches the current AbstractCosmologicalEmulators.jl generic emulator API. Custom postprocessing functions should take three arguments:

def postprocessing(input_params, output, emulator):
    return output

When loading an emulator from disk, postprocessing.py should define that function. Legacy four-argument functions postprocessing(input_params, output, auxiliary_params, emulator) are still accepted for backward compatibility, but new emulators should use the three-argument form.

Features

  • Background cosmology (growth, distances, Hubble)
  • Neural network emulators with auto-JIT
  • Massive neutrinos and dark energy support
  • Full JAX integration (grad, vmap, jit)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jaxace-0.6.1.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jaxace-0.6.1-py3-none-any.whl (35.9 kB view details)

Uploaded Python 3

File details

Details for the file jaxace-0.6.1.tar.gz.

File metadata

  • Download URL: jaxace-0.6.1.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jaxace-0.6.1.tar.gz
Algorithm Hash digest
SHA256 dd8a42a6c5ef4f978f598ac3b2939af11c00f2a1ec1532d3740a2f51883549b0
MD5 493dd29739bfd17eebcddf4229078800
BLAKE2b-256 5c38933481b915ced6ce848891976099714f08ff94073881d4d65de8196032f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for jaxace-0.6.1.tar.gz:

Publisher: publish.yml on CosmologicalEmulators/jaxace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jaxace-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: jaxace-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 35.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jaxace-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28dc5328f36cda8840310c09f50f7f4f43347d476ab52f07292cb674399263f8
MD5 2972734552d076bb92b7d0e600000e49
BLAKE2b-256 0ea7e0c52bc0a66d8f39df37959a0b9884cfd95ebd9dc7578dfdab4b05f0a461

See more details on using hashes here.

Provenance

The following attestation bundles were made for jaxace-0.6.1-py3-none-any.whl:

Publisher: publish.yml on CosmologicalEmulators/jaxace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page