Repository navigation
Calibrate the ACS local release on a sparse target matrix and bind district SOI targets (state_cd) - #1053
Merged
Conversation
… state_cd SOI surface (WIP) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s; add the engine-free evaluation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… evaluation to the target-registry checkpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r-district ESS and the top-1% weight share The real-engine smoke on the rebased branch found that #1007's specs carry calibration hierarchies whose target id must equal the spec name, so a renamed carrier cannot keep one. The fixture's district specs now carry production-shaped hierarchies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d calibration outputs to the run identity, check stored carrier rows - District-file-only concepts (charitable, interest paid, QBI deduction) are lifted onto the Historic Table 2 basis by a sibling's two state levels (STATE_CD_LEVEL_BRIDGES), so every state level shares one basis. - weights_latest.npz and calibration_summary.json carry the run-identity digest; resume, the complete shortcut, finalize and package refuse stale or unstamped evidence, finalize re-verifies the checkpoint digests, and materialize removes the previous calibration outputs. - The first-chunk carrier check compares the CSR rows the assembler stored. - The refresh recipe names --cd-holdout-fraction for every state_cd build, 0 included, at full precision. - Development rungs weight drawn households by their stratum's inverse sampling rate and record zero-draw strata. - The reviewed-limitations register is built from the surface receipt (no stale North Carolina text) and names where the holdout is scored. - The CD holdout hash is pinned by golden values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t the level bridge, rungs, binding and ESS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gh the Modal stage plan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…QA and solver settings to the run identity Second adversarial review (REQUEST_CHANGES) fixes: - A (state, concept) rebase factor or level-bridge sibling ratio more than 1.25x from its measure's median across states is dropped and recorded (receipt factor_band.out_of_band). On the pinned feed that is Hawaii's ordinary and qualified dividends, New York's rental income, Utah's tax-exempt interest, and the Wyoming and South Dakota itemized bridges: 34 district rows and 4 bridged state rows. Contract counts updated (25,864 SOI rows, 2,189 blocks); the doc no longer says the bridge "measures exactly" the gap. - Every chunk rebuilds each state parent from its block's stored district rows and refuses any difference, so the carrier check cannot be vacuous. - consumer_export.json records the calibrated H5's sha256 and the run-identity digest, spine_qa.json the digest; finalize and package refuse an H5 or QA evidence from another materialization before any release directory exists. Materialize deletes them and the gate report. - The run identity binds the lean H5; weights and summary carry the solver settings, and resume or reuse under other settings is refused. - Materialize refuses a district row without positive ladder populations for the pro-rata baseline, before the solve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_cd surface is built The reconciliation ran only in the feed-gated test; the builder now refuses its own output if any block fails to add up to a bound parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…link the band's verdicts, check district rows in every mode Second independent review (APPROVE, conditional on CI) findings, all fixed: - A recalibration that stops between writing the H5 and the summary can no longer pair new weights with an old summary: consumer_export.json and calibration_summary.json both record a digest of the calibrated weights (and the export the solver settings), finalize and package require them to match, and a solve deletes every previous output but the resume weights before it starts. - A bridge sibling is distrusted if either band verdict fails: its two state levels, or the rebase of its own district block (the medians differ, since at-large states count only in the first). A sign conflict in the sibling is refused before the band. Wherever the district file has a state row beside its district rows, the two must agree to 1e-6, or the surface is refused as a defect inside the file. - The per-chunk check now covers every mode: state_cd blocks rebuild their named parent bit for bit (a state_cd row without a compiled parent is refused, so the check cannot be vacuous); other modes check each district row against a same-concept state row on its own households. - Finalize and package refuse QA evidence of other bytes; package's evidence checks run before the release directory exists; the H5 path is no longer compared (the sha binds the bytes); solver literals are shared constants; QA reads the run identity instead of rehashing the staging file. - Docs: the bridge comment no longer says "exactly"; the tolerance range is stated against the largest kept gap (1.220) and Utah's (1.316). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…seholds outside their state's block; pin the district file's internal consistency Fourth review (APPROVE, conditional on CI and the feed-gated test): - The "already complete" shortcut now also requires the summary to record the saved weights' digest; a checkpoint summarized before the digest existed is refused with "run without --resume" instead of looping. - A state_cd block that fails to rebuild its parent because households sit in no district of the block now names them (their district is not one of their state's current-plan districts) rather than blaming the carrier split. - The receipt records the district file's internal consistency (blocks checked, largest relative gap); on the pinned feed all 2,193 blocks agree to 4.0e-16, which the feed-gated contract test pins. - Dropped a per-chunk count check that could never fire; docs and changelog scoped (fallback check's shared key, what a solve deletes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and allow for a missing district row The confirmation review's two wording nits on the new refusal message; no behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…checkpoint through finalize and package Closes the test gap two reviews noted (every finalize/package fixture used a pre-sparse identity, so the binding returned early). A consistent checkpoint round-trips; an interrupted recalibration is refused by finalize before any gate report exists, and QA from another materialization by package before any release directory exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
September 30, 2026 15:04
Contributor
Author
|
Merging after every gate held on head 7d536ab:
|
MaxGhenis
added a commit
that referenced
this pull request
Sep 30, 2026
…options into its solver stamp l2_basis and mass_parametrization join _solver_settings, so main's resume and already-complete checks cover them; a stamp written before they existed reads as the historical solve. calibrate_surface takes both with historical defaults. My separate resume guard is dropped in favor of the stamp. 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.
Summary
d487 (Max, 2026-09-27, amended): congressional-district fidelity comes from ACS-based content, not a CPS-clone bridge. The ACS local release already exists (
tools/build_us_acs_local_release.py, 1.59M households). It left district SOI targets out because its materializer built a dense float32 households × targets matrix: 184 GiB for thefullsurface. This PR removes that wall and adds the district surface.target_matrix.npz), row-aligned with Unify calibration diagnostics schema and publication #1007'starget_registry.json, plus a row-alignedtarget_roles.jsonbeside a structure-only lean H5. No dense matrix exists at any point.build_constraint_matrix. Unify calibration diagnostics schema and publication #1007'scalibration_summary.jsonand schema-8 diagnostics are kept.--soi-mode state_cd: the TY2022 SOI district file's district rows on top ofstate, with one vintage per state concept. See "Choices" below.microcosm.build.holdout.hash_holdout_unit).calibration_summary.jsonalso records Kish ESS nationally, per state and per district, ESS over distinct households (household_spine,household_source_id), the top-1% weight share and household-weight share by spine, at design and calibrated weights.--sample-fractionaccepts f001/f004/f010/f025 (the stacked pool's rungs), stratified by spine × district. Drawn households are weighted by their stratum's inverse sampling rate and each spine is scaled to its full mass; zero-draw strata are recorded. Package refuses any rung but f100.run_identity.jsonhashes the registry, roles, matrix and lean H5.weights_latest.npzandcalibration_summary.jsoncarry its digest and the solver settings.--resumeand the "already complete" shortcut refuse other materializations or settings.consumer_export.jsonrecords the calibrated H5's sha256 and the digest, andspine_qa.jsonthe digest. Finalize and package refuse an H5 or QA evidence from another materialization before any release directory exists.The default
statesurface calibrates to the same problem as before (checked below). No release is published or packaged here.Evidence
All numbers below come from runs in this session; paths are under
~/PolicyEngine/_build_artifacts/acs-local-state-cd-20260927/.Real-data dense vs sparse (the 2026-09-23
statecheckpoint, 1,588,854 households × 4,459 targets).matrix_nnzthat run published. The CSR checkpoint is 198 MB.state/dense_comparison.json). A first rerun at 4 threads differed by a median 0.58%, which is thread-order float nondeterminism, not the sparse path. On the fixture, the differential test shows the two paths give bitwise-identical problems and weights.Full-scale
state_cd(engine-free, same checkpoint).state_cd_soi_surfacerefuses otherwise. The three district-file-only families (charitable, interest paid, QBI deduction) have no engine column in that checkpoint and are left out.v2/). North Carolina included, before the band. There are 3,972 state admin targets and 487 population targets, plus 19,215 district rows whose parent is a Historic Table 2 row. Matrix nnz is 24.8M state rows plus 12.9M district rows = 37.7M, and the whole CSR is about 0.45 GB as float32. 2,394 district targets are held out (103 of 860 state × family units).v2/, 2,394 targets in 103 units; lower is better):state_cdcalibrationThe first run (
state_cd/, NC excluded, 2,310 held targets) gave the same picture: 34.2% against pro-rata's 34.6%, and 56.3% for state-only.v2's train fit is loss 0.0298, 94.0% within 10%, ESS 19,664.The band barely touches this evidence.
v2predates the band. On the banded surface, its held-out set loses one unit (Utah tax-exempt interest, 4 targets). Rescored without it, the result isstate_cd33.85% against pro-rata's 34.22% (medians 19.7% and 17.2%), better on 48.9% of 2,390 targets. The band's other change is dropping 30 Hawaii and New York rows from training, out of about 21,000. That would need a re-solve to measure, and I did not run one: it is a heavy engine-free calibration, and the host guidance keeps those off the shared Mac.District targets cut held-out district error by 39% against today's state-only calibration, which is worse than the design weights. Against pro-rata they only tie (mean 33.9% vs 34.2%, median 19.7% vs 17.2%; better on 48.9% of held targets). They win on income-linked families (AGI 6% vs 34%, income tax 3–4% vs 19–21%, ordinary and qualified dividends 26–40% vs 73–92%, itemized deductions) and lose on benefit-linked ones (EITC 40% vs 23%, unemployment, Social Security, medical, IRA, Schedule C, rental). Train fit: loss 0.030, 94.0% within 10% (state-only: 0.016, 97.6%).
Weight by origin. Adding district targets moves household weight off the ASEC donor rows (random geography) and onto ACS rows (real PUMA geography): donor share 68.0% → 48.0%. The design weights split 50/50.
Concentration, as the Route A session asked (
concentration_v2.json). The state-only arm is the 09-23 weights, reproduced bit for bit;state_cdisv2/.state_cdFlag:
state_cdlowers ESS in some places. Relative to state-only it lowers ESS in 17 of 51 states (worst WV −25.5%, NM −17.3%, HI −13.6%) and 99 of 436 districts (worst MN-06 −44%, WA-05 −41%, AR-04 −40%). The median effect is +10.7% per state and +33% per district, and +44% nationally. The cap andl2_lambdaare unchanged: that is the open methodology question (low_effective_sample_size_lambda_zero), and this PR only reports it. The first run (concentration_v1.json) gave the same picture: 18 states and 111 districts lower.Real-engine smoke on Modal, final code (
smoke4-modal/; runacs-state-cd-smoke4c-f004-20260930, commit 7d536ab,--soi-mode state_cd --sample-fraction 0.04 --hh-chunk 700, capped pilot staging, policyengine-us):consumer_export.jsonandspine_qa.json. The weights digest is the same in the summary, the export and the saved weights. The H5 sha is the same in the export, the file and QA's certified bytes. The solver settings match, and the lean-H5 digest matches its file.Choices and why
statealready calibrates to, so astate_cdbuild stays comparable to Build O, Build P and 09-23 state by state.STATE_CD_LEVEL_BRIDGES:return_countfor counts,itemized_deductions_amountoradjusted_gross_incomefor amounts), so every state level shares one basis. Bridge factors: counts median 1.016, itemized amounts median 1.062, QBI amounts median 1.049. The bridge is an estimate: it assumes the measure shares its sibling's ratio in that state. It is stamp-invariant.STATE_CD_FACTOR_BAND).tax_filer_individual_count, which has no state parent in either vintage;congressional_district_geoid__117th_congresscolumn (location v1, coordinated with that session) would make them exact block sums.hash_holdout_unit.target_roles.jsonrecordssigma: nullwith its basis, and the loss is unchanged. A σ-weighted objective is a separate ruling (REPORT recommendation 7).Invariants
Each holds for every input and is tested; P marks a Hypothesis property, D a differential test, F a pinned-feed test.
CalibrationProblemand bitwise-identical calibrated weights.state_fips). At runtime, the first chunk checks one stored row per carrier against its direct row. Every chunk rebuilds each state parent's direct column from its block's stored district rows, bit for bit; a test corrupts only a later chunk and is refused.calibratechecks it end to end).--resume, the complete shortcut, finalize and package refuse weights or a summary that are unstamped or carry another run identity. The digest changes with the staging file, surface, holdout and sample; resume and the shortcut also refuse other solver settings.consumer_export.json's, an export and summary that record different weights, and QA evidence from another materialization or of other bytes.Review
A six-lens adversarial review ran on the rebased branch, with every finding independently verified: 24 confirmed, 2 rejected. All are addressed in 698a343, 74a5fd8 and 65db50b:
--cd-holdout-fraction 0;targets.jsonreferences.A second independent review (
subfleet run --task review --tier standard) returned REQUEST_CHANGES. Its code findings are addressed in d4c66f8 and 6596998:A third independent review approved (conditional on CI). It fixed-checked every earlier finding and raised seven lower-severity ones, all addressed in e190723:
state_cd;A fourth review, of that delta, also approved (conditional on CI and the feed-gated contract test). Its remaining points are addressed in the next commit:
The 1e-6 internal-consistency refusal holds on the pinned feed: all 2,193 district-file blocks match their own state rows, with a largest relative gap of 4.0e-16.
A fifth, confirmation review of c00b096 approved with no regressions. Its two wording nits on the new refusal message are applied in 225fafd.
Coordination
hash_holdout_uniformandhash_holdout_unitbyte-for-byte, so whichever PR lands second merges clean.Decisions for Max (queued as d619, d620 and d621; not needed to merge this opt-in mode)
state_cdis opt-in; the default surface is unchanged. Using it in any build or release is a methodology call:state_cdrelease would bind rows from a file the feed stamps a year late (Read restamped Chronicle facts at their data year before aging #1030), rely on the defect register while Rebase congressional-district capital gains onto Table 1.4 and drop mislabeled CD SALT and PTC columns on the full surface #1040 is unruled, and map rows through the 117th→119th population crosswalk.state_cdties pro-rata (34.2% vs 34.6% mean error). Thecd_holdoutgate is report-only, so a release needs a threshold.Not in this PR
state_cdrun through the engine. No existing staging H5 passes the current reviewed-null contract (is_spm_independent_minor_role, chip filed), and staging has to be rebuilt first. Materialize RSS is now the staging frame plus one engine chunk, and the dense-checkpoint jump from 55 GB to 78 GB is gone.axiom: n/a: calibration infrastructure and target-surface selection; no policy rule changes.
🤖 Generated with Claude Code