jax-healpy
jax-healpy: A JAX-based implementation of HEALPix functions for high-performance scientific computing.
This project provides a comprehensive JAX-native implementation of HEALPix (Hierarchical Equal Area isoLatitude Pixelization) functions, designed for modern scientific computing with GPU acceleration, automatic differentiation, and seamless integration with machine learning workflows.
Key Features
- 🚀 GPU Acceleration: Leverage JAX's XLA compilation on CPUs and GPUs, with pixel functions up to 1000 times faster than healpy on GPU
- 🔄 Automatic Differentiation: Full support for forward and reverse-mode automatic differentiation
- 📊 Vectorized Operations: Efficient batch processing of HEALPix operations
- 🔧 HEALPix Compatibility: Drop-in replacement for many healpy functions
- 🌐 Spherical Harmonics: Differentiable spherical harmonic transforms computed by ducc0 on CPU and by s2fft on GPU, which agree with healpy to 1e-12
- 🎯 Clustering Tools: Advanced clustering algorithms for astronomical data analysis
Installation
Prerequisites
First, install JAX following the official documentation for your target architecture (CPU/GPU).
Install jax-healpy
Install via PyPI:
pip install jax-healpy
If JAX is not already installed, this command installs its CPU version. JAX and jax-healpy can also be installed together, for instance with NVIDIA CUDA 13 support:
pip install jax-healpy "jax[cuda13]"
The spherical harmonic transforms are computed by an additional library, which depends on the device and is installed by an extra:
# On CPU: ducc0
pip install "jax-healpy[cpu]"
# On GPU: s2fft, here with NVIDIA CUDA 13 support
pip install "jax-healpy[gpu]" "jax[cuda13]"
The extra gpu requires an s2fft more recent than 1.5.0, its latest release, whose transforms of polarization are wrong by a few percent on HEALPix maps. Until this version is released, install s2fft from GitHub in the same command, which requires git and a C++ compiler:
pip install "jax-healpy[gpu]" "jax[cuda13]" "s2fft @ git+https://github.com/astro-informatics/s2fft"
Quick Start
import jax.numpy as jnp
import jax_healpy as hp
import jax
# Create a HEALPix map
nside = 64
npix = hp.nside2npix(nside)
# Convert pixel indices to sky coordinates
pixels = jnp.arange(npix)
theta, phi = hp.pix2ang(nside, pixels)
# Convert sky coordinates back to pixels
recovered_pixels = hp.ang2pix(nside, theta, phi, nest=False)
# Spherical harmonics transform (requires the cpu or the gpu extra)
skymap = jax.random.normal(jax.random.PRNGKey(0), (npix,))
alm = hp.map2alm(skymap, lmax=128)
reconstructed_map = hp.alm2map(alm, nside=nside, lmax=128)
Numerical Precision
jax-healpy follows JAX's precision setting and does not enable 64-bit precision on import (since v0.7). By default JAX uses 32-bit.
We recommend enabling 64-bit precision for almost all uses. Do it before the first array operation:
import jax
jax.config.update('jax_enable_x64', True) # process-wide
# or scope it locally:
with jax.enable_x64(True):
...
32-bit precision matches healpy only at very small nside. Even at moderate resolution (e.g. nside = 256), float32 rounding shifts points across pixel boundaries, so angle<->pixel conversions and neighbour/interpolation results start to diverge from healpy. Use 32-bit only for small maps or when memory/throughput is the priority and exact healpy agreement is not required.
64-bit is required when nside > 8192: pixel indices exceed the int32 range, so 32-bit computations overflow and may raise errors, or silently return wrong results. jax-healpy will try to emit a warning in this case.
Pixel-index dtypes track nside regardless of the x64 flag: int32 for nside <= 8192, int64 above.
Performance Benchmarks
Execution time of the pixel functions on 10 million points, relative to jax-healpy on GPU in 32-bit precision:
Test System:
- CPU: Intel(R) Xeon(R) Gold 2648 @ 2.50GHz
- GPU: NVIDIA Tesla V100-SXM2-16GB
The pixel functions run about 10 times faster than healpy on CPU and up to 1000 times faster on GPU. The spherical harmonic transforms, computed by ducc0 on CPU and by s2fft on GPU, are not part of this benchmark.
Documentation
Complete documentation is available at jax-healpy.readthedocs.io
High-Performance Computing
Environment Setup
For HPC systems, load required modules:
module load python/3.10
python -m venv venv
source venv/bin/activate
pip install jax-healpy
GPU Support
Ensure JAX is properly configured for your GPU architecture. See the JAX GPU installation guide for details.
Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up the development environment
- Code style and testing requirements
- Submitting pull requests
- Reporting issues
Citation
If you use jax-healpy in your research, please cite:
@software{jax_healpy,
author = {Chanial, Pierre and Morshed, Magdy and Biquard, Simon and Kabalan, Wassim and Basyrov, Artem},
license = {GPL-3.0},
title = {{jax-healpy: Differentiable implementation of HEALPix functions and extensions in JAX}},
url = {https://github.com/CMBSciPol/jax-healpy},
year = {2026}
}
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Acknowledgments
jax-healpy is developed within the SciPol project, funded by the European Research Council (ERC) of the European Union, with the support of the CNRS.
Metadata
Release files for jax-healpy 0.9.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 |
|---|---|---|---|---|
| jax_healpy-0.9.0.tar.gz | 4.0 MB | With provenance | Details for jax_healpy-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jax_healpy-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for jax_healpy-0.9.0-py3-none-any.whl |
Total release size: 4.1 MB
Release files / jax_healpy-0.9.0.tar.gz
| Download URL | jax_healpy-0.9.0.tar.gz |
|---|---|
| Size | 4.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b5de15f7152bb36fdff37c61a6cbc72a19ad6cd8466ce7eb55966a963311f3e
|
|
BLAKE2b-256 checksum How to use checksums |
6b4362f810fab276200a3f4931f203f56119ed4d22e1ee8c07b6110e20b22d19
|
| 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 17, 2026.
Transparency logRelease files / jax_healpy-0.9.0-py3-none-any.whl
| Download URL | jax_healpy-0.9.0-py3-none-any.whl |
|---|---|
| Size | 95.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f79d9029aeb2cc72f47c090706ef712669a8dacfcdd1fbc245f9900c3cdc4fe9
|
|
BLAKE2b-256 checksum How to use checksums |
855f42c367432f0d76d63bb37a6e8b3f57b02ea48666ff66e26339039fadec9c
|
| 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 17, 2026.
Transparency logSecurity for jax-healpy 0.9.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 jax_healpy-0.9.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 17, 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.