Skip to content

Unify the engine for singles and households and support staged decisions - #670

Open
hmgaudecker wants to merge 68 commits into
mainfrom
feat/one-engine-path
Open

hmgaudecker wants to merge 68 commits into
mainfrom
feat/one-engine-path

Conversation

@hmgaudecker

@hmgaudecker hmgaudecker commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Closes #679.

Singles and households now use one solve and simulation engine. A regime defined with a plain utility function has one member, "self". The PR removes the separate single-agent kernels and query branches and adds support for several decisions within one economic period.

Model and API changes

  • One member axis. Every value array has a trailing member axis. Singles use the coordinate "self" and keep the simulated column value. Regime.members replaces Regime.member_axis.
  • Stages within a period. Declare stages with Model(stages={stage_name: (regime_name, ...)}). User functions receive economic period and age. A step identifies one stage of one period. Model queries take period= and find the regime's step. Solution accessors take step=. Staged simulation results include a stage column.
  • Stage transitions and composition actions. An edge lands at the target's next occurrence. Solve, simulation, and policy lookup use that landing step. Supplied shock paths use the starting regime’s column on entry and each selected destination’s column on transition. A composition action into a later stage checks feasibility at the landing state. The destination can use its own shocks in utility and constraints. Its published value integrates those shocks, and feasibility uses the destination's shock nodes. Later-stage composition destinations require GridSearch.
  • Household preferences and execution. Aggregators and certainty equivalents accept member-keyed mappings. Household solves stream action blocks, and household taste shocks can coexist with current-period shocks. Endogenous-grid solvers consume the common member axis for one-member regimes and take a bare aggregator and certainty equivalent.
  • Saved formats. Solutions, fragments, simulation results, snapshots, and captures use new format versions. Regenerate files written under the previous formats. Model fingerprints change, and SOLVER_API_VERSION is 5.
  • Guarded archive replay. Budgeted native replay uses the detached value the archive loader creates after checksum verification and copy admission. The archive cache and replay bank can coexist, so full-size replay still needs separate memory admission.

Collective model names

Before Now
Regime(exit=Exit(targets=...)), ExitTarget Regime(composition_action=CompositionAction(destinations=...)), Destination
Unilateral(compares="each_action") PCOnActions(tie=...)
Unilateral(renegotiate=Renegotiate(state=...)) PCOnWeight(state=..., tie=...)
Unilateral(compares="optimum") PCOnWeight(tie=...)
MutualConsent(settle=Settlement(...)) MutualConsent(transfer=Transfer(...))
n_subjects, subject_id, subject_batch_size, subject_devices, simulation_sharding="subjects" n_agents, agent_id, agent_batch_size, agent_devices, simulation_sharding="agents"
lcm.exits, parameter keys exit and settle lcm.composition_actions, parameter keys composition_action and transfer

Composition outside values are evaluated at the destination's landing state with the information available to the decider. The PR also aligns tie-breaking, minus-infinity values, and starts whose only feasible choice is a composition action. See the changelog for the full migration and behavioral details.

Verification

The stage audits and regression tests cover landing steps, the economic clock, feasibility, and destination shocks. The retained test suite includes the independent staged-game and numerical oracles. The deletion review removed 1,112 collected cases across 37 affected test files, including temporary engine-migration cases and repeated parameter combinations. The CI workload manifest was regenerated for the retained tests.

Performance against main

Historical A100 float64 measurements used an empty compilation cache in both arms.

Benchmark main PR branch
French and Jones, full grid, warm solve 16m 53s 16m 52s
French and Jones, cold solve 38m 24s 39m 41s
French and Jones, device peak 42,288 MiB 42,288 MiB
Mahler and Yum, warm solve and simulate 4.86 s 5.06 s
Mahler and Yum, cold 27.2 s 31.1 s
Mahler and Yum, device peak 4,728 MiB 4,728 MiB

Both models used the same block widths in the two arms. The French and Jones values and simulated panel matched bit for bit. Issue #678 tracks the cache asymmetry in the automated benchmark comment.

Follow-ups

The #679 fix covers shocks drawn by the later-stage destination. Supporting endogenous-grid destinations would require publishing per-state feasibility alongside values. The later-stage edge parameter validation and invariant-component metadata observations in #679 remain follow-up work.

The existing follow-ups remain open in #671, #672, #673, #674, #675, #676, #677, and #678.

