Skip to content

Score US post-export requests in the shared worker pool by default - #1775

Draft
anth-volk wants to merge 28 commits into
mainfrom
claude/pooled-post-export-scoring-605c24
Draft

anth-volk wants to merge 28 commits into
mainfrom
claude/pooled-post-export-scoring-605c24

Conversation

@anth-volk

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

Copy link
Copy Markdown
Contributor

Tracker task 1.4 · 7 (project 15, "US build memory, CPU and run time"): post-export scoring in the shared worker pool, as certification's default.

What this does

Certification's post-export scoring (the reform-coverage smoke, reform validation, demographics and the two held-out reports) took about 93% of a national build's time: about 17,900 policyengine-us runs in one process. It now runs the reform passes in spawned worker processes (microcosm.build.worker_pool, #1726), runs the baseline passes in the certifying process first, and runs each stage again in the certifying process over the results. Every output file and both manifests' consumer records are byte-identical to the serial scorer's.

How the pooled scorer works (_PooledPostExportScorer in tools/build_us_fiscal_refresh_release.py)

  • What it scores: the plan's engine-free dry run already records every request of every stage (Return every US post-export request as a picklable descriptor #1722). It now also records which keys the serial scorer scores together in each reform pass and every reform each stage opens (_PostExportConsumerRequests, held by _PostExportScoringPlan.consumer_requests; the plan's record in calibration_diagnostics.json is unchanged apart from the method label).
  • Baseline passes, in the certifying process (Anthony's decision of 27 November): when the first stage opens, the merged baseline pass (Score post-export baselines in one merged pass and pre-OBBBA law once #1725) runs with the serial scorer's own code, and, if it raises (MemoryError included), every stage's own baseline pass runs next, in the stages' order, where the serial scorer runs each when its stage opens. All of them run before any worker starts, and each batch engine is released before the next, so no baseline engine is held there while workers run. A stage whose own pass raised gets that error when it opens, with the original traceback as a note. Why: in the pooled export probe below, a baseline pass over one 2,000-household batch went over the worker cap on every attempt.
  • The pool: one unit per reformed simulation, holding every recorded pass of it over every batch, in the order the stages run, so a worker builds a reform's rules once, as the serial scorer builds them once per reformed simulation. A build whose stages open no reform starts no pool.
  • Workers (microcosm.build.us_runtime.post_export_pool, _PostExportWorker):
    • read each batch from the scorer's batch file (Keep the US post-export scorer's household batches in files, not memory #1751), refusing one whose bytes changed;
    • score it with the serial scorer's own per-batch code (_score_post_export_batches): one engine per batch, keys in ascending period order, the population-aggregate refusal in a pass over more than one batch, the baseline-branch refusal and the behavioral-response check of a reform pass;
    • return a pass's failure as data, so the pool keeps running; MemoryError is raised, so the pool runs the unit again in a fresh worker;
    • are given this process's policyengine-us lock-check record (MICROCOSM_ENGINE_ABI_LOCK_CHECK_RECORD, US base: check the policyengine-us lock file once per run, and import torch only where it is used #1750), so their import of the release tool skips the lock-file check, and otherwise inherit its environment, thread variables included;
    • refuse to start with a release tool whose bytes differ from the certifying process's (_RELEASE_TOOL_SHA256), so a file changed during a run cannot mix two versions' results.
  • Serving the stages: each stage runs as in the serial path and builds its own reforms (the smoke check keeps recording each list edit's resolved lists from its own build, Return every US post-export request as a picklable descriptor #1722's note).
    • Its baseline is served its recorded plan; each reformed simulation its recorded passes in order.
    • The smoke check's and reform validation's builders now mark each reform with the description they built it from (post_export_requests.described_reform), and each reformed simulation must be opened with the reform the dry run recorded at that place.
    • Anything else (a key, a pass or a reform the dry run did not record, a skipped pass, a consumer opened twice or not in the plan) is refused, so a stage whose requests depended on the values it got back is never served values scored for another request (Return every US post-export request as a picklable descriptor #1722's first note).
    • Each key's per-batch values are joined in batch order (_concatenate_post_export_parts), as the serial scorer joins them.
    • A pass that failed in a worker raises, when the stage asks for it, an error with the worker's exception's class name and message (PostExportUnitFailure.exception()), so a held-out report records the serial scorer's text. A changed batch file raises the tool's own PostExportBatchFileError.
  • Return every US post-export request as a picklable descriptor #1722's other notes: a unit whose arguments a worker cannot unpickle stops with a WorkerPoolUnitError naming the unit (the pool already reads each unit inside a try). A worker spawned from certification runs certification's script again as __mp_main__, which imports the release tool; that is the import the worker needs, so it runs once per worker start (with the lock-check record, about 20-30 s per start on the build machines, 1.4 · 6's estimate).

The default settings (tracker decision 1.4 · 6, decided by Anthony on 26 November)

plan_post_export_workers (post_export_pool.py), with readings from the new microcosm.build.host_resources:

  • Workers: at most min(usable cores − 1, ⌊(0.75 × memory − 3 GiB) ÷ 5 GiB⌋), at least one, and never more than a pool run has units. Usable cores are os.process_cpu_count() limited by a cgroup v1 or v2 CPU quota; memory is the machine's, limited by a cgroup memory limit.
  • Override: MICROCOSM_POST_EXPORT_WORKERS: unset, blank or auto for the formula; a positive whole number for that many workers (1 is one worker, a process of its own); serial for the serial scorer. Anything else is refused.
  • A machine too small for one worker (under about 10.7 GiB): certification refuses before it places the build or loads the H5, unless the variable names a count or serial.
  • Each worker: replaced after 2 units, capped at max(5 GiB, (0.75 × memory − 3 GiB) ÷ workers) of memory footprint; thread variables inherited. A reform unit is one reformed simulation's passes, which is one pass for every shipped stage, so this is the decision's "after 2 reform passes"; a range of the merged baseline pass is a unit too, so a worker that ran one is replaced after one reform pass.
  • Certification prints the plan (workers, planned peak beside the 75% budget, cap), and the manifests' post_export_scoring.execution records it, each baseline pass run in the certifying process (label, keys, wall and CPU time, error) and the pool's report, as run metadata.
  • Where the variable comes from: the operator's shell, or route_a.env, which route_a.sh now exports like the telemetry settings; Route A's supervisor starts the certify stage with the driver's environment (supervise.py, {**os.environ, ...}), with_hf_token.sh execs with it, certification reads os.environ, and spawned workers inherit it. Modal runs no certification. The export probe's command reads it the same way, only when it runs an engine stage.

The method label

POST_EXPORT_SCORING_METHOD is raised once, to household_batched_written_h5_v2, covering the merged baseline sweeps and pooled scoring (decision 1.1 · 1). The plan's record carries it, and certification compares the plan it rebuilds with the build's record, so a build recorded with the earlier label is certified with the code it was built with (the refusal says so).

The export probe (tools/probe_us_post_export.py)

  • records every engine stage's plan before it opens the scorer and registers it, with the two held-out reports' plans, as certification does, so its baseline is certification's merged pass (a stage whose dry run fails is left out and fails alone; a held-out report's failed dry run is a fidelity verdict);
  • scores in the pool by default from the command (ExportProbe(post_export_pooling=...)), and writes one passes.jsonl line per pass, naming the process that ran it: the baseline passes run in the certifying process, timed as in the serial probe, and each reform pass a worker ran has the worker's process ID, wall and CPU time, footprint and peak RSS; each stage records worker_cpu_seconds; the report's post_export_scoring.execution holds the pool's report;
  • its household row map now reads one batch file at a time (the 1.4 · 4 review's note), and counts each entity's rows once;
  • records a stage the pool could not serve because no worker could start as the probe's failure, not the release's.

The export sampler (tools/sample_us_export_households.py)

  • tools/sample_us_export_households.py --drop-column NAME leaves a stored column out of the subsample (every published export stores has_marketplace_health_coverage, which the current export contract refuses as formula-owned), and the subsample now takes the name of the --export path rather than of the Hugging Face blob a link resolves to.

What stays the same

The serial scorer (MICROCOSM_POST_EXPORT_WORKERS=serial) is unchanged apart from the label, the manifests' new execution record ({"mode": "serial"}) and its merged baseline pass moving into a method of its own (_run_merged_baseline_pass), which the pooled scorer calls too. The guard sweep and the head-to-head scorer are unchanged.

Deliberate differences from the serial scorer

  • A unit after the merged pass that fails on every attempt (out of memory, over its cap, a worker that died) raises WorkerPoolUnitError in the stage that asks for it, which stops certification, held-out reports included; the serial scorer, which has no cap, may have finished. The pool then goes on with the other units in fresh workers.
  • A held-out report whose own baseline pass (after a merged-pass fallback) fails on every attempt stops certification instead of recording itself unavailable.
  • A consumer that catches a failed reform pass and then asks for some of its keys alone is refused (the serial scorer would run that smaller pass); asking for the same keys again raises the same error. No shipped stage catches reform errors.

Not done here

  • The pooled export probe, and what it changed. Run on a 5% subsample of the published file in snapshot f95e684d (seed 0, 7,587 households, pooled run only; serial left out at Anthony's request), with 4 workers, a 5.25 GiB cap and batches of up to 2,000 households, on the branch before the change above. A baseline pass over batch 1 went over the cap on both attempts, for the merged pass (97 keys: 5.37 and 5.38 GiB) and then for the reform-coverage smoke's own pass (5.43 and 5.34 GiB), so the smoke stage failed with WorkerPoolUnitError. The reform passes that reached the certifying process peaked at 1.35 to 2.00 GiB per worker. The run was stopped at 1 h 53 min, with reform validation still waiting for its own baseline pass, on a machine at load 20 with swap nearly full. Anthony then decided that baseline passes run in the certifying process before the pool starts (above).
  • Blocking: the probe at certification's 5,000-household batches (28 November, with the change above). 12% subsample of the same file (16,774 households), 4 workers, a 5.25 GiB cap, on a quiet machine; 26.5 minutes.
    • Baseline passes ran in the certifying process first, about 14 minutes in all; sampled RSS peaked at 3.71 GiB, and the process's memory footprint when the workers started was 4.05 GiB, against the plan's 3 GiB. The merged pass and reform validation's own pass stopped partway with SPMInputError: SPM unit has no classified adult (this July file against the current engine; the serial scorer raises the same error), so those passes' readings cover only part of their batches.
    • 23 reform units of the smoke check finished in workers at 1.36 to 2.50 GiB footprint; the 24th, the state_income_tax@2024 reform, went over the cap on both attempts (5.92 and 5.93 GiB), so the smoke stage failed. Reform validation's reform units did not run.
    • So 1.4 · 6's 5 GiB per worker (measured at 2,000-household batches) and 3 GiB for the certifying process do not hold at certification's batch size; how to size the workers needs Anthony's decision before this PR leaves draft. The subsample over-represents households with rare inputs or large amounts, so a typical national batch may need less.
    • Logs and the full write-up: the shared notes folder, pooled-5000-batch-probe-2026-11-28/results.md.
  • 1.4 · 8 (scheduling the reform-coverage passes first and cancelling the rest when that check fails) is separate; the smoke check's units already come first in the stream.
  • 1.4 · 4a: the serial merged pass re-raising PostExportBatchFileError (the Keep the US post-export scorer's household batches in files, not memory #1751 merge note) reached main through Stop the merged baseline pass at a refused post-export batch file #1772, which this branch has merged; the pooled scorer's merged pass stops on a changed batch file in the same way. 1.4 · 5a (Free policyengine-us 2.2.1's pinned copy of the rules when an engine is released #1777, which frees policyengine-us 2.2.1's pinned copy of the rules when an engine is released, in every worker too) is merged in as well.
  • Follow-ups found in review:
    • the export probe's stage peak covers only the time since its last pass began (its timing wrapper resets the stage's memory sampler for each pass); after a failed merged pass the first stage's peak therefore leaves out the earlier baseline passes, though each pass's own row has its peak;
    • a kept baseline error keeps exception attributes such as AttributeError.obj, and one raised later inside a caller's handler takes that handler's exception as its context (no stage is opened inside one);
    • after a stage fails, the pool still runs that stage's later reform units (the probe's smoke units ran on after its smoke stage had failed); 1.4 · 8 cancels the rest when the reform-coverage check fails;
    • when a later unit fails on every attempt, the shared pool stops the whole run, so the units in flight, the one due included, start again in a fresh pool (several such failures repeat that); a pool option to report a unit's failure without stopping the run would avoid it (worker_pool.py);
    • a MemoryError while a worker sends its result is not retried (worker_pool.py);
    • a worker scores a reformed simulation's later passes after an earlier one failed (no shipped stage asks for them after a failure);
    • on a machine where the formula gives more than 21 workers (about 151 GiB and 23 usable cores or more), Route A's 110 GiB RSS limit for the certify stage can be passed; the Route A README says to set the variable, and 2.6 · 4 sizes stages to the budget.

Tests

Red-green throughout: each change is a failing-tests commit followed by the change (the pooled scorer; the defaults; review round 1; Route A's export; review rounds 2 and 3). Three rounds of adversarial review followed; each round's fixes are one of those pairs. Round 3's fixes (a kept unit error holds no frames of the stopped run, a consumer's own failed unit is raised again when asked again, a stage's own baseline raises its first problem in batch order, failed attempts name their pool, and a deterministic look-ahead test) came after the last round and have not been reviewed adversarially.

The change that moved baseline passes into the certifying process (after the export probe) had its own red-green cycle and three more adversarial review rounds, each followed by a tests-then-fixes pair:

  • round 1: the unit type refuses a baseline unit; the footprint at pool start is recorded; closing drops unopened stages' baselines; a kept error leaves the caller's exception unchanged;

  • round 2: a kept error keeps the cause chain the build's run outcome reads (out of memory, terminated); an error raised during a termination stops scoring at once; a traceback that cannot be formatted; the probe rows' failed field;

  • round 3: the same termination rule for the merged baseline pass, in the serial scorer too (a gap from before this branch), and doc corrections. Round 3's fixes have not been reviewed again.

  • Byte identity:

    • test_pooled_scoring_writes_the_serial_scorers_bytes_at_any_worker_count: every file certification writes for the five stages and the manifests' block, scored by the shipped consumers on the fake engine in spawned workers, are byte-identical at 1 and 3 workers (the pool's assert_identical_across_worker_counts) and to the serial scorer's; worker engines are built one batch at a time, released before the next, with the SPM selection, a reform's system alone and ascending periods.
    • engine_workflow/us/test_us_post_export_scoring.py::test_pooled_scoring_gives_the_serial_scorers_bytes_on_policyengine_us: on policyengine-us 2.2.1, the eight guard households in three batches, a neutralization probe, a parameter-change probe and demographics: byte-identical at 1 and 2 workers and to serial (passed locally, about 5 minutes).
    • The probe writes the serial probe's stage files byte for byte when it scores in the pool.
  • Where baseline passes run: every baseline engine is built in the certifying process, before the pool starts, with none left unreleased (test_pooled_scoring_writes_the_serial_scorers_bytes_at_any_worker_count, test_a_merged_pass_that_runs_out_of_memory_falls_back_here_before_the_pool); a stage whose own baseline failed gets that error when it opens; a build with no reform starts no pool.

  • Refusals and failures: the three worker-side refusals with the serial error's class name and text and the serial counts; the merged-pass fallback (a failing key, and a unit out of memory) against the serial fallback; a changed batch file; a unit that fails on every attempt, including while an earlier unit is still running; a pool whose workers cannot start; unrecorded keys, passes and reforms; a reform a worker cannot unpickle.

  • Defaults: the formula against 1.4 · 6's worked examples (32 GiB/6 and 10 cores → 4, 128 GiB/18 cores → 17, 16 GiB → 1, 29.8 GiB → 3), the refusal under about 10.7 GiB, the override's values, cgroup v1 and v2 readings, certification's call order, Route A's export.

Run locally, each by node ID only, in an engine-free environment (Python 3.13, no engine) and, for the engine-workflow test, the US engine environment. Existing tests changed: the method label and certification-wiring source checks in test_us_post_export_scoring.py, the plan record's pinned digest in test_us_post_export_requests.py::test_the_release_s_recorded_post_export_outputs_are_unchanged (re-pinned for the raised label after CI's engine-free jobs failed on it; every consumer output's digest is unchanged, and the test now checks that the record with the first label still hashes to the earlier pin), the stage expectations in test_us_post_export_probe.py::test_probe_runs_every_stage_on_a_subsample, the module list in test_us_spine_blindness.py, and test_us_fiscal_refresh_builder.py's _certify_us_build stubs (they take the new keyword) and a module fixture that sets MICROCOSM_POST_EXPORT_WORKERS=serial (its tests stub the scorer or certification's body). Not run locally: other tests that only read these modules. CI cost: each pooled test starts spawned workers that import the release tool (about 12-15 s each in an engine-free environment), so the new pooled tests add roughly ten minutes to the engine-free job.

🤖 Generated with Claude Code

anth-volk and others added 19 commits November 26, 2026 23:56
Tracker task 1.4 · 7. The tests require the release tool's
_PooledPostExportScorer to score the engine-free dry run's recorded
requests in spawned pool workers and serve each consumer, run again in
the parent, byte-identical outputs to the serial scorer at one and
several workers (on the fake engine and on policyengine-us); the
serial scorer's refusals to happen in the workers with the serial
error's class name and text; the merged baseline pass to fall back as
the serial scorer does; a changed batch file and a pool failure to stop
scoring; and a request the dry run did not record to be refused.

They also require POST_EXPORT_SCORING_METHOD raised to
household_batched_written_h5_v2, the held-out reports to re-raise
WorkerPoolError, and the export probe to register every stage's
baseline plan, score in the pool, write each worker pass's timing and
read one batch at a time in its household row map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tracker task 1.4 · 7. _PooledPostExportScorer scores the requests the
plan's engine-free dry run recorded in the shared worker pool and
serves each consumer, run again in the certifying process, from the
results:

- the pool runs the merged baseline pass split into one range of
  batches per worker, then one unit per reformed simulation holding
  every recorded pass of it over every batch, so a worker builds a
  reform's rules once, as the serial scorer does; after a failed merged
  pass it also runs each consumer's own baseline pass first, and a
  changed batch file stops it instead;
- a worker (microcosm.build.us_runtime.post_export_pool) reads each
  batch from the scorer's batch file and scores it with the serial
  scorer's own per-batch code (_score_post_export_batches), with the
  same population-aggregate, baseline-branch and behavioral-response
  refusals; failures come back as data and are raised where the serial
  scorer raises, with the worker's exception's class name and text;
- each consumer's baseline is served its recorded plan and each
  reformed simulation its recorded passes in order, and any other
  request is refused; parts are joined in batch order, so outputs are
  byte-identical to the serial scorer's;
- workers get this process's policyengine-us lock-check record, and the
  manifests' post_export_scoring block records how scoring ran under
  execution (run metadata).

POST_EXPORT_SCORING_METHOD is raised once, to
household_batched_written_h5_v2 (decision 1.1 · 1). The dry run now
records each reform pass's keys, and the plan holds every consumer's
requests. The held-out reports re-raise WorkerPoolError. Certification
takes the pool settings as a parameter; certify_main still passes none
(serial) until 1.4 · 6 decides the defaults. The serial merged pass's
handling of a changed batch file is left to tracker task 1.4 · 4a.

The export probe records every engine stage's plan before it opens the
scorer and registers it (one shared baseline pass, as certification),
can score in the pool, writes one passes.jsonl line per worker pass
with its time and memory, records worker CPU per stage, and its
household row map reads one batch file at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tracker task 1.4 · 7, with the worker settings 1.4 · 6 recommends,
which Anthony approved on 27 November. The tests require:

- microcosm.build.host_resources to read the cores a process may use
  (its CPU affinity, limited by a cgroup v1 or v2 CPU quota) and the
  machine's memory (limited by a cgroup memory limit);
- plan_post_export_workers to choose min(usable cores - 1,
  floor((0.75 * memory - 3 GiB) / 5 GiB)) workers, each capped at
  max(5 GiB, (0.75 * memory - 3 GiB) / workers) and replaced after 2
  units, with inherited thread settings; to take a positive count or
  serial from MICROCOSM_POST_EXPORT_WORKERS and refuse anything else;
  and to refuse a machine too small for one worker unless the variable
  names a count or serial;
- certification to choose its pool settings from the environment
  before it places the build, and pass them to _certify_us_build; the
  export probe's command to do the same before it loads the export;
- the manifests' execution record to hold the plan.

The certification tests that stub _certify_us_build take the new
keyword, and the harness whose stand-in scorer is the serial scorer
sets MICROCOSM_POST_EXPORT_WORKERS=serial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tracker task 1.4 · 7, with the worker settings 1.4 · 6 recommends,
which Anthony approved on 27 November:

- microcosm.build.host_resources reads the cores this process may use
  (os.process_cpu_count(), limited by a cgroup v1 or v2 CPU quota) and
  the machine's memory (limited by a cgroup memory limit);
- plan_post_export_workers chooses min(usable cores - 1,
  floor((0.75 * memory - 3 GiB) / 5 GiB)) workers, each capped at
  max(5 GiB, (0.75 * memory - 3 GiB) / workers) and replaced after 2
  units, with inherited thread settings. MICROCOSM_POST_EXPORT_WORKERS
  takes auto, a positive count or serial; anything else, or a machine
  too small for one worker without a named count, is refused;
- certification reads it before it places the build and passes the
  pool to _certify_us_build, printing the workers, the planned peak
  beside the budget and the cap; the export probe's command reads it
  before it loads the export;
- the manifests' execution record holds the plan's readings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests require pooled scoring to:

- refuse a reformed simulation whose reform is not the one the dry run
  recorded at that place (served by position alone, a consumer that
  opened its reforms in another order would get each other's values),
  one whose reform carries no description, and one beyond the recorded
  ones; the consumers' own builders mark each reform they build with
  its description;
- fall back to each consumer's own baseline pass when a merged baseline
  unit fails on every attempt (an engine out of memory), as the serial
  scorer falls back when its merged pass raises MemoryError;
- keep serving what the merged pass scored after the pool stopped, and
  refuse what needs the pool with PostExportPoolStoppedError, a
  WorkerPoolError, which the export probe records as its own failure;
- raise a failed reform pass's error again when the consumer asks for
  the same keys again, as the serial scorer does;
- record the environment the workers were given, and have each worker
  refuse a release tool whose bytes differ from the parent's.

The export probe must register the two held-out reports' plans as
certification does, count each entity's rows once in its row map, and
refuse an engine given alongside pool settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Each reformed simulation must be opened with the reform the dry run
  recorded at that place: the smoke check's and reform validation's
  builders mark each reform with the description they built it from
  (post_export_requests.described_reform), the dry run keeps every
  reform it opened, and the pooled scorer refuses a reform with another
  description, none, or beyond the recorded ones.
- A merged baseline unit that fails on every attempt is a failed merged
  pass: each consumer then scores its own plan in a new pool, as the
  serial scorer falls back when its merged pass raises MemoryError.
- A stopped second pool run refuses only what needs the pool, with
  PostExportPoolStoppedError (a WorkerPoolError, which the held-out
  reports pass on); what the merged pass scored is still served.
- A failed reform pass asked for again raises its error again, with the
  serial scorer's counts.
- Workers refuse a release tool whose bytes differ from the parent's
  (_RELEASE_TOOL_SHA256), and the execution record names the
  environment the workers were given.
- The export probe registers the held-out reports' plans as
  certification does, records a stage the stopped pool could not serve
  as its own failure, counts each entity's rows once, refuses an engine
  given alongside pool settings, and says which passes passes.jsonl
  leaves out.

The worker-start test's third check is corrected: a tool found loaded
with a record of the bytes it ran is accepted, as those are the code the
worker scores with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route A sources route_a.env without exporting its values, so a
MICROCOSM_POST_EXPORT_WORKERS set there would not reach certification,
which reads it from its environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
route_a.sh exports a value route_a.env sets, as it does the telemetry
settings, so the certify stage, which the supervisor starts with the
driver's environment, scores with the workers it names, or serially. The
example settings file and the README describe the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests require pooled scoring to:

- raise a unit that fails on every attempt only in the consumer that
  asks for it, even when it fails while an earlier, slower unit is
  still running, and go on with the other units in a fresh pool;
- refuse every consumer when no worker can start (a release tool
  digest other than the workers'), naming the refusal;
- keep every pool's report in the execution record, with the merged
  baseline fallback's cause and units;
- raise any earlier failed reform pass again when it is asked again.

The export probe must read the pool setting only for a run with an
engine stage, and record a held-out report whose dry run fails. The
certification tests in test_us_fiscal_refresh_builder.py, which stub
the scorer or certification's body, score serially whatever the test
machine's memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Workers run ahead of the consumers, and the pool stops a run as soon
  as any unit in flight fails on every attempt. That unit's error is now
  kept and raised in the consumer that asks for it; the units from the
  one due, without it, go on in a fresh pool (_result_of). A consumer's
  own failed unit raises WorkerPoolUnitError; a pool whose workers cannot
  start refuses every later consumer with PostExportPoolStoppedError.
- The execution record keeps the report of every pool the scorer ran
  (worker starts, failed attempts, the largest peak), why the merged
  baseline pass fell back, and the fallback's units.
- Every failed reform pass is kept, so asking for any of them again
  raises its error, as the serial scorer does.
- The export probe reads the pool setting only for a run with an engine
  stage, records a held-out report whose dry run fails as a fidelity
  verdict, and its docstring says how a failed unit and a pool that
  cannot start are recorded.
- The release build rule says the merged pass's units and reform
  validation's own pass are unmeasured against the 5 GiB cap, and the
  Route A README that the worker count is not sized to the certify
  stage's 110 GiB RSS limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tests require that:

- a later unit's failure, kept until its consumer asks for it, holds
  none of the stopped run's frames, and the look-ahead case is exercised
  every time (the earlier unit's engine waits until the later unit has
  failed twice);
- a consumer that asks again for its own failed unit gets that unit's
  error again, and each failed attempt in the record names its pool;
- a stage's own baseline pass, after the merged pass failed, raises its
  first problem in batch order, as the serial scorer does, even when a
  later range also fails on every attempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A later unit's failure is kept as a copy without its traceback, whose
  frames held the stopped run's finished results while the fresh pool
  computed them again, and the fresh pool starts outside the handler.
  No pool is started when no unit is left.
- _take returns a consumer's own failed unit with its error, so a
  stage's own baseline pass raises its first problem in batch order, as
  the serial scorer does, and a reformed simulation whose unit failed
  raises that error again when it is asked again.
- Each failed attempt in the execution record names its pool.
- The release build rule says the units in flight start again in the
  fresh pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_the_release_s_recorded_post_export_outputs_are_unchanged pins the
SHA-256 of the plan record in calibration_diagnostics.json, which holds
POST_EXPORT_SCORING_METHOD. This branch raises the label to
household_batched_written_h5_v2 (decision 1.1 · 1), which moved that one
digest in CI's engine-free jobs; every consumer output's digest was
unchanged. The test now also checks that the record with the first
label still hashes to the earlier pin, so the label stays its only
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_a_changed_batch_file_stops_pooled_scoring still matched the
message the scorer raised before review round 1, "stopped earlier". A
pool that could not start now refuses every later consumer with
PostExportPoolStoppedError, "could not start", which the held-out
reports pass on as a WorkerPoolError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the export's given name

Failing tests: a --drop-column option that leaves a stored column out of
the subsample, checks it is absent after the write, records it in the
receipt and refuses an unstored name, the household weight and the id and
membership columns; and a default output name taken from the path the
export was given rather than the file a link resolves to, refusing to
write over that link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s given name

--drop-column NAME (repeatable) leaves a stored column out of the
subsample; the sampler refuses an unstored name, the household weight and
the id and membership columns, the post-write check expects exactly those
columns absent, and the receipt lists them under output.dropped_columns.
The default output name now comes from the --export path as given, not
the blob a Hugging Face cache link resolves to, and writing over that
link is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e tool

Failing test: the probe registers the held-out reports that the release
tool's _post_export_holdout_consumers lists, the list certification
registers, rather than naming them itself. The probe naming the IRMAA
holdout module fails test_only_the_release_tool_imports_the_holdout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_post_export_holdout_consumers lists the held-out reports every build
registers after its post-export stages; certification's
_post_export_consumers and the export probe both read it, so the probe
names no held-out module itself and
test_only_the_release_tool_imports_the_holdout passes again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 9 commits November 27, 2026 22:41
…the pooled scoring branch

main moved the batch loops' garbage-collection helpers to
microcosm.build.us_runtime.household_batches as automatic_gc_suspended,
collect_batch_garbage and collect_pass_garbage. The conflict in the
serial scorer's _score keeps this branch's call to
_score_post_export_batches, the loop shared with pool workers, which
already reads each batch by position and frees its frame; that loop and
the pooled scorer now call the moved helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…certifying process

Failing tests for Anthony's decision of 27 November: every baseline pass
runs in the certifying process with the serial scorer's code before any
worker starts, and the pool runs one unit per reformed simulation only.
The merged pass runs first; if it raises, every stage's own pass runs
next, before the pool, and a stage whose own pass raised gets that error,
with its traceback as a note, when it opens. The execution record lists
each baseline pass run here; a build with no reform starts no pool; a pool
that cannot start fails the first reform request instead of the first
stage's opening; the export probe writes the baseline passes as passes of
the certifying process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ool starts

Anthony's decision of 27 November. In the 5% export probe a baseline pass
over one 2,000-household batch went over the 5.25 GiB worker cap on every
attempt, while reform passes peaked at about 2 GiB.

When the first stage opens, _PooledPostExportScorer runs the merged
baseline pass with the serial scorer's code (now its own method,
_run_merged_baseline_pass, which the serial scorer calls too) and, if it
raises, every stage's own baseline pass, all before any worker starts.
A stage whose own pass raised gets that error, its traceback kept as a
note without its frames, when it opens. The pool then runs one unit per
reformed simulation only, and starts no workers when no stage opens a
reform. The execution record lists each baseline pass run here, and the
export probe writes them to passes.jsonl as passes of the certifying
process. The merged baseline's batch-range units are removed.

Also fixes the new own-baseline test, which read the kept error's
traceback after the error had been raised again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rocess

Failing tests: a post-export pool unit refuses a baseline unit; the
execution record holds the certifying process's memory footprint when the
workers start (None when no pool starts); closing the scorer drops the
baseline values of stages that never opened; a kept baseline error is cut
from the exceptions it was raised from or while handling, so a caller's
own handled exception keeps its traceback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A post-export pool unit refuses a unit without a reform: baseline passes
  run in the certifying process, never in a worker.
- The execution record holds the certifying process's memory footprint
  when the workers start, the check on the plan's 3 GiB for it.
- Closing the scorer drops the baseline values of stages that never
  opened.
- A kept baseline error is cut from the exceptions it was raised from or
  while handling (their text stays in its note), so it holds none of them
  and leaves a caller's handled exception unchanged.
- PostExportPoolStoppedError's docstring, the release build rule and the
  probe's description now say what a failure to start and a fallback do:
  which request raises which error, and that after a failed merged pass
  every stage's own pass runs when the first stage opens and is held until
  its stage opens. The planned-peak comment names what is not measured.
- The byte-identity test reads the new footprint field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failing tests: a kept own-baseline error keeps the cause chain the run
outcome reads (a failure raised while a MemoryError unwinds stays out of
memory), with its tracebacks dropped and a caller's handled exception left
unchanged; an error raised while a termination unwinds stops scoring at
once, before later stages' own passes; an error whose traceback cannot be
formatted is still kept for its stage; the probe's passes.jsonl rows say
whether each pass failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A kept own-baseline error keeps the exceptions it was raised from or
  while handling, so the build's run outcome still reads them (out of
  memory, terminated); only the tracebacks raised inside its pass are
  dropped, and the exception the caller was handling is left unchanged.
- An error raised while the build is being interrupted or terminated stops
  scoring at once instead of waiting for later stages' own passes.
- A kept error whose traceback cannot be formatted (out of memory) is kept
  with a short note instead of stopping every stage.
- The export probe's passes.jsonl rows for passes in the certifying
  process say whether the pass failed, as worker rows do.
- The release build rule, the agent guide, the probe's description, the
  plan's docstring and the Route A README now say that only reform passes
  go to the pool, and that the recorded footprint at pool start is
  reported, not checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failing test (review round 3): an error raised while SIGTERM unwinds the
merged baseline pass stops scoring at once in the serial and the pooled
scorer, instead of falling back to every stage's own pass, and the run
outcome reads it as a termination.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An error raised while the build is being interrupted or terminated stops
  the merged baseline pass at once instead of falling back to every
  stage's own pass, in the serial and the pooled scorer (the serial gap
  predates this branch; a build being stopped has no outputs to compare).
- The kept-error docstring says what it keeps (exception attributes) and
  what Python changes when it is raised inside a handler.
- The release build rule, the Route A README, the scorer's and
  certification's docstrings and the probe's description say that the
  baseline passes run in the certifying process and only the reform passes
  in the pool, which error the first stage gets, and that the footprint at
  pool start is recorded by each run but not yet measured at full size.

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

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.

1 participant