Skip to content

Read the SIPP 2023 person file once for the US release's five donor tables - #1686

Merged
anth-volk merged 12 commits into
mainfrom
claude/sipp-csv-parsed-once-9be602
Nov 25, 2026
Merged

anth-volk merged 12 commits into
mainfrom
claude/sipp-csv-parsed-once-9be602

Conversation

@anth-volk

@anth-volk anth-volk commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The US release tool hashed and parsed the 3.73 GB SIPP 2023 file once for each of five donor tables. It now reads the file once, and each stage builds its donor table from the shared December rows.

  • read_sipp_december_person_rows (new module sipp_december_person_rows.py) reads the union of the five donors' columns (99 columns).
  • build_sipp_2023_{financial_asset,ssi_disability,head_start,vehicle,voluntary_filing}_donor replace the per-donor path loaders. load_sipp_2023_ssi_disability_donor stays because the ACS local-area build calls it with a path.
  • _main frees the December rows after the voluntary-filing stage and keeps no donor table in a local variable. The alias sipp_vehicle_donor_path is gone.

How the read keeps each donor's table

The old loaders did not parse the file the same way, so the read works in two steps per 100,000-row chunk:

  1. Tokenize the file with low_memory=True, keeping the requested columns as unconverted text.
  2. Write those cells as a narrow CSV and parse it with low_memory=False, so each column's type is inferred over the whole chunk from the same tokens as a direct parse.

The chunk size is SIPP_PERSON_FILE_CHUNK_ROWS (100,000), the default of both read_sipp_december_person_rows and load_sipp_2023_ssi_disability_donor. Column types are inferred per chunk and the old loaders all read 100,000-row chunks, so the donor tables match theirs only at this size; a test pins it.

The remaining differences between the old reads are kept explicitly:

  • The financial-asset donor gets SSUID as text. The other four get the inferred type.
  • The Head Start donor concatenates every chunk, including chunks without December rows, because those chunks' column types affected its result.
  • The vehicle and voluntary-filing donors used low_memory=True. They now refuse a column whose values that parse could have converted differently: text in a column, an integer cell of more than 15 digits, or a negative zero in a float64 column. This refusal is deliberately broader than the cases that actually differ.
  • An SSUID of 309 or more digits used to be read as text by the financial-asset loader, while the other four loaders raised OverflowError. The shared read now raises that OverflowError for all five. Real SSUID values have 12 digits.

The read also refuses a file with a carriage return outside a CRLF pair, or a first row longer than the header, because pandas' row splitting for those files depends on how they are read.

Evidence that outputs are unchanged

  • New tests compare each donor built through the shared read with the donor built from a copy of that donor's old read, on invented files with leading-zero and text SSUID values, blank cells, non-December rows and chunks without December rows. Comparison covers values by bytes, dtypes, column order, row order, index and .attrs.
  • On the real pu2023.csv at the pinned revision (3,726,010,471 bytes, SHA-256 5c30439e…33ee2), all five donor tables from the origin/main loaders and from this branch are identical: values by bytes, dtypes, column order, row order, index and .attrs. The shapes are 20,000 × 20 (financial assets), 9,346 × 21 (SSI), 785 × 8 (Head Start), 16,841 × 21 (vehicles) and 22,296 × 8 (voluntary filing).
  • On an invented file of the real file's shape (5,000 columns, 476,736 rows, 3.73 GB), all five donor tables from the origin/main loaders and from this branch are identical.
  • Six rounds of adversarial review compared origin/main's loaders with this branch on thousands of invented files. The last round found no silent difference and no input the old code refused that this code accepts.

The two test_cached_full_donor_* tests pass against the real file. The pinned Head Start and SSI source audits, which run when the file matches the pins, also held in the real-file run.

Memory and time

Measured on a 32 GB Mac without the US engine installed. With the engine, the SSI donor build also constructs a tax-benefit system, as its loader did before.

Five separate reads (origin/main) Shared read
Process peak RSS, real file (one run) 6,258 MB 1,153 MB
Hash, parse and build time, real file 98 s 21 s to read, under 1 s to build all five
Process peak RSS, invented file 7,784 MB 1,153–1,239 MB
Hash, parse and build time, invented file 94 s 23–24 s to read, under 1 s to build all five

On the real file, the December rows of the 99 requested columns hold 31.3 MB (39,513 rows).

Retention choice. I compared keeping the December rows until the last SIPP stage with building all five donors immediately and keeping those:

Keep December rows (chosen) Build all five donors first
Bytes held between stages 32.3 MB 7.7 MB
Process peak RSS 1,153–1,239 MB 1,158–1,227 MB
RSS between stages 957–1,118 MB 1,020–1,118 MB

Peak and between-stage RSS overlap, and the table difference is about 25 MB. I kept the December rows because each donor's build and any failure stay in that donor's own stage.

Memory held after the read. RSS stays about 0.5–0.7 GB above its pre-read level after the read, although only 32 MB of tables are live. In the origin/main run, RSS during the last two loaders peaked within about 0.1 GB of the level after imports. This is memory the allocator has not returned to the system. I measured it on macOS only, so whether it adds to later stages on the Linux build machines is not known.