hmgaudecker and others added 7 commits November 24, 2026 14:16
A private switch, off by default, builds a regime declared with a plain utility
function on the household kernels with the one member "self". With it on, value
arrays carry a member axis of length one, the result column keeps the name
`value`, and a route that names no role lands on that member, so
`lcm_examples.collective_household` forms and dissolves couples as before. With
it off no program changes.

The health state of `lcm_examples.precautionary_savings_health` stays on its
grid: exercise closes part of the gap to full health and work halves health.
Its regression archives are not regenerated yet.

`tests/test_single_on_household_path.py` compares both paths on four models:
values within 16 units in the last place and identical discrete choices.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
With the measurement switch on, a gated edge reads its target, fallback and
source members from the engine's member axis, so a single lands on the member
"self". The rule for a member's copy of a name (`value`, `utility`, `V_target`
for "self", `<name>_<member>` otherwise) and the rule for the member a route
lands on are each stated once, in `regime_building/collective.py`.

`tests/test_single_on_household_path.py` gains four gated-edge models and two
single-agent exits; all agree bitwise with the single path at both precisions.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
`scaled_lottery_mean` computed each node's exponent, took the largest, and
shifted every node by it: two readers of an array as large as the values at
every node. On the GPU the compiler could keep that array whole, 93 GiB for one
regime of a production model, and more often for a regime with members.

One reduction over the nodes now carries the numerator as a sum with an
exponent and rescales it as it goes; a second does the same for the mass. The
sums have the bits of the old ones for the same order of addition. On the CPU
the compiler adds in a different order than before, so values move by rounding.
A row with live infinities of both signs now gives NaN on the GPU as well.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A household with taste shocks publishes action values, and an exit with
targets for several members demands the member seed like a transition with
several routes does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
While searching for block widths, the planner compiled a candidate and compared
its memory with the budget. When XLA itself ran out of device memory during
that compilation, the solve stopped. Such a candidate now counts as not fitting:
it is compiled once more on its own and then skipped. If every candidate runs
out, the planner raises its own error with XLA's as the cause.

A width fixed by the user, or the only width a core admits, still raises XLA's
error, and so does any other compilation error.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
@read-the-docs-community

read-the-docs-community Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

hmgaudecker and others added 2 commits November 24, 2026 21:12
Period capture and replay, invariant blocking, and the shared own-value read of
an exit query refused a regime whose values carry a member axis. They take it
as they take any other: the value's axis names include `member`, so a blocked
view and a replayed period have the right rank.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
The places that choose a name or a role read a regime's members: the member
"self" keeps the short name (`utility`, `value`, `V_target`) and is no role, so
a start in such a regime carries no `own_member` and a route of that member
carries none. The regime finder reads a recorded member "self" as an
individual.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Benchmark comparison (main → HEAD)

Comparing 1ef251c9 (main) → deb1a469 (HEAD)

