Repository navigation
Score US post-export requests in the shared worker pool by default - #1775
Merged
Merged
Conversation
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>
…port-scoring-605c24
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>
…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>
Failing tests for Anthony's decision of 30 November, after the export probe at 5,000-household batches (a reform pass at 5.93 GiB in a worker; the certifying process at 4.05 GiB when the workers started): workers = min(usable cores - 1, floor((0.75 x memory - 6 GiB) / 8 GiB)), each capped at max(8 GiB, (0.75 x memory - 6 GiB) / workers). A 32 GiB machine gets 2 workers at 9 GiB each, the 128 GiB build Mac 11, and a machine under about 18.7 GiB is refused unless the operator names a count or serial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Anthony's decision of 30 November, after the export probe at certification's 5,000-household batches measured one reform pass at 5.93 GiB in a worker and the certifying process at 4.05 GiB when the workers started (1.4 · 6 had 5 GiB and 3 GiB, from 2,000-household batches). WORKER_PEAK_BYTES and PARENT_PEAK_BYTES change; the formula, cap and refusal follow: 2 workers at 9 GiB on a 32 GiB machine, 11 on the 128 GiB build Mac, refusal under about 18.7 GiB. The release build rule, the changelog, the Route A README (13 workers or fewer under the certify stage's 110 GiB limit) and route_a.env.example give the new figures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The release build rule's 27 November example names 5.25 GiB as the cap that machine then had, not the current cap. - The Route A README says 12 workers or fewer: 13 would plan exactly the certify stage's 110 GiB limit. - Two rewrapped passages read as single paragraphs again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…coring branch The one conflict was the recorded plan digest in test_us_post_export_requests.py, which both sides re-pinned: main for the 2.145.3 probes and specs, this branch for the raised method label. The merged pin (d7fd707a...) is the record with both; the record with the earlier label hashes to main's pin (0e105751...), which is now _PLAN_SHA256_WITH_THE_FIRST_LABEL, so the two differ only by the label. Every stage output's digest is main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
marked this pull request as ready for review
November 30, 2026 18:05
juaristi22
reviewed
Nov 30, 2026
juaristi22
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at bda2932ba. On a 1,035-household sample of the 27 November national build (populace-us-2024-3b3de63-12693b9db03d-20261127T193416Z), in three batches on policyengine-us 2.145.3, the export probe at this head wrote byte-identical reform-coverage smoke, reform validation and demographics files with the serial scorer and with two pool workers, the smoke file's scoring record included; all 108 reform units ran in workers replaced every two units (54 starts, no failed attempt). Merged into current main, the 10 engine-free test files this changes pass here, and the worker plan gives the description's figures.
Two notes on sizing:
- Route A certifies at 2,000-household batches (
--maximum-microsim-batch-size 2000inroute_a.env.example, as that build records), while the 8 GiB per worker comes from the probe at 5,000, so on the build Mac the formula gives 11 workers where 1.4 · 6's figures, measured at 2,000, give 17. - The Route A README's advice of 12 workers or fewer on machines of about 147 GiB or more keeps the plan at 102 GiB, but each worker's cap is (0.75 × memory − 6 GiB) ÷ workers, so on those machines the certifying process's 6 GiB and the 12 caps come to more than the stage's 110 GiB limit (144 GiB at 192 GiB).
…add up to From the review of #1775: - The export probe that led to 8 GiB per worker and 6 GiB for the certifying process ran at the release tool's default 5,000-household batches; Route A's builds pass --maximum-microsim-batch-size 2000, and certification scores at the size the build recorded. The release build rule and the planner's comments now say so, and that the figures do not depend on the batch size (11 workers on the build Mac where 1.4 · 6's figures gave 17). - The Route A README said 12 workers or fewer keeps the certify stage under its 110 GiB limit. It keeps the plan under it, but each worker's cap is (0.75 x memory - 6 GiB) / workers, so the caps and the certifying process's 6 GiB come to 75% of the machine whatever the count: above 110 GiB on machines over about 147 GiB. Sizing to the stage's limit is task 2.6 · 4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failing tests for Anthony's decision of 1 December, after review of #1775 pointed out that Route A's builds use 2,000-household batches: batches of up to 2,000 households plan 6 GiB per worker (1.4 · 6 measured 3.5-4.7 GiB at that size), larger batches, a whole-file batch and an unknown size 8 GiB. Certification reads the size the build recorded in its scoring plan, and the export probe passes its --batch-size. At 2,000 the 128 GiB build Mac gets 15 workers, a 32 GiB machine 3 and a 16 GiB machine 1. The plan's record and printed line name the batch size and the figure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Anthony's decision of 1 December: batches of up to 2,000 households, which Route A's builds use, plan 6 GiB per worker (1.4 · 6 measured up to 4.7 GiB at that size); larger batches, a whole-file batch and an unknown size keep 8 GiB. plan_post_export_workers takes max_batch_households (worker_peak_bytes picks the figure), and its record and printed line name the batch size and the figure. Certification passes the batch size the build recorded in its scoring plan (_recorded_maximum_batch_size), and the export probe its --batch-size. At 2,000 the build Mac gets 15 workers, a 32 GiB machine 3 and a 16 GiB machine 1. The release build rule, the changelog, the Route A README (16 workers or fewer under the certify stage's 110 GiB limit) and route_a.env.example give the figures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failing tests (review of the per-batch worker figure): the worker plan's field, its record's key and the planners' parameter are maximum_batch_size, as the build's scoring plan names the configured size; the manifests' scoring block already holds the largest batch actually scored as max_batch_households. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The worker plan's field, record key and the planners' parameter are maximum_batch_size, as the build's scoring plan names the configured size; max_batch_households in the same manifest block is the largest batch actually scored. - The Route A README says why it advises 16 workers or fewer (8 GiB of the 110 GiB limit left for what the plan does not count; 17 would leave 2). - The release build rule and the _PostExportPooling docstring say the printed and recorded plan names the batch size and the per-worker figure; route_a.env.example is re-wrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Nov 30, 2026
Two conflicts, both where main and #1775's branch (this branch's base, at 1f9bc17) changed the same code; resolved as #1775's own merge of main (bda2932) resolved them: - tools/build_us_fiscal_refresh_release.py, the serial scorer's pass: kept #1775's call to the shared _score_post_export_batches, and applied main's renames of the garbage-collection helpers in #1775's code (automatic_gc_suspended, collect_batch_garbage, collect_pass_garbage). - tools/build_us_fiscal_refresh_release.py, _certify_us_build's scoring stages: this branch re-indents them inside its try block, and main added _record_certification_failures to the smoke's failure handling. The span is main's text, indented inside the try; #1775 changes nothing in it. - test_us_post_export_requests.py's pinned plan digest: #1775 re-pinned it for its raised method label, main for the policyengine-us 2.145.3 refresh. Took #1775's merged pin (d7fd707a...) and main's current pin as the first-label digest (0e105751...); test_the_release_s_recorded_post_export_outputs_are_unchanged passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Nov 30, 2026
Keeps #1775's branch as this branch's base. #1775 now scores every baseline pass in the certifying process before the pool starts, and the pool runs only reform units (Anthony's decision of 27 November). Three conflicts: - tools/build_us_fiscal_refresh_release.py, _start_pool: took #1775's, which no longer runs the merged baseline pass in the pool (_run_merged_baseline removed); this branch had only main's helper rename there. _certify_us_build differs from #1775's only by this branch's try block. - docs/us-release-build-rule.md: #1775's paragraph on unit failures, then this branch's paragraph, now saying the smoke's units are the first the pool runs, after every baseline pass has run in the certifying process. - test_us_post_export_pooled_scoring.py: #1775's file with this branch's changes applied again (imports, the fixture's environment reset, the scorer helpers' batch parent, the closing tests). The stop test now requires the certifying process to have built only baseline engines and one worker the reform engines, in order; units_completed counts reform units only. The twelve new test cases and test_us_post_export_requests.py::test_the_release_s_recorded_post_export_outputs_are_unchanged pass, each run by node ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Nov 30, 2026
…ranch #1775 merged into main as 88fadfa, whose parents (6b87a0c and #1775's head 1ea69f7) this branch already holds, so the merge has no conflicts and changes no file here. It makes main's head this branch's only common ancestor with main, so #1802's diff against main is this task's five files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracker task 1.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 (
_PooledPostExportScorerintools/build_us_fiscal_refresh_release.py)_PostExportConsumerRequests, held by_PostExportScoringPlan.consumer_requests; the plan's record incalibration_diagnostics.jsonis unchanged apart from the method label).MemoryErrorincluded), 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.microcosm.build.us_runtime.post_export_pool,_PostExportWorker):_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;MemoryErroris raised, so the pool runs the unit again in a fresh worker;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;_RELEASE_TOOL_SHA256), so a file changed during a run cannot mix two versions' results.post_export_requests.described_reform), and each reformed simulation must be opened with the reform the dry run recorded at that place._concatenate_post_export_parts), as the serial scorer joins them.PostExportUnitFailure.exception()), so a held-out report records the serial scorer's text. A changed batch file raises the tool's ownPostExportBatchFileError.WorkerPoolUnitErrornaming the unit (the pool already reads each unit inside atry). 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; memory figures set by Anthony on 30 November and 1 December)
plan_post_export_workers(post_export_pool.py), with readings from the newmicrocosm.build.host_resources:--maximum-microsim-batch-size, read from its scoring plan; the probe uses its--batch-size): 6 GiB for batches of up to 2,000 households, which Route A's builds use, and 8 GiB for larger batches, a whole-file batch or a size not recorded. At 2,000: 3 workers on a 32 GiB machine, 15 on the 128 GiB build Mac, 1 on a 16 GiB machine; at 5,000: 2 and 11, and a 16 GiB machine is refused. 1.4 · 6 decided 3 GiB for the certifying process and 5 GiB per worker; Anthony raised them to 6 and 8 GiB after the probe at 5,000-household batches (below) measured the certifying process at 4.05 GiB when the workers started and one reform pass at 5.93 GiB, then set 6 GiB per worker for batches of up to 2,000 households after review pointed out Route A's batch size (1.4 · 6 measured up to 4.7 GiB at that size).MICROCOSM_POST_EXPORT_WORKERS: unset, blank orautofor the formula; a positive whole number for that many workers (1is one worker, a process of its own);serialfor the serial scorer. Anything else is refused.serial.post_export_scoring.executionrecords it, each baseline pass run in the certifying process (label, keys, wall and CPU time, error) and the pool's report, as run metadata.route_a.env, whichroute_a.shnow 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.shexecs with it, certification readsos.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_METHODis raised once, tohousehold_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)ExportProbe(post_export_pooling=...)), and writes onepasses.jsonlline 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 recordsworker_cpu_seconds; the report'spost_export_scoring.executionholds the pool's report;The export sampler (
tools/sample_us_export_households.py)tools/sample_us_export_households.py --drop-column NAMEleaves a stored column out of the subsample (every published export storeshas_marketplace_health_coverage, which the current export contract refuses as formula-owned), and the subsample now takes the name of the--exportpath 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' newexecutionrecord ({"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
WorkerPoolUnitErrorin 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.Not done here
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 withWorkerPoolUnitError. 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).--maximum-microsim-batch-size 2000), and certification scores at the size the build recorded. 12% subsample of the same file (16,774 households), 4 workers, a 5.25 GiB cap, on a quiet machine; 26.5 minutes.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.state_income_tax@2024reform, 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.SPMInputErrorstops before they run.pooled-5000-batch-probe-2026-11-28/results.md.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.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);worker_pool.py);MemoryErrorwhile a worker sends its result is not retried (worker_pool.py);MICROCOSM_POST_EXPORT_WORKERSto 16 or fewer keeps the plan (102 GiB) under the limit, not the caps; 2.6 · 4 sizes stages to the budget (the review of 1 December pointed this out).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:
failedfield;On 1 December, after review, the docs say that Route A's builds use 2,000-household batches and what the workers' caps add up to (a90fc6e, docs and comments only). Then, by Anthony's decision of 1 December, one more pair: failing tests for a per-worker figure that follows the build's batch size (54b29ea), then the change (93a322d). One review confirmed that certification plans for the batch size it scores at and checked the worked numbers; its fixes (the field and record key renamed to
maximum_batch_size, which the manifests' scoring block does not already use for the largest scored batch, and wording) are a tests-then-fix pair too, not reviewed again. The raised memory figures (30 November) are one more pair: failing tests with the new worked numbers (fdd57e4), then the constants and every document that states them (4c1b4a4). One review checked each worked number against the formula and searched for old figures; its fixes (a dated example's wording, two rewrapped passages, this description, and the Route A guidance lowered to 12 workers so the plan stays under the 110 GiB limit, since raised to 16 with the per-batch figure) were not reviewed again.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'sassert_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, last on 28 November). Not run since main moved to policyengine-us 2.145.3 (Move the US engine to policyengine-us 2.145.3 and prepare the Route A national build #1676, merged into this branch at bda2932): that version is not in the local package cache.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.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 intest_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 intest_us_post_export_probe.py::test_probe_runs_every_stage_on_a_subsample, the module list intest_us_spine_blindness.py, andtest_us_fiscal_refresh_builder.py's_certify_us_buildstubs (they take the new keyword) and a module fixture that setsMICROCOSM_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