Repository navigation
JCT reform batches: give each batch engine the reform system alone - #1773
Merged
Merged
Conversation
Target compilation's JCT reform batches pass both tax_benefit_system= and reform=, so policyengine-us 2.2.1 clones the reform's system for every batch engine and gives each a baseline branch. These tests require each batch engine to get the reform system alone, with no system clone per batch, and require the two refusals that replace the baseline branch: a reform system that moves a behavioral-response parameter, and a batch engine that computed a formula reading the baseline branch. A real-engine test compares every shipped JCT reform's household income tax, byte for byte, with the construction that passes reform= as well. The shared fake engine now computes under the reform its system was built with and carries a baseline branch only when given reform=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Target compilation constructed each JCT reform batch engine with both tax_benefit_system=reform_system and reform=reform. Given both, policyengine-us 2.2.1 clones the supplied system on every construction (SPMSimulationMixin._prepare_spm_system -> clone_spm_system), applies the reform again to the clone and adds a baseline branch that copies every input array: 11 reforms x 177 batches = 1,947 clones in a release build. Each batch engine now gets the reform system alone, as the post-export scorer's do, so the reform's batches share its policy and carry no baseline branch. Two refusals stand in for that branch, reusing the scorer's lists: before a reform's first batch engine, a reform system that moves a labor-supply or capital-gains response parameter off baseline is refused; after each batch, an engine that computed a POST_EXPORT_BASELINE_BRANCH_READERS formula is refused, at every batch count, so branches are now recorded for one batch too. The household income-tax arrays are unchanged, so the reform cache identity is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1: the byte-identity test ran the reform= construction on the reform system the system-alone batches had already used, so a change those batches left in the shared system would also reach the clones it was compared with. The comparison now builds its own reform system, as the previous code did, and runs first. It runs in two batches to keep its cost down; the clone-count test keeps three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The fake-engine test of the population-aggregate refusal in the JCT loop matched any message naming the Medicaid denominator, which is now also a baseline-branch reader, so it passed with that refusal removed. It now matches the population-aggregate refusal's own message. - The fake ledger records whether each engine got a baseline branch at construction; checking simulation.baseline after release could not fail. - The clone-count test also counts private copies of a shared parameter tree (SharedParameterPolicy.detach_parameters), and requires none. - The changelog gives the identity test's two batches; the docs say the JCT engines, unlike the scorer's, pass no spm= selection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3 nit: the measure names contain dots, which matched any character in the two real-engine refusal tests' patterns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
marked this pull request as ready for review
November 26, 2026 20:48
juaristi22
reviewed
Nov 27, 2026
juaristi22
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 5f414d696: with policyengine-us 2.2.1 the four new engine tests pass here (all 11 reforms byte-identical, no system clone), as do the 471 builder tests; one system clone takes about 3.2 CPU-s on this Mac, so dropping 1,947 of them saves roughly 105 CPU-minutes per release build, and this PR's engine-us legs (65 and 68 minutes) fall within the 58 to 76 minutes of recent runs. Nothing to raise.
juaristi22
added a commit
that referenced
this pull request
Nov 27, 2026
…mitter, the Chronicle rebuild image's roots and US base changes (#931) Main took six pull requests since 5589fae: #1743 (UK cuts publish their build into its own folder through the emitter, and the retired Orrery upload flag goes), #1747, #1737, #1770 and #1773 (the US base build's hash inputs, final export carry, memory profile and system-only JCT reform) and #1769 (the UK Chronicle rebuild's image distrusts the eMudhra roots). The emitter interface moves to 0.18.0; no feed or engine pin moves. Two files conflicted. - tools/run_uk_cut.py: main replaced the staging-branch constant with the emitter publisher; this branch's spine inputs, build-inputs repository and disk and memory floors for dense-spine stay beside it. - docs/agent-guide.md: main's account of publishing through the emitter, with this branch's dense-spine command and the national step's refusal until the atomic-area basis exclusion applies on the national line. The sentence on the tagged publisher's arguments goes, since the cut no longer builds them. The gate contract pins, the stage table, the coverage manifest, the US F0 report and the US pins are current on the merged tree. Checks: with policyengine-uk hidden, as in CI's engine-free job, the tests main's six pull requests change, the cut and full-build CLI tests, the spec-engine loader and the UK graph's binding rules (1,556 pass); the US coverage report and pins, the gate pins, the stage table and the coverage manifest (--check); CI's test plan verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracker task 1.6 · 1 (project "15. US build memory, CPU and run time").
What changes
Target compilation runs the baseline and 11 JCT tax-expenditure reforms over the pool in household batches (177 batches of 2,000 households in a release build).
_reform_household_income_taxbuilds one reform tax-benefit system per reform and constructed each batch engine with bothtax_benefit_system=reform_systemandreform=reform.Given both, policyengine-us 2.2.1:
SPMSimulationMixin._prepare_spm_system→clone_spm_system: the whole parameter tree rebuilt and every variable deep-copied, so each batch starts on cold parameter caches);baselinebranch whose holders copy every input array.That is one clone per reform per batch: 11 × 177 = 1,947 in a release build.
Each JCT batch engine now gets the reform system alone, as
_HouseholdBatchedPostExportScorer._constructalready does. policyengine-us then shares the system's policy across the reform's batches (share_spm_policy) and adds nobaselinebranch. The dataset and every other construction argument are unchanged (still nospm=).Refusals that stand in for the missing
baselinebranchWithout a
baselinebranch an engine scores two kinds of formula differently, so the JCT path now refuses both, reusing the post-export scorer's lists and helper:_refuse_reform_moving_behavioral_responses): before a reform's first batch engine,_moved_behavioral_response_parameterscompares the reform system'sgov.simulation.labor_supply_responsesandgov.simulation.capital_gains_responsesleaves atPERIODwith the engine's shared baseline system, and refuses the reform if any differ. Without abaselinebranch both responses are 0. With one they are 0 at the engine's zero default elasticities.baselinebranch (_refuse_batch_baseline_branch_readers): after each batch, an engine that holds a computed period of anyPOST_EXPORT_BASELINE_BRANCH_READERSformula is refused. This applies at every batch count, so the JCT batches now record branches (_record_engine_branches) for one batch too, not only when the population-aggregate refusal is on. The population-aggregate refusal still reads the root engine and every branch a formula created, including deleted ones; the only engine it no longer sees is thebaselinebranch, which no longer exists.The JCT reforms only replace one variable with a zero formula, so the first refusal cannot fire for them. What keeps their values unchanged is that the engine's default elasticities are zero; the identity test below also checks, on every old-construction batch engine, that both responses are zero. The refusal compares the reform's response parameters with baseline, as the post-export scorer's does; it would not catch an engine whose default elasticities are nonzero (see the decision below).
Both refusals run only when a reform is simulated; a per-reform cache hit reuses the stored vector without them.
Data outputs
Decision 1.1 · 1: outputs stay byte-identical. The real-engine test runs every shipped JCT reform over a five-household fixture in two batches and compares
_reform_household_income_tax's household array with the old construction's (.tobytes()). The old construction runs first, on its own reform system shared by its batches, as before this change. Each reform changes income tax for at least one fixture household. The per-reform income-tax cache identity (_target_materialization_cache_identity, schema version 3) is unchanged: it binds the inputs that decide the vector, not the construction, and the vectors are identical.Engine version
The cloning analysis is for policyengine-us 2.2.1, which
origin/mainpins. Draft #1676 moves the engine to 2.145.3. Whichever of the two PRs merges later should recheck_prepare_spm_systemand reruntest_us_jct_reform_batches.py.Tests
Red commit first (983de0f), then the change (0ef2776). The branch is rebased on
origin/mainat c585965, which already includes #1751 and #1725; neither touches the JCT path.engine_workflow/us/test_us_jct_reform_batches.py(new, policyengine-us):test_jct_reform_batches_match_the_reform_argument_construction: byte-identical arrays for all 11 reforms (about 19 minutes on a loaded Mac; it adds to theengine-usjob, whose slowest leg was 73 of 110 minutes);test_jct_reform_batches_clone_no_tax_benefit_system: over three batches, noTaxBenefitSystem.clonecall and no private parameter-tree copy (SharedParameterPolicy.detach_parameters), against three clones for the old construction;test_jct_reform_refuses_moved_behavioral_responses_on_policyengine_us: a reform that moves the income elasticity is refused by name before any batch engine;test_jct_reform_batch_refuses_a_baseline_branch_reader_on_policyengine_us: an engine that computed the Medicaid state denominator is refused in one batch.engine_free/us/test_us_batched_target_materialization.py: new fake-engine tests for the construction arguments, the baseline-branch refusal (root engine and deleted branch, one batch and several) and the behavioral-response refusal. The shared fake (test_support/microcosm_build/us_batched_target_materialization.py) now computes under the reform its system was built with, and carries abaselinebranch only when givenreform=, as policyengine-us does; itsaggregate_in_baselineoption is removed, since no JCT engine has abaselinebranch now.engine_free/us/test_us_fiscal_refresh_builder.py: the JCT and checkpoint-resume fakes read the reform from the system; the JCT test asserts no batch engine getsreform=.Only these tests, and the existing fake-engine tests that reach the JCT loop through the changed shared fake (28), were run, each by node ID. The new engine-free and engine tests were run against the unchanged builder first and failed there.
Review
Three rounds of adversarial review. Round 1 found no value change on 2.2.1; it found that the identity test compared against clones of the reform system the new batches had already used, fixed in 16464fe. Round 2 found that the fake-engine population-aggregate test in the JCT loop also passed with that refusal removed, an assertion that could not fail, and two wording errors, fixed in 21cc4af. Round 3 found nothing serious; its one nit (unescaped dots in two test patterns) is fixed in 5f414d6.
Decision: behavioral-response refusal
The behavioral-response refusal compares the reform system's response parameters with baseline, as the post-export scorer's does, rather than requiring zero elasticities. Without a
baselinebranch both responses are 0; with one they are 0 only at zero elasticities. So on an engine whose default elasticities are nonzero, this check would not stop a value change; the identity test would catch it in CI on an engine upgrade. Anthony decided to keep the scorer's check, with no follow-up.Other PRs changing this file
Open PRs #1755, #1676 and #1714 change
tools/build_us_fiscal_refresh_release.py; the sibling 1.6 · 2 and 1.6 · 3 sessions change the input-stage batch loops and the post-calibration SSI and Medicaid passes. Whichever merges later rebases.🤖 Generated with Claude Code