Benchmark Statistic before after Ratio Alert
ACA (reduced) warm solve + simulate (reuses compiled code) 1:47 min 1:51 min 1.03
cold solve + simulate (first run, includes compilation) 27:01 min 29:59 min 1.11 ❌
peak CPU mem 10.5 GB 10.6 GB 1.01
Mahler-Yum warm solve + simulate (reuses compiled code) 23.7 s 26.5 s 1.12 ❌
cold solve + simulate (first run, includes compilation) 52.6 s 1:02 min 1.19 ❌
peak CPU mem 1.8 GB 1.83 GB 1.02
peak GPU mem: automatic solve + simulate 643 MB 643 MB 1.00
peak GPU mem: load saved solution + simulate 837 MB 631 MB 0.75
peak GPU mem: solve + save all persistable artifacts 643 MB 643 MB 1.00
Precautionary Savings - Solve execution time 71.6 ms 89.5 ms 1.25 ❌
first call (including compilation) 1.72 s 2.11 s 1.22 ❌
peak CPU mem 1.4 GB 1.41 GB 1.00
Precautionary Savings - Simulate execution time 973 ms 961 ms 0.99
peak GPU mem 640 MB 640 MB 1.00
first call (including compilation) 3.15 s 3.37 s 1.07
peak CPU mem 1.53 GB 1.56 GB 1.01
Precautionary Savings - Solve & Simulate execution time 777 ms 792 ms 1.02
peak GPU mem 3.84 GB 3.84 GB 1.00
first call (including compilation) 4.52 s 5.04 s 1.11 ❌
peak CPU mem 1.49 GB 1.49 GB 1.00
Precautionary Savings - Solve & Simulate (irreg) execution time 805 ms 832 ms 1.03
peak GPU mem 3.84 GB 3.84 GB 1.00
first call (including compilation) 4.62 s 5.16 s 1.12 ❌
peak CPU mem 1.5 GB 1.5 GB 1.00
Iskhakov et al. (2017) - GridSearch Solve execution time 182 ms 248 ms 1.36 ❌
peak GPU mem 120 MB 120 MB 1.00
first call (including compilation) 3.21 s 4.25 s 1.32 ❌
peak CPU mem 1.6 GB 1.68 GB 1.05
Iskhakov et al. (2017) - DC-EGM Solve execution time 768 ms 861 ms 1.12 ❌
first call (including compilation) 5.88 s 6.17 s 1.05
peak CPU mem 1.89 GB 1.91 GB 1.01
Iskhakov et al. (2017) - GridSearch Simulate execution time 1.07 s 1.08 s 1.01
peak GPU mem 891 MB 1.24 GB 1.39 ❌
first call (including compilation) 6.64 s 7.28 s 1.10
peak CPU mem 1.73 GB 1.87 GB 1.08
Iskhakov et al. (2017) - DC-EGM Simulate execution time 1.56 s 1.57 s 1.00
peak GPU mem 891 MB 1.24 GB 1.39 ❌
first call (including compilation) 9.26 s 10.7 s 1.15 ❌
peak CPU mem 1.96 GB 2.09 GB 1.06
Collective Household - Construct execution time 1.87 s 1.98 s 1.05
peak CPU mem 1.44 GB 1.44 GB 1.00
Collective Household - Solve execution time 844 ms 903 ms 1.07
first call (including compilation) 27.3 s 35 s 1.28 ❌
peak CPU mem 1.66 GB 1.73 GB 1.04
Collective Household - Simulate (1000) execution time 1.95 s 2.04 s 1.05
first call (including compilation) 1:52 min 2:17 min 1.22 ❌
peak CPU mem 2.1 GB 2.29 GB 1.09
Collective Household - Simulate (100000) execution time 2.2 s 2.19 s 1.00
peak GPU mem 84.3 MB 84.3 MB 1.00
first call (including compilation) 1:49 min 2:19 min 1.27 ❌
peak CPU mem 2.17 GB 2.38 GB 1.09
SimulationDispatch ('dissolution', 'off') warm simulation time per period and regime (ms) 93.9 ms 84 ms 0.89
backend compile requests on second simulation call 0
SimulationDispatch ('dissolution', 'progress') warm simulation time per period and regime (ms) 95.6 ms 88.9 ms 0.93
backend compile requests on second simulation call 0
SimulationDispatch ('multi_regime', 'off') warm simulation time per period and regime (ms) 64 ms 60.5 ms 0.95
backend compile requests on second simulation call 0
SimulationDispatch ('multi_regime', 'progress') warm simulation time per period and regime (ms) 63.3 ms 66.9 ms 1.06
backend compile requests on second simulation call 0

hmgaudecker and others added 19 commits November 24, 2026 22:49
A solver declares whether it solves a regime of several members
(`supports_several_members`); grid search does, the endogenous-grid family does
not, and that capability is the one check on the number of members. A kernel's
value carries the regime's member axis, so the solver API version moves to 4 and
the fingerprint pin table with it. The solvers read the member's utility by its
name and publish the trailing axis inside the compiled program.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
The integration over current-period shock nodes keeps the member axis, so a
household that observes such shocks and has no exit solves on the grid-search
kernel instead of a query kernel, and a household with taste shocks may observe
them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Every household argmax is one lexicographic reduction: the weighted objective,
then each member's value in declared order, then the smallest action id. Signed
zeros compare equal and a NaN ranks below every number, so the winner depends
neither on the declaration order of the actions nor on the block schedule. A
feasible action whose objective is NaN gives NaN for every member on the dense
and the streamed route alike.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
`scaled_lottery_mean` raises `UnsupportedDifferentiationError` under
differentiation, as the other scaled helpers do. The read ledger, the
candidate-certificate mutation and the query period groups test follow the
source they describe, and a reduction's result in the N-NB-EGM kernel has a
name the carry probe knows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
…ivalent

