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.

9 min read • View on GitHub • More from danmonuni

An aerial view of a vast grid of small houses stretching to a stippled horizon, each house containing a tiny figure at a ledger. Thin lines run from every house to a single large engine block at the center of the grid, which has pistons, a flywheel, and a plate engraved with a loop arrow inside a square. The illustration literalizes the headline: 200,000 households, one compiled training function, with the spokes standing in for vmap broadcasting across agents.
Many households, one function. Every house in the grid feeds a single compiled training step, and the whole population updates together.
Key Takeaways

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.

Daniele Montagnani, Andrea Coletta, Antonietta Mira, and Aldo Glielmo, Paper authors · JaxMARL-BC (arXiv 2610.28907)

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.

How pure-JAX training collapses two nested Python loops into one compiled program. vmap handles the agents, scan handles time, jit fuses the rest.

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.

A close-up of an economist's desk: on a single sheet of white paper the Euler equation is hand-lettered in fine ink notation, a small circled residual value sits in the margin, and brass dividers measure the gap between a drawn consumption path and a smooth reference curve, with a fountain pen resting across the corner. The illustration stands for the moment a learned policy is graded against the Euler equation, which is what turns an RL equilibrium into an auditable economic claim.
The Euler error is the moment RL becomes economics. A learned saving rule is measured against the condition a rational household is supposed to satisfy.

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-BCMARL-BCJaxMARLAI Economist
BackendPure JAXReference PPO implementationJAXPython, not JAX
Model familyRBC, heterogeneous RBC, Krusell–SmithSame macro model familyGeneral 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-specificStylized economy
Economic diagnostics built inFull suiteBaseline referenceNonePolicy-focused metrics
Maturity signalResearch artifact, 2 stars (snapshot)Published predecessor855 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.