JaxMARL-BC Puts 200,000 Households Inside One JAX Function
A compiled PPO loop trains RBC, heterogeneous RBC, and Krusell–Smith economies in seconds, then checks the learned economy against the diagnostics macroeconomists already trust.
- JaxMARL-BC trains hundreds of thousands of economic households inside a single jitted JAX function, then grades the learned economy with the same diagnostics macroeconomists use on solved models.
- The speed comes from one pattern: vmap over agents, scan over time, jit over the whole step, fused into a single XLA program.
- Its real contribution is epistemic: it asks whether an RL equilibrium is a correct economy, not merely whether agents learned something.
- It is a two-star research artifact with calibrated, not estimated, models, so the reported speedups and population sizes are the authors' claims, not settled facts.
A household that learns to save
Give a neural network a household's capital, whether it has a job this period, and a summary of the aggregate economy. Ask it for one number: how much to save. Run two hundred thousand of these at once. Nobody hands them the Euler equation. The question is whether they find it on their own.
That is the move JaxMARL-BC makes. In a standard macro model, a household's saving rule is a known function, solved by dynamic programming or perturbation methods. Here it is a policy network trained by PPO against the household's own lifetime reward. The economy's equilibrium is whatever emerges once every household stops changing its mind.
Most reinforcement learning work in economics stops at "the agents learned something." This project asks a sharper question: is what they learned a correct economy?
Macro's expensive laboratory
Structural macro models are expensive to solve. The Real Business Cycle model is a single-agent problem, but the interesting ones are not. Krusell–Smith adds idiosyncratic employment shocks and aggregate productivity states on top of a heterogeneous population. Solve those with global methods and the cost climbs with every household you add.
Reinforcement learning is a candidate solver for exactly this kind of problem. But an RL equilibrium is only useful if you can audit it. An agent that learned a smooth consumption rule might have learned the right one, or it might have learned a plausible-looking wrong one. The difference only shows up when you check it against invariants that macroeconomists have trusted for decades.
We release JaxMARL-BC as open source.
That audit is the part most RL-for-economics projects skip. It is also the part that makes this repository interesting.
One function, 200,000 households
The entire training step lives inside a single jitted callable. The environment step, the policy forward pass, and the PPO update are not separate Python functions calling each other in a loop. They are one function that JAX compiles into one XLA program.
Three primitives do the work. vmap broadcasts a function across the agent axis, so a single Python call runs every household at once. scan folds the same step over the time axis, carrying state forward without unrolling the loop. jit fuses the whole thing, environment and optimizer included, into compiled code. This is where the paper's reported 75x to 724x speedups against the reference implementation come from, and it is why the population can grow without the wall-clock time exploding with it.
The workflow splits cleanly in two. run.py trains a policy and writes rollouts and metrics to disk. analyze.py runs the diagnostics afterward, on CPU, with no GPU required. Training is the expensive half; auditing is the cheap half, and the project treats them as separate stages rather than one monolithic script.
The receipts: Euler errors, resource constraints, Gini
This is where a fast RL demo becomes a scientific instrument. The diagnostics suite checks the learned economy against the standard numerical-macro toolkit.
- Euler-equation errors measure whether households are smoothing consumption the way an optimizing agent should.
- Resource-constraint residuals check that the accounting adds up across the whole population.
- Krusell–Smith forecasting R² and the Den Haan statistic test whether agents' aggregate forecasts are internally consistent.
- Gini coefficients, Lorenz curves, and top shares describe the wealth distribution the agents actually produce.
One configuration detail is worth pausing on. DiagConfig.n_agents lets you train on a few hundred agents and then evaluate on a much larger population. That works because the policy only ever sees per-agent inputs plus aggregates, so it is size-agnostic. You are not training a policy that memorized a specific crowd. You are training a decision rule that scales.
How it stacks up
JaxMARL-BC is not the only project in this space, but its niche is specific: structural macro benchmarks, independently learning agents, JAX-accelerated scale, and economics-specific correctness checks in one repository.
| JaxMARL-BC | MARL-BC | JaxMARL | AI Economist | |
|---|---|---|---|---|
| Backend | Pure JAX | Reference PPO implementation | JAX | Python, not JAX |
| Model family | RBC, heterogeneous RBC, Krusell–Smith | Same macro model family | General MARL environments (SMAX and others) | Agent-based tax and policy simulation |
| Scale (agents) | Up to 200,000 households (reported) | Hours per run (reported) | Not macro-specific | Stylized economy |
| Economic diagnostics built in | Full suite | Baseline reference | None | Policy-focused metrics |
| Maturity signal | Research artifact, 2 stars (snapshot) | Published predecessor | 855 stars (snapshot) | Established research framework |
Star counts and speedup figures are drawn from the research snapshot and the authors' paper respectively. They are not independently verified here.
What it isn't
The honest framing matters. This is a research artifact with two stars, one paper, and no independent adopters surfaced in the available research. The models are calibrated to match known steady states, not estimated from real data. The 75x to 724x speedups and the 200,000-household scale are the paper's reported numbers, and they should be read that way.
The repository also carries its own loose ends: a stray scratch.py at the root, and a separate llm-sim-dashboard/ sub-application that shares the same requirements file. It is a strong proof of concept and a clean statement of a paradigm, not a platform with a roadmap.
Read it as a case study. The idea is that an economic equilibrium can be learned rather than solved, and that a learned equilibrium can be graded with the same instruments macroeconomists already use. Whether that idea becomes a standard tool or stays a demonstration depends on work that has not been done yet.





