Introducing hybrid-aif: Open source hybrid active inference in JAX
Announcing Hybrid-AIF
Nov 24, 2026
Real robots don't live in one kind of math. A solar rover's position and speed are continuous. Its terrain map is a set of discrete classes. Its camera is best modeled by a neural net. Its mission is a choice among a handful of options that each last dozens of ticks.
The most widely used active inference toolkits are built around discrete math: categorical states and policies. Factor-graph toolkits handle Gaussian and mixed models by message passing and have recently added planning by expected free energy. But inside a Python machine-learning stack, planning over a model that mixes discrete and continuous state, or integrating a learned component like a fitted neural net, usually means writing the glue yourself.
Today we're open-sourcing hybrid-aif, a Python/JAX library for active inference on models that mix continuous, discrete, mixture and amortized (neural) factors, under one objective and one inference engine.
In short:
- One factor-graph language for categoricals, Gaussians, switching-linear mixtures, user-defined nonlinear functions and neural factors.
- Compiled, differentiable models in JAX, where closed-form conjugate updates run alongside gradient- and sample-based inference.
- Actions and parameters are ordinary variables, and agents and environments compose from a single
Systemprimitive. - Planning by expected free energy by default, with information-gain and novelty terms you can switch off per variable.
- MIT-licensed, version 0.22.0.
What hybrid-aif is
hybrid-aif treats an agent as an abstraction over an underlying factor graph, whose beliefs and plans are updated by the inference rule each part of the model calls for.
Mixed factors, one engine. You declare a model from conditional categoricals and Gaussians, Gaussian and switching-linear mixtures, nonlinear functions you write yourself, and amortized neural factors. Where a factor pair is conjugate, inference runs in closed form. Where it isn't, linearized, gradient- or sample-based inference can run on the same compiled JAX graph.
Actions are just variables. Control states and parameters are first-class variables. An actuator kernel links the agent's latent control state to the action actually realized in the world. Planning is then posterior inference over policies, and conjugate learning is inference over parameters, in the same graph.
Systems all the way down. Agents and environments are both built from one System primitive and nest inside each other. A low-level continuous controller is a system. A mission planner that schedules these lower-level controllers is a system wrapping them. A simulated environment is a system too, or the loop can be driven by real external inputs.
Objectives you can take apart. Expected free energy is the default. Its information-gain and parameter-novelty terms can be ablated per variable. Maximum-occupancy objectives are supported; empowerment is on the roadmap.
Scheduling and scoring. Models support batching, layers running at different speeds, and Jacobi, Gibbs or Glauber-style update schedules. A model can be scored by its description length: its variational free energy on a recorded run, plus what its structure and priors cost to state, so you can compare model structures on minimum-description-length grounds. Every term is logged per factor and per policy, so you can see why an agent chose what it chose.
Where it comes from. The discrete core owes a clear debt to pymdp, and SPM and RxInfer.jl are inspirations. On the roadmap is an adaptor layer allowing models specified in hybrid-aif's model description language to run on pymdp and RxInfer backends.
A worked example: mapping a solar field
The demo on our project page is close to home for us. Rovers build a shared map of a 2.5D field, classifying each cell as firm, rough or ice. Batteries charge in sunlight, which depends on shading. Each rover navigates with a forward camera and a GPS-like fix of varying quality.

Two rovers under a joint mission planner*. Plans are plotted as line segments in front of each rover. Each cell is filled in as rovers classify terrain and add to a shared map. S**uns mark optimal charging sites.*
Each rover is a hybrid model: a continuous state, a Dirichlet terrain map, and a neural camera likelihood that is inverted to localize it. A discrete mission tier above the rovers chooses, every 24 ticks, whether each one surveys a sector or goes to charge. Over five seeds, two rovers under the mission tier map faster early and end level with the same rovers planning on their own, and either way sharing one map beats pooling two separate maps. The project page has the replay, the model and the full comparison.
| Map coverage (mean ± sd, five seeds) | Tick 200 | Tick 400 | Tick 600 | Tick 800 |
|---|---|---|---|---|
| Two rovers, one shared map, mission tier | 0.579 ± 0.034 | 0.764 ± 0.048 | 0.832 ± 0.033 | 0.863 ± 0.008 |
| Two rovers, one shared map, no mission tier | 0.457 ± 0.013 | 0.703 ± 0.043 | 0.835 ± 0.050 | 0.866 ± 0.058 |
| Two rovers, separate maps pooled afterwards | 0.373 ± 0.033 | 0.596 ± 0.029 | 0.733 ± 0.027 | 0.797 ± 0.049 |
Coverage is the fraction of the field's 256 cells whose most likely terrain class has posterior probability above 0.6.
Why it matters
The robots we build for solar farms have to fuse noisy continuous sensing, discrete maps and learned perception, and decide when to work and when to recharge. We wanted one place to express all of that and one objective to plan with.
We also think it's useful beyond us. If you work on active inference, hybrid-aif lets you put a neural likelihood inside a principled generative model without giving up closed-form updates where they exist. If you work in probabilistic ML, it gives you planning and actions as inference, with every term logged.
A note on how it was built: most of hybrid-aif's code was written with Claude, under the direction of our maintainers. The design records explaining why each choice was made are in the repo.
Try it
The fastest way in is the Mountain Car quickstart: three thrust levels, 81 four-tick thrust sequences to plan over, and an agent that climbs the hill in about 30 ticks.
git clone https://github.com/noumenal-labs/hybrid-aif
cd hybrid-aif
uv venv && uv pip install -e ".[dev]"
- Project page and solar-rover demo
- Code on GitHub (MIT), including
examples/demo.ipynb - API reference
docs/capabilities.mdfor what's supported today, anddocs/design/for why
What's next
Five items on our roadmap that we think matter most:
- A public query API on the factor-graph layer. The engine already runs on a layer of role-free distributions and inference rules; making this layer fully queryable on its own is a major goal.
- A factor-graph-native planner. The authors of RxInfer have shown that planning by expected free energy can be done purely by message passing on an augmented factor graph, and we'd like to enable this as an alternative to explicit planning algorithms.
- A predictive-coding backend. Inference today picks a local rule per family: closed-form message passing, fixed-point updates, linearization, amortized recognition. Predictive coding adds one more, in which Gaussian beliefs settle by local gradient steps, with a matching local learning rule to follow.
- Posteriors for non-conjugate parameters. Conjugate parameters already carry full posteriors, and neural components are trained by gradient to point estimates. Next is to give those point estimates posteriors too, and to learn the parameters inside user-written nonlinear functions, which are fixed today.
- A real-time streaming contract. You can already drive the loop from your own code, one compiled tick at a time, with live inputs, but we'd like better tooling for more versatile asynchronous, real-time operation.
If you build something with
hybrid-aif, or break it, open an issue. We'd like to hear what's missing.