The regime slots `koopmans_aggregator` and `certainty_equivalent` accept a
mapping keyed by member, with parameters under `koopmans_aggregator_<member>`
and `certainty_equivalent_<member>`; a bare declaration is shared by every
member under the bare key. A household may use a nonlinear certainty equivalent,
additive shocks in its continuation and a `Decoupled` aggregator: it chooses on
the weighted sum of the members' objectives and publishes each member's value.
Intermediates and NaN diagnostics read the solve's own kernels and so cover
regimes with a member axis.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A regime with a member axis streams its solve over action blocks as any other
regime does, takes the one-block route when the action product fits the planned
width, streams its simulation decision, and may partition its actions over
devices. The dense-only disposition for households and the refusal to partition
them are gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
…egimes

Another regime's exit may read the decision of a household with taste shocks,
and such a household may declare its own exit: the decider's logit runs over its
kept stays and its exit payoff, and every other member gets its expected value
under the decider's probabilities.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
The aggregate, grouped-mapper and process-grid certificate tests pin the
registered population of 409 mutations and its digests, as the grid-search
certificate test does.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
`Model(stages={stage: (regimes, ...)})` orders the regimes of a period into
stages. `period` and `age` are economic time in user functions, parameters and
results; the engine links the stages of a period without discounting, a
transition lands in the next stage, and the simulation frame of a staged model
carries a `stage` column. A Koopmans aggregator or an endogenous-grid solver on
a stage that is not the last of its period is refused, and so is the regime
finder on a staged model.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
…ingle's route

A regime with a member axis shards its continuous states over devices. A
household with taste shocks takes the disposition of any regime with taste
shocks and its policy lookup keeps the intermediates. One wrapper per core
publishes the member axis across periods, the collective merge places both
partials alike before stacking, and the household kernel takes its
aggregator's own arguments.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
dags compares the annotations of every function in a regime, and the lambdas
beside these functions cannot carry any.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A program that reads a value another regime publishes in the same period is
dispatched in a later wave than its publisher; the planner takes the reads from
each program's declared transfers and refuses a cycle by naming the regimes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A formation by `Consent` pays nothing: its target cannot declare a
`utility_adjustment`. An exit observes a shock group whole or not at all.
`MutualConsent` requires a settlement. In a `Decoupled` household a tie in the
objectives goes to the members' stored values in declared order before the
smallest action id.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
An edge of a staged model lands at the first later step that belongs to the
target regime's stage: a later stage of the same period without discounting,
or the next period with one discount. The meaning is a generated pass-through
in every stage the target sits out, with the target's states, no action, no
shocks, zero utility and the identity transition, so every link still leads
to the next step. An exit may read a destination that decides later in the
period; subjects start in their regime's own stage.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
… state

The law of a shock that an exit, a consent rule or a renegotiation observes
may read only parameters and states the projection returns unchanged, so it is
the same at the source's state and at the landing state. One build-time check
covers a group the caller also draws and a group only the destination draws,
and replaces the discrete-only projection check and the pinning refusal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Two regimes pool only if they renegotiate over equal lists: the pooling kind
holds each renegotiated state's name and nodes, in the search and, written
separately, in the layout checker. The value roots of a `Phased` utility,
aggregator, household objective and discount factor are registered for the
solve and for the simulation, so a state read by either variant is kept and
the checker rejects a layout that drops it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A regime that sits out a stage has an engine-generated pass-through that the
user never names: the parameter template, parameters of an edge that skips a
stage, regime codes, declared starts, solved values, raw results, saved files
and error messages show only declared regimes. An unstaged model never enters
the pass-through code, so declaration errors keep their messages.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Every value array ends in a member axis; a single's coordinate is "self".
The measurement switch and its helper are gone. Versions: solver API 5,
saved-solution schema 4 and format 4, fragment format 3, fingerprint
tag 9, chunk-profile tag 6. A saved simulation result carries a format
version and older files are refused.

A household query without action axes reads its one candidate directly,
and the weighted objective only selects the action, so derivatives pass
through the published value.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
hmgaudecker and others added 2 commits November 26, 2026 12:39
… period

`Model.n_periods` and the result's `n_periods` count periods; `Model.n_steps`
counts steps, and `Model.step_of`, `period_of_step` and `stage_of_step`
convert. `period=` on `Model.lookup_policy`, `state_grid` and
`initial_state_bounds` is the economic period.

