Repository navigation
Score post-export baselines in one merged pass and pre-OBBBA law once - #1725
Conversation
…ling) Engine-free tests for microcosm#1595's post-export scoring change: - the five planned consumers' baselines come from one batch-outer pass over the union of their plans, with outputs, served arrays and the manifests' post_export_scoring block unchanged; - _open_post_export_scorer registers the recorded plans; - each served baseline still refuses keys outside its own plan; - a consumer opened with a plan other than its registered one is refused; - merged values are dropped once no unserved consumer planned them; - a failed merged pass falls back to each consumer's own pass; - prefetch scores several keys of one reformed simulation in one pass, counted once by the dry run; - reform validation scores the pre-OBBBA state once (53 passes with a release fit, from 54); - the guard sweep's baseline worker registers its plans. A slow policyengine-us test checks byte identity of the merged baseline and of the shared pre-OBBBA pass against separate passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Post-export scoring ran one baseline pass over the written H5's household batches for each of its five stages (the reform-coverage smoke, reform validation, demographics and the two held-out reports): 885 batch engines on a national export. The scorer now registers the plans recorded before export, scores their union in one pass in ascending period order, and serves each stage exactly its own keys, dropping merged values once no stage still to be served planned them (177 batch engines). Each served baseline still refuses keys outside its own plan. A stage opened with a plan other than its registered one is refused. If the merged pass raises, every stage scores its own plan as before, so a key that only one held-out report planned fails that report alone. Each stage's recorded baseline_passes stays 1. Reform validation scored the pre-OBBBA state (every OBBBA provision reverted) once per OBBBA group. It now asks one simulation for both groups' totals; the batched reform's new prefetch scores them in one pass, and the dry run counts that pass once. Reform validation's recorded reform_passes and reform_systems drop from 54 to 53; reform_validation.json is unchanged. The guard sweep's baseline worker registers its plans too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The slow tests record each pass's label, so a fallback to separate passes fails them, and the fixture gives one person a taxable estate so the shared pre-OBBBA pass's estate tax is nonzero. - A failed merged pass frees its partial values before the fallback pass. - A consumer is refused a plan other than its recorded one when the recorded plan is empty, and after the merged pass has failed. - The build log says when a consumer's baseline came from the merged pass. - The served baseline's prefetch refuses keys outside the plan. - reform validation reads the pre-OBBBA state's groups in ascending period order on a simulation without prefetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The fallback after a failed merged pass runs outside the exception handler, so the failed pass's traceback and the per-batch values its frame collected are freed before the first consumer's own pass. - The scorer keeps every registered plan for its refusal, so a consumer whose recorded plan was empty, or any consumer after a failed merged pass, is refused a plan other than its recorded one. - A consumer served from the merged pass says so in its build log summary; its recorded baseline_passes stays 1. - The served baseline accepts prefetch, refusing keys outside its plan, as the dry run's recorder accepts it. - reform validation reads the pre-OBBBA state's groups in ascending period order, so a simulation without prefetch never computes an earlier period after a later one. - The build rule doc says how a fallback shows in the build log, that the merged pass holds every stage's baseline arrays at once, that the smoke's telemetry stage time now includes every stage's baseline work, and which plans the sweep tool's merged pass covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The release harness's fake scorer gives its consumers baseline_from_merged_pass, which _score_post_export_consumer now reads; without it the two held-out reports in the green harness runs wrote "unavailable". - A failed merged pass's partial values held in a reference cycle are freed before the fallback pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A full garbage collection runs before the fallback pass, so a failed merged pass's values held in a reference cycle are freed first. - The build rule doc says the merged pass runs in the first stage opened (the smoke unless skipped), that its batch engines compute every stage's keys, that a failed merged pass costs its time on top of every stage's own pass, and that tools/probe_us_post_export.py still scores each stage's baseline separately. - The changelog notes that the probe tool's plan comparison against a release built before this change reports reform validation's 53 against 54. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A merged-pass error whose text cannot be formatted still leads to each consumer's own pass, and the merged pass is not tried again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A failed merged pass is marked failed before its error is printed, and an error whose text cannot be formatted prints its type, so the fallback holds and the merged pass is not tried again. - POST_EXPORT_SCORING_METHOD's comment says a regrouping of keys into fewer passes that leaves every value byte-identical keeps the method. - The test helper module's docstring names the merged pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The source-spine blindness check treats an unannotated parameter as a possible table and refuses an index into it, so the lambda key failed test_runtime_population_operators_are_source_spine_blind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts resolved by keeping both sides: - _BatchedPostExportReform keeps main's finished-reform refusal and its removal of each reform's rule modules, and this branch's prefetch, which scores several keys of one reform in one pass; - the scorer keeps main's open-reform tracking and this branch's registered baseline plans; - the test helper _scorer takes both baseline_plans and variables_dir; - both branches' new tests are kept. The slow pre-OBBBA test reads the shared pass's values before opening the next reform, since opening it now finishes the earlier one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22
left a comment
There was a problem hiding this comment.
Reviewed at 44e418562. The shared baseline pass and the single pre-OBBBA pass leave every scored value unchanged, and the branch merges cleanly with current main. Nothing on our side blocks it.
A quick check on order: is this still going in after #1722? The two conflict in tools/build_us_fiscal_refresh_release.py and docs/us-release-build-rule.md, and #1722's recorder has no prefetch, so the rebase needs to add one that counts the pre-OBBBA state as a single pass and to re-pin #1722's planned reform-validation count.
What I checked
- Each stage gets exactly its recorded keys, merged values are dropped once no remaining stage needs them, and a failed shared pass falls back to per-stage passes.
_assert_reform_keeps_baseline_responsesnow runs once per period instead of once per key. It reads only the period, so it refuses the same reforms.- The dry run counts a
prefetchas one pass, as the scorer runs it. - None of the 75 commits
mainhas gained since your base touch the post-export code,reform_validation.py, the sweep or the lock. - 135 engine-free tests and the two slow byte-identity tests on policyengine-us 2.2.1 pass locally, and CI is green.
The next national build will show the shared pass's peak, since each batch engine now computes 97 baseline keys instead of at most 75; that needn't hold up the merge.
#1722's engine-free dry run records every request through _RecordingPostExportSimulation and counted one reform pass per request. This branch's prefetch scores several keys of one reformed simulation in one pass, so the merged recorder takes prefetch too: - it records the keys not asked before in ascending period order, as _BatchedPostExportReform.prefetch computes them, and counts the call as one pass (_dry_run_post_export returns that count); - it refuses a prefetch of a reformed simulation after the next one opened, as it refuses a calculate. Re-pins for the shared pre-OBBBA state, which reform validation now reads for both OBBBA groups from one simulation in one pass: the planned reform-validation count on #1722's fixture goes from 64 to 63 for the same 64 requests, and the descriptor test allows that one shared pass and simulation. The recorded output digests are unchanged. A new test covers the dry run's prefetch order, count and refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. #1722 merged first, so this PR took it in (855a37d): the dry run's recorder now takes |
…nd, the table_copies hash binding, and US and NZ changes (#931) Main took five pull requests since e29843d: #1734 (New Zealand's receipt target cap), #1749 (staging hands a run's files over at its start and its results at its end, with no upload interval), #1761 (the UK stage, population and calibration hashes bind microcosm.frame.table_copies), #1725 (the US post-export merged baseline sweep) and #1750 (the US base engine lock checked once). No UK feed or engine pin moves. Eight files conflicted. - uk_runtime/graph_calibration.py, graph_kernels.py and graph_population.py: #1761 binds table_copies into the stage, population and calibration hashes; this branch already binds it, as frame_table_copies, in every UK kernel that computes through it (bbe3633), so the merge keeps this branch's side. The population kernels #1761 binds are gone on the clone-first spine, so its new test in test_uk_kernel_frame_copies holds the national problem kernel, which copies through context_frame, in their place, with the pool checkpoint kernel as the control. - test_uk_rowwise_candidate: #1749's dense role without an upload interval; this branch's removal of the constituency vintage stays. - The US seed map and seed protocol, the loader's golden spec vector and the US pool test's spec pin, computed on the merged tree, and the US F0 coverage report, regenerated (--check passes, and so does the US re-pinner's --check). The UK gate contract pins, the stage table and the coverage manifest are current on the merged tree. Checks: with policyengine-uk hidden, as in CI's engine-free job, the tests main's five pull requests change, the UK graph's binding rules, the kernel frame copies (main's new test among them), the clone-first nesting, the transport binding rule and identity, the graph parity pins, the spec-engine loader and the Child Benefit stage and gate tests (2,729 pass); the US coverage report and pins (--check); and the UK gate pins, the stage table and the coverage manifest (--check). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Post-export scoring now computes the baseline for all five post-export stages in one pass over the written H5's household batches, instead of one pass per stage. Reform validation now scores the pre-OBBBA state once for both OBBBA groups. Data outputs are unchanged byte for byte. Refs microcosm#1595.
What changes
One shared baseline pass (
tools/build_us_fiscal_refresh_release.py)_open_post_export_scorernow registers the baseline plans recorded before export. When the first registered stage is opened,_HouseholdBatchedPostExportScorer._baseline_forscores the union of those plans in one pass, in ascending period order: 177 batch engines.prefetch;_concatenate_post_export_parts, the population-aggregate refusal and the baseline-branch-reader refusal are unchanged, and now run on every engine of the shared pass.baseline served from the merged pass. A fallback printsPost-export merged baseline plan failed.Pre-OBBBA law scored once (
packages/microcosm-build/src/microcosm/build/us_runtime/reform_validation.py)stacked_obbba_effectsstacks every OBBBA group from the same pre-OBBBA state, in which every provision is reverted.released_weighted_totalsasks it for both totals in ascending period order.prefetch, which scores several keys in one pass. The engine-free run counts aprefetchas one pass, so the planned count still equals the passes run.Microsimulationhas noprefetch, so whole-file callers read the totals one at a time as before.Guard sweep (
tools/sweep_us_post_export_scoring.py)Recorded fields (both approved by Anthony before implementation)
baseline_passesin the manifests'post_export_scoringblock (and the smoke's copy inreform_coverage_smoke.json) stays 1. It now means the one pass the stage's baseline came from, shared unless the shared pass failed. No field was added, so only the build log shows a fallback.reform_passesandreform_systemsgo from 54 to 53;reform_validation.jsonis unchanged.tools/probe_us_post_export.py's plan comparison against a release built before this change will report 53 against 54.POST_EXPORT_SCORING_METHODis unchanged; its comment now says that regrouping keys into fewer passes, with every value byte-identical, keeps it.Evidence
Before implementing: on the 8-household fixture H5 in 3 batches, one baseline pass over the 97 distinct keys served all 103 per-stage arrays byte-identical (values, weights and dtypes) to the five separate passes, in both key orders.
Byte-identity comparison on the fixture H5, origin/main against this branch:
_certify_us_builddoes, with a calibration fit covering every in-sample reform.Results:
reform_coverage_smoke.json,reform_validation.json,demographics.json,us_ssi_social_security_holdout.json,us_medicare_irmaa_holdout.jsonand the plan record incalibration_diagnostics.jsonare byte-identical.post_export_scoringblock: identical, except reform validation'sreform_passesandreform_systems(54 → 53). The planned count also goes from 54 to 53.34be2f7be. Later commits change only the fallback path, tests and docs.Peak memory (RSS) on the fixture:
New tests:
_open_post_export_scorerregisters the plans;prefetchpass counting;test_merged_baseline_and_shared_pre_obbba_pass_are_byte_identicalchecks that the shared baseline pass, and one pre-OBBBA pass for both groups, give the bytes of separate passes. One fixture person holds a taxable estate so that estate tax is nonzero.test_shipped_baseline_plans_match_whole_file_policyengine_usnow serves the shipped plans from the shared pass.test_main_writes_diagnostics_before_post_calibration_gate_failure's fake scorer gainsbaseline_from_merged_pass.Only the tests this change added or modified were run, each by node ID; all pass.
Memory and timing
Review
Three rounds of adversarial review by subagents. None found a change to data outputs. Fixes from each round are in their own commits, tests first:
Not in this PR
tools/probe_us_post_export.pystill scores each stage's baseline separately, so its timings reflect the old pass structure._RecordingPostExportSimulation, which now takesprefetchtoo: it records the keys not asked before in ascending period order, counts the call as one reform pass, and refuses aprefetchof a reformed simulation after the next one opened. On Return every US post-export request as a picklable descriptor #1722's fixture, the planned reform-validation count is re-pinned from 64 to 63 for the same 64 requests, and the recorded output digests Return every US post-export request as a picklable descriptor #1722 pinned are unchanged.Docs: the "Post-export scoring" section of
docs/us-release-build-rule.md, andchangelog.d/1595-post-export-merged-baseline-pass.changed.md.🤖 Generated with Claude Code