Stage timing changes

  • All hashing and parsing now happens in the scf_wealth_inputs stage reported by telemetry.stage(...). The SSI, Head Start, vehicle and voluntary-filing stages only build their tables.
  • A missing column or a bad file now fails at scf_wealth_inputs instead of at the first stage that needed it.
  • The default path still hashes the file twice per run, once in fetch_sipp_2023_financial_asset_donor and once in the read, instead of six times.

Other notes

  • Editing sipp_financial_assets.py, sipp_vehicles.py and ssi_disability_criteria.py moves the seed-protocol source digests, so the second commit re-pins them with tools/repin_us_spec_engine_contracts.py, tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.
  • This edits the same _main call sites as the change that frees release objects after their last use, so whichever merges second resolves that text conflict.

Tests

Run individually by node ID: all of test_us_sipp_december_person_rows.py, the migrated donor tests, the SSI and ACS loader tests, test_main_writes_diagnostics_before_post_calibration_gate_failure in every mode, the re-pinned digest tests, and the module classification and pool import-graph tests in test_us_spine_blindness.py, and test_the_batterys_binding_identity_adds_only_the_leaf_and_its_imports in test_transport_evidence_kernels.py, which now list sipp_december_person_rows. The two test_cached_full_donor_* tests pass against the real file.

🤖 Generated with Claude Code

anth-volk and others added 2 commits November 19, 2026 05:41
The US release tool hashed and parsed the 3.73 GB SIPP 2023 file once per
donor table. It now reads it once: the file is tokenized with low_memory=True,
keeping only the columns the five donors use, and that narrow table is parsed
over whole chunks, so column types match a direct parse. Each stage builds its
donor from the December rows, which are freed after the last SIPP stage.

The vehicle and voluntary-filing donors, whose own reads used low_memory=True,
refuse columns those parser blocks could have converted differently. The read
refuses files with bare carriage returns or a first row longer than the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated with tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 4 commits November 19, 2026 21:33
The new sipp_december_person_rows.py module was missing from the reviewed
list of US runtime modules, so the classification test failed. It reads the
SIPP person file for the five donor builders and treats no population, so it
joins the non-registry modules.

The multi-spine pool tool now reaches it through sipp_financial_assets.py,
so its pinned runtime import graph grows from 86 to 87 modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The transport validation checks registered in TRANSPORT_GATE_REGISTRY import
the us_runtime package, which now reaches sipp_december_person_rows through
the five SIPP donor modules. The test that counts the modules those checks
import found 247 instead of 246, so the module joins
BINDING_MODULES_ADDED_AFTER_BASE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The only conflicts were the seed-protocol and spec digests, which main moved
for the in-place QRF leaf array and this branch moved for the SIPP modules.
They were regenerated from the merged source with
tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's per-target QRF fit and draw (#1667) moved the same seed-protocol and
spec digests as this branch. They were regenerated from the merged source with
tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk requested a review from juaristi22 November 24, 2026 14:25

@juaristi22 juaristi22 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.

Reviewed at 50d70c9c7. The shared read reproduces each old loader's parse, so the saving (peak memory from 6.3 GB to 1.2 GB, read time from 98 s to 21 s) comes with no output change. Two things before merge, and two notes.