What is indexed by step says so: `SolutionResult.value`, `value_array` and
`value_frame` take `step=`; `SimulationResult.step_to_regime_to_V_arr`; the
reachability queries; `SolutionMetadata.n_steps`, `ArtifactRef.step` and the
saved keys `n_steps`, `step` and `last_completed_step`, inside the format
versions this pull request already moved; the solver API contexts.

Messages print the period, and the stage of a staged model, where they printed
a step.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
The summary check of the starting states called a type-checked function for
every subject, which cost about 2.6 microseconds per subject (3 s for a
million). One array test per regime replaces the loop.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
hmgaudecker and others added 3 commits November 26, 2026 14:34
The engine passes the step to user functions, and a staged model wraps
each function so that it reads the period of that step. The test breaks
four kinds of law in one period only and asserts that validation reports
that period.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
…-pass lottery mean

The household reduction ranked every regime's actions on (objective,
member values, action id) and read the objective a second time for the
NaN rule. The compiler then stored the action values for every cell and
action, the planner refused the widths that main chooses, and a warm
call repeated the width search (Mahler and Yum, V100: warm 23.7 to
42.2 s, cold 67 s to 4:33 min, device peak 0.6 to 1.3 GB).

- The NaN flag is an operand of the same reduction, for every regime.
- A regime with one member has no tie keys; its solve reduces on the
  value and the NaN flag, its decision also on the action id. This is
  the second place that looks at the number of members.
- The lottery mean is the two-pass form again; the one-pass form cost
  1.3 s per warm call on an A100 for the same model.
- Values across action-block widths, across devices and against the
  stored archives agree within 8 ULP with identical discrete choices;
  the archives are regenerated (largest change 2 ULP).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
- Rules: PCOnActions (participation constraints on actions; what
  Unilateral() was by default), PCOnWeight (participation constraints on
  the Pareto weight, with or without a weight state), MutualConsent with
  a Transfer. Unilateral, Renegotiate, Settlement and the keyword
  compares are removed.
- Regime(composition_action=CompositionAction(destinations=...)) with
  Destination replaces Regime(exit=Exit(targets=...)) with ExitTarget;
  module lcm.composition_actions; parameter keys composition_action and
  transfer.
- An agent is one person; a member is an agent's position in a regime
  with several agents: n_agents, agent_id, agent_batch_size,
  agent_devices, simulation_sharding="agents".
- Documentation, messages and docstrings use: the decision on the
  composition, the value of the outside option, Pareto weight, transfer,
  a regime with one member.

No value changes. Model fingerprints change because class and field
names enter them; four identity strings that seed draws or name
compiled programs keep their bytes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
hmgaudecker and others added 4 commits November 26, 2026 18:53
- A solve without compilation on several devices failed in the
  value-only reduction: the winner's missing id was a free constant.
- Two device layouts, a ceiled block width, a kept-intermediates lookup
  and a four-device capture are different compiled programs from their
  references: their tests assert equal choices and values within 8 ULP
  (per period back from the last one for the two-block solve, where a
  last-bit difference compounds). A replay still reproduces the solve
  its capture came from bit for bit.
- aca-model pin moves to c87fd32b9, which has n_agents.
- Model functions in the age-specialized tests are named and annotated.
- Text: a member who must consent, not a deciding member, for the
  decision on the composition; member index kappa in formulas.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
With the member axis carried through the two-pass mean, the GPU compiler
stored each node's exponent between the passes: one integer per cell,
action and lottery node (French and Jones, A100: compiler peak +13.5 GiB
in the working-age regimes, device peak 51.7 against 42.3 GB on main,
narrower action blocks in four periods). The mean is now taken per
member and the results are stacked; the compiler memory of every regime
equals main's at fixed widths.

The aca-model pin moves to 93dadb903 (same code, its CI runs against
this branch).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
Where every alternative is worth minus infinity to the deciding member,
a logit has no choice probabilities. The solve and the regime's own
simulation already treat such a node as worth minus infinity to every
member and raise when a simulation reaches it. A query on behalf of an
agent who arrives there through a composition action took the first
alternative and published its stored value instead. The shared draw now
takes no alternative, and the simulation raises NoFeasibleActionError.
Without taste shocks, a separate objective at minus infinity still acts
by the stored values.

Also: a helper defined twice in one test file had made an older test
pass for the wrong reason; three more identical duplicates are removed.
The reference page says that solvers other than GridSearch are refused
for a regime with several members.

Found by the external audit of round 2 (F7, H-R2-TEST-SHADOW, H-R1-DOC).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
…eclaration

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
@hmgaudecker
hmgaudecker marked this pull request as ready for review November 27, 2026 00:49
…s destination

A composition action whose destination sits in a later stage of the period
reads the destination's published value at the landing state. That value
does not say whether the destination has a feasible action there, and the
read counted every landing as available. So a regime with several members
could separate into a state where one member has no feasible action, and
it published a value where no outcome exists.

The read now also evaluates the destination's constraints at the landing
state, over the destination's action grid, as a read of a destination in
the same stage does. A destination that is feasible and worth minus
infinity stays available.

For that the destination of a later stage is admitted by the same rule as
one in the source's own stage: GridSearch over its whole action grid. A
later-stage destination solved by an endogenous-grid solver built before
and is now refused when the model is built.

Found by the external audit of the stage object (track stages, round 0, F2).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
hmgaudecker and others added 3 commits November 27, 2026 07:52
…e once

Four defects of models with several decisions in one period, each observed
before the repair:

- A policy lookup read every target at the next step. It now reads each
  target where the edge into it lands, by the same function as the
  simulation, so a lookup works when an edge skips a stage or crosses into
  the next period.
- A regime with composite states that sits in a later stage was started in
  the first stage of its period, missed its edge, and made a reachable
  state infeasible. It now starts in its own stage.
- The check whether a composition action is open at a period converted time
  twice for a predicate that depends only on the period. An action that
  opens later lost its parameters, and a closed action was kept.
- The transition law of a member of a composite state got the period where
  it expects the step and converted it again, so a law that reads the
  period moved the state to the wrong value.

Found by the external audit of the stage object (track stages, round 0,
F1, F3, F4, F5).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K77bhs11cpunKfPpouVQHT
A composition action in an earlier stage reads the destination's published
value. Keep the destination's shock plan at its own occurrence, where the
landing check needs the physical shocks for its constraints. Require a
feasible action at each shock node with positive weight.

Addresses part 1 of #679.
@hmgaudecker hmgaudecker changed the title Run singles and households on one engine path Unify the engine for singles and households and support staged decisions Nov 27, 2026
@hmgaudecker
hmgaudecker requested review from mj023 and timmens November 27, 2026 19:32
The native archive loader verifies the payload and admits a private copy
of its cached leaf. Return that copy from the guarded store path.

Exercise cold and preloaded archives, exact replay, independent buffer
lifetimes, unchanged archive bytes, and refusal before copy dispatch.

Decision: ekl-guarded-replay-copy-pr670-20261128

@mj023 mj023 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just found one small correctness bug when combining shock_paths and stages. For the future it might be good to split large renames from technical PRs, so that the diff does not blow up so much. Rename PRs can then be merged without review.

1. shock_paths read the wrong column on an edge that skips a stage. simulate.py:1437 reads the supplied draw at step + 1, but the edge lands at landing_step. With stages a: (alpha,), b: (omega,) and alpha → alpha (a discrete health lottery), the value held at step 2 comes from column 1 and the value at step 4 from column 3. Columns 2 and 4 are never read, so an invalid code there passes silently. _agent_occupancy also advances agents to step + 1, so it loses them once their target sits out that step: no later column is validated, an invalid code in a read column only fails as an InvalidStateTransitionError on the law, and a path one column short is filled with code 0. The docs say the transition into a step reads that step's column, so I think the read, the occupancy and the lag-1 declarations in _shock_declarations should all use landing_step. Since targets of one source can land at different steps, the supplied argument would need to be per target. No current test combines shock_paths with stages.

2. Two deleted tests I'd keep. Nothing that remains covers what they check:

  • test_egm_solver.py::test_egm_agrees_with_dense_grid_search is the only check of plain EGM against a solver that doesn't invert the Euler equation, and this PR changes how EGM publishes its value.
  • test_decoupled.py::test_ev1_simulated_choices_follow_the_acting_selfs_probabilities is the only test of simulated choice frequencies under Decoupled, while decoupled.py changes substantially.

Bind target-specific operands for staged paths and validate the columns
reached through the simulation graph, including entry in a later stage.
Restore the independent dense EGM comparison and Decoupled taste-shock
frequency check.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Staged models: composition actions into a later stage, two gaps left after #670

2 participants