Repository navigation
Run each population simulation once, not twice, and say how long it takes - #260
Open
vahid-ahmadi wants to merge 2 commits into
Open
vahid-ahmadi wants to merge 2 commits into
vahid-ahmadi wants to merge 2 commits into
Conversation
…akes policyengine 6.11.1's calculate_decile_impacts calls Simulation.ensure() on the simulations it is given. ensure() checks only policyengine's own cache and then a saved output file; a simulation finished with run() is in neither, so it was run a second time and its ~27 MB output written beside the input dataset. Hosted, that is the shared Modal volume, under a random name never read again: 1,725 such files since July. _pe_register_run() adds each finished run (baseline, reform, incidence overlay) to that cache, so ensure() reuses it: one run per simulation and no file written. It is a no-op if the private cache name moves. Runtime text: population_reform_impact takes two to three minutes hosted, not ~6 s; score_reform(model="obr") takes over ten minutes on the default window; start_job names the job tools for both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
frbus_shock_incidence, hank_shock_incidence, svar_inflation_incidence and define_scenario_incidence each end in a population microsimulation (two to three minutes hosted), so a direct hosted call passes the 150-second ceiling: frbus_shock_incidence timed out in the demo-readiness pass, and while it ran the server's quick metadata calls timed out too. They are now on the job allow-list, and start_job says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch was successfully deployed
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.
Refs #243 (demo-critical: hosted
score_reform(model="obr")takes over 10 minutes).What was found
The OBR session measured the hosted pieces (
obr-for-macro-243.mdin the shared notes). The OBR solve takes about 3 minutes; the rest is the PolicyEngine population costing at 2–3 minutes per year, against "~6 s per run" in the docs. Reading policyengine 6.11.1's source shows a large part of the reason:calculate_decile_impacts(policyengine/outputs/decile_impact.py:209–210) callsSimulation.ensure()on the simulations it is passed.ensure()(core/simulation.py:194) checks only policyengine's in-process_cache, then a saved output file. A simulation finished withrun()is in neither, so it runs again and thensave()s its output beside the input dataset (common/model_version.py:55).run()and then passes them tocalculate_decile_impacts. So every costing ran the reform twice, and the baseline twice on first use per year. On the hosted server each run also wrote a ~27 MB file to the shared Modal volume under a random name that is never read again. A read-onlymodal volume lsshows 1,725 such files since July (about 45 GB), 77 of them today.Change
core._pe_register_run(sim)adds a finished run topolicyengine.core.simulation._cacheunder itsstorage_id, so the laterensure()reuses it. The result is one run per simulation and no file written. It is called after the baseline run, the reform run and the incidence-overlay run. If the private name moves (it is pinned to policyengine 6.11.1), it does nothing and behaviour falls back to the old double run.population_reform_impactnow says two to three minutes hosted and points tostart_job(tool="pe_population_impact").score_reform'sobrentry says over ten minutes on the default window and suggests start_job oryears=1–2.start_jobnames the job tool for each slow tool.Results are unchanged: the decile step reads the same run it would otherwise have repeated deterministically.
Also: the incidence tools run as jobs
frbus_shock_incidence,hank_shock_incidence,svar_inflation_incidenceanddefine_scenario_incidenceeach end in a population microsimulation. In the demo pass a direct hostedfrbus_shock_incidencecall timed out, and while it held the server,model_summary,hank_summaryandlist_reform_parameterstimed out too (they returned normally afterwards). They are now onjobs.JOB_TOOLSunder their own names, andstart_jobdocuments them.Decision log (Fable 5.2, asked because Vahid asked for no questions)
timing_secondswill show the effect on the first hosted run after both merge.Not done (needs Vahid)
policyengine-macro-pe-data. The per-year datasetsenhanced_frs_2023_24_year_2026…2030.h5andpopulace_us_2024_year_2026.h5must stay.years=1with a realistic budget belongs there.Tests
New
test_pe_register_run.py(with a stand-in policyengine module). Integration (excluding remote): 456 passed. Merging redeploys Modal.🤖 Generated with Claude Code