What I checked

  • On main, all five loaders read 100,000-row chunks (none of _main's calls overrode the default), the financial-asset donor read SSUID with dtype="string", Head Start and SSI parsed with low_memory=False, and vehicles and voluntary filing with low_memory=True. Each new builder asks source_table for exactly that: ssuid_as_text, include_chunks_without_december_rows for Head Start, and read_in_parser_blocks for the two low_memory=True donors.
  • The refusal for those two donors is sound: a whole-chunk int64 or bool column parses the same in every block, and a float64 column does when its integer cells have at most 15 digits and no negative zero; every other column is refused.
  • The SSI path loader that the ACS local build keeps goes through the same read with only its own columns. It infers the same types, because each column's type comes from its own cells.
  • The sixth SIPP read in _main, load_sipp_2023_tip_donor, reads a different file (SHA-256 1f0bcb8e…), so the person file is now read once.

Before merge

  1. Let the engine-free jobs finish.
  2. This, #1697 and #1683 all edit tools/build_us_fiscal_refresh_release.py, and this, #1683 and #1684 all move the US seed-protocol pins, so whichever merges later resolves the text and re-runs the repin tools.

Notes

  • The 100,000-row chunk is now part of the equivalence: the tests prove it at matching chunk sizes, and _main relies on the default matching the old loaders'. A named constant, or a test that the default stays 100,000, would stop a later memory tweak from changing inferred types.
  • I couldn't rerun the real-file comparison, because the SIPP file isn't on this machine; it rests on your run and the invented-file tests.

Checked

  • 1,452 of 1,460 tests on the touched surface pass locally (macOS arm64, Python 3.14), including the 120 in test_us_sipp_december_person_rows.py, the five donors' tests, the SSI and ACS loader tests and the re-pinned digest tests; the 8 skips need the US engine or the pinned Chronicle feed.

anth-volk and others added 6 commits November 24, 2026 20:02
The equivalence with the old per-donor loaders holds only at matching chunk
sizes, because column types are inferred per chunk, and the release tool and
the ACS local-area build rely on the default. Fails until the constant exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SIPP_PERSON_FILE_CHUNK_ROWS (100,000) is now the default chunk size of
read_sipp_december_person_rows and load_sipp_2023_ssi_disability_donor.
Column types are inferred per chunk, and the old per-donor loaders all read
100,000-row chunks, so the donor tables equal theirs only at this size.
Addresses the chunk-size note in the review of #1686.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated with tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's QRF prediction worker count (#1684) moved the same seed-protocol and
spec digests as this branch. They were regenerated from the merged source with
tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's table operations through adopt (#1683) and build-tool thread settings
(#1696) moved the same seed-protocol and spec digests as this branch. They
were regenerated from the merged source with
tools/repin_us_spec_engine_contracts.py,
tools/generate_us_bundle_from_constants.py and tools/spec_engine_coverage.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's #1697 loads each donor table inside its stage's call, so no local
keeps it. This branch builds the five SIPP donors inline from the shared
December rows, so the merged _main keeps both: the SCF donor loaded inline,
the shared read once, and each SIPP donor built in its stage's call.

#1697's test_main_passes_each_donor_table_straight_into_its_stage now covers
the five build_sipp_2023_*_donor calls in place of the removed loaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk

Copy link
Copy Markdown
Contributor Author

@juaristi22 thanks for the review. All four points are addressed at 8f6daf666.

Before merge

  1. engine-free jobs: both engine-free jobs pass on 8f6daf666, as do the engine-us, engine-uk and other checks.
  2. Overlap with Free large US release-build objects after their last use #1697, Frame: share unchanged columns and check them before writing #1683 and Size QRF prediction workers from joblib.cpu_count() and stop comparing thread counts #1684: all three merged into main first, and this branch now includes them.

Notes

  • Chunk size: SIPP_PERSON_FILE_CHUNK_ROWS = 100_000 is now the default of both read_sipp_december_person_rows and load_sipp_2023_ssi_disability_donor, and test_every_sipp_person_file_read_defaults_to_the_old_loaders_chunk_rows pins it (fb870afe3, 4e64fc1c5, f36316613).
  • Real-file comparison: it ran at b6b560b19. Since then the SIPP modules have changed only by naming that default, with the same value, so the comparison still applies.

🤖 Generated with Claude Code

@anth-volk
anth-volk merged commit dd9dd6b into main Nov 25, 2026
12 checks passed
@anth-volk
anth-volk deleted the claude/sipp-csv-parsed-once-9be602 branch November 25, 2026 18:03
juaristi22 added a commit that referenced this pull request Nov 25, 2026
…he SPI forest release and the shared SIPP read (#931)

Main took seven pull requests since cac12ab: #1724 (each kernel reads
read-only views of its inputs instead of a deep copy), #1690 (the SPI
stage-2 forests freed before each later fit), #1686 (the SIPP person file
read once for its five donor tables), #1697 (release tools free large
objects after their last use), #1726 (a shared worker pool), #1660 (the
County Files ACS donor patch) and #1707 (New Zealand's geography layer
labels). No feed or engine pin moves, so no file is re-pinned.

Four files conflicted, all pins that both sides moved: the US spec-engine
seed map and seed protocol, the UK loader and US spec pins, and the US F0
coverage report. Each is computed on the merged tree, and the coverage
report is regenerated (--check passes; 41/41 inventory checks).

Two of main's new tests needed this branch's code reviewed.
- #1724's scan for writes into shared buffers finds np.add.at in two
  weight folds of the identity tool: _pre_split_household_weights, which
  this branch changed, and _pre_high_value_household_weights, which it
  added. Both write into the copy of the household weights that
  _pre_residential_household_weights makes and _pre_clone_fold and the
  folds pass along, so both findings are reviewed with their digests, and
  the helpers the reasons rest on take theirs, _pre_clone_fold included.
- #1690's SPI forest-release test froze origin/main's SPI output and
  receipts; this branch's keyed draws move them, as the test foresees. The
  macOS arm64 digests are recorded from this code. Linux x86_64's need a
  recording under Docker, which this machine lacks, so those two tests
  skip there and the same-run checks still run. The owner-manager rule
  rewrites owned_company_carries_on_property_business after the draw, as
  it does the trade flag, and on the synthetic fixture's draws it moves one
  drawn person, so the flag joins the targets rewritten after the draw.

Checks: main's changed tests, the pin tests and the kernel-binding test
pass (1,931, then the shared-buffer scan's 99 and the SPI forest-release
test's 48 after the two reviews), and so does the H2 clone-first test at
one and four clones (34).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants