Installation¶
Requirements¶
Package |
Version |
Purpose |
|---|---|---|
Python |
>= 3.12 |
Runtime (tested with 3.12.x and 3.13.x) |
JAX |
>= 0.8.2 |
JIT-compiled numerical kernels (CPU-only) |
NumPy |
>= 2.3 |
Array operations |
NLSQ |
>= 0.6.10 |
Trust-region Levenberg–Marquardt solver |
NumPyro |
>= 0.19 |
Bayesian MCMC / NUTS inference |
h5py |
>= 3.15 |
HDF5 data I/O |
evosax |
>= 0.2.0 |
CMA-ES evolutionary optimization |
Install with pip¶
pip install heterodyne
Install with uv (recommended)¶
uv add heterodyne
For an editable development install:
git clone https://github.com/imewei/heterodyne.git
cd heterodyne
uv sync
Development install¶
Install with all development and documentation dependencies:
uv pip install -e ".[dev,docs]"
Or use the Makefile:
make dev
Make Targets¶
The project Makefile provides common development workflows:
Target |
Description |
|---|---|
|
Install package with development and documentation dependencies |
|
Run all tests |
|
Run all tests with coverage report |
|
Run all quality checks (format + lint + type-check) |
|
Build Sphinx documentation |
Verify Installation¶
After installation, verify that the package and its dependencies are correctly configured:
heterodyne-validate
This checks that JAX, NLSQ, NumPyro, and all required dependencies are importable and reports their versions.
You can also verify from Python:
import heterodyne
print(heterodyne.__version__)
import jax
print(jax.default_backend()) # Should print "cpu"
Shell Completion¶
Run the post-install script to set up shell completions and recommended aliases:
heterodyne-post-install
This installs tab completion for Bash, Zsh, and Fish shells.
Short aliases (installed as console scripts via pip/uv):
Alias |
Equivalent |
Purpose |
|---|---|---|
|
|
Main CLI |
|
|
Config generator |
|
|
XLA flag configurator |
|
|
Post-install setup |
|
|
Cleanup utility |
|
|
System validation |
|
|
Plot experimental data |
|
|
Plot simulated C2 heatmaps |
Shell aliases (added to your profile by heterodyne-post-install):
Alias |
Expands to |
Purpose |
|---|---|---|
|
|
Main CLI |
|
|
Config generator |
|
|
NLSQ shortcut |
|
|
CMC shortcut |
|
|
XLA flag configurator |
|
|
Post-install setup |
|
|
Cleanup utility |
Exit Codes¶
All CLI commands use consistent exit codes:
Code |
Meaning |
|---|---|
|
Success |
|
General error (invalid arguments, missing files) |
|
Configuration error (invalid YAML, missing required fields) |
|
Data error (corrupt HDF5, shape mismatch, NaN detected) |
|
Optimization error (convergence failure, numerical instability) |
|
Unhandled exception (bug – please report) |
Environment Variables¶
Variable |
Description |
|---|---|
|
Force JAX backend platform (set to |
|
Enable 64-bit floating point in JAX ( |
|
Control OpenMP thread count for BLAS operations |
|
Override default output directory for results |
|
Enable debug-level logging ( |
CPU Optimization¶
Heterodyne includes a dedicated XLA flag configurator that tunes JAX’s compiler for your specific CPU topology (core count, NUMA nodes, cache hierarchy):
heterodyne-config-xla
This detects your hardware and writes optimal XLA flags for thread allocation,
intra-op parallelism, and memory layout. The configuration is stored in
$VIRTUAL_ENV/etc/heterodyne/xla_mode (or $CONDA_PREFIX/etc/heterodyne/xla_mode
in conda/mamba environments, or ~/.config/heterodyne/xla_mode outside any
environment) and sourced automatically on subsequent runs.
For HPC environments with many cores (36–128+), this step is strongly recommended before running any analysis.