Hyperiax is a pure-JAX library for message passing on rooted trees. It provides
immutable tree data structures, typed per-node arrays, and decorator-based
sweeps that compose with jax.jit, jax.vmap, and jax.lax.scan.
Hyperiax is designed for phylogenetic and tree-structured scientific computing, including Gaussian graphical models, phylogenetic means, and guided inference for diffusion processes on trees.
Hyperiax requires Python 3.11 or newer.
pip install hyperiaxThe core package depends only on JAX, jaxlib, and NumPy. For accelerator-backed JAX installations, follow the official JAX installation instructions for your platform before or after installing Hyperiax.
import jax.numpy as jnp
import hyperiax as hx
topology = hx.symmetric_topology(depth=2, degree=2)
tree = hx.Tree.empty(topology, {"value": (2,)})
leaf_count = int(topology.is_leaf.sum())
tree = tree.at[topology.is_leaf].set(value=jnp.ones((leaf_count, 2)))
@hx.up(reads_children=("value",), writes=("value",))
def average_children(node, children, params):
return {"value": children.value.mean(0)}
result = average_children(tree)
root_value = result.value[0]Sweeps are ordinary Tree -> Tree functions. The @hx.up and @hx.down
decorators declare which fields are read and written, so dispatch remains
explicit and JAX-friendly.
hyperiax/
├── core/ # Topology, Tree, Schema, views, sweep dispatch, builders
├── utils/ # Pure-JAX ODE and SDE solvers
└── prebuilt/ # Ready-to-use sweeps for BFFG and phylogenetic means
hyperiax.core contains the public primitives:
Topologyfor rooted tree structure.Treefor immutable per-node JAX arrays.Schemafor field shape and dtype validation.@hx.upand@hx.downfor message-passing sweeps.- Newick helpers for importing and exporting rooted trees.
hyperiax.utils contains pure-JAX numerical helpers, including ODE and SDE
solvers used by the prebuilt guided-inference routines.
hyperiax.prebuilt contains focused implementations for common tree workflows:
phylo_meanfor weighted phylogenetic means.bffgfor Backward Filtering Forward Guiding on discrete Gaussian and continuous SDE edges.
Tutorials and API reference are available in the project documentation:
- Quickstart and sweep-writing tutorials under
docs/source/notebooks/. - Public API reference under
docs/source/api/.
The BFFG implementation follows:
van der Meulen, F. H. & Sommer, S. (2025). Backward Filtering Forward Guiding. JMLR 26(281), 1-51. https://arxiv.org/abs/2505.18239
Hyperiax is maintained by CCEM, University of Copenhagen. For technical questions, please open a GitHub issue or contact Stefan Sommer.
