diff --git a/changelog.d/us-release-head-to-head-modal-stage.added.md b/changelog.d/us-release-head-to-head-modal-stage.added.md new file mode 100644 index 0000000000..dc68f9579e --- /dev/null +++ b/changelog.d/us-release-head-to-head-modal-stage.added.md @@ -0,0 +1 @@ +The US head-to-head scorer is a Modal stage: `us-release-head-to-head` (one `score` stage; digest-pinned incumbent, candidate and ledger-feed inputs; `workers`, `maximum_microsim_batch_size` and `worker_max_slices` as the only plan options), with a `head-to-head` resource class (16 CPUs and 288 GiB, both limited at the request, and a timeout derived from `HEAD_TO_HEAD_COST_CAP_USD`: at d844's $40 cap and the non-preemptible list price, 15,705 seconds). `docs/us-modal-stage-route-a-h2h-plan.json` is the 16-worker d844 run (the d1386 Route A build against `populace-us-2024-spm-20260915`), non-preemptible, without worker recycling, with a 14,505-second tool budget, pinned to `main` at 2cfe3043d, which carries #1171. Whether it fits $40 depends on Modal's speed for this scorer, which nothing has measured. Check mode reports the image venv's Python and runs a tool's option preflights (`ToolSpec.option_preflights`), so a plan that sets `worker_max_slices` runs the scorer's recycling guard in the image and fails the check on Python below 3.14.7. `tools/us_head_to_head_projection.py` reads the stage's streamed log, rebuilds both worker pools under CPython's on-demand worker starts, replays the rest of the run from the measured paces, and answers `WAIT`, `GO` or `NO-GO` against the tool's time budget or a stall; memory is reported, not judged. The Modal stage runner now prints its `BUDGET: the tool may run Ns (limited by X)` line before every tool start, not only when the class timeout limits the tool, so the projection treats streams with scorer lines but no budget line as begun late and never says `GO` on them. `tools/us_head_to_head_watch.sh` streams the app's log into one file per stream, polls the projection every ten minutes and stops the app on a `NO-GO` that a restarted stream confirms with a scorer line printed after both the last poll and that stream's own start, confirming the stop; where it cannot show the log is current (a stall, or a hung, refused or silent stream) it raises `ALARM` and leaves the run to the runner's budget. `docs/evidence/us-h2h-speed` holds the local slice times, a three-worker pool run of the pinned scorer and simulated 16-worker runs. The runbook documents the sizing evidence and its gaps, costs outside the compute ceiling, the lack of a final receipt after a whole-container OOM, and operator-supplied input paths. Check mode imports sibling-dependent tools with their script directory on the module search path and registers the probed module before executing it. diff --git a/docs/evidence/us-h2h-speed/README.md b/docs/evidence/us-h2h-speed/README.md new file mode 100644 index 0000000000..ec344768b1 --- /dev/null +++ b/docs/evidence/us-h2h-speed/README.md @@ -0,0 +1,467 @@ +# US head-to-head slice times, measured locally + +What this measures: how long the pinned scorer's slice work takes, chunk by +chunk, for the d844 incumbent and candidate, and how its worker pool behaves. +It is the d844 run's sizing input and the source of `chunk-weights.json`, +which the early-stop estimate (`tools/us_head_to_head_projection.py +--chunk-weights`) uses for chunks it has not measured yet. Three parts: slice +times in one process (below), a three-worker pool run of the scorer itself, +and simulated 16-worker runs, which are not measurements. + +## Slice times in one process + +- Scorer: `tools/score_us_release_head_to_head.py` at 2cfe3043d, the plan's + pin, in a detached checkout. +- Interpreter: CPython 3.14.7, the standard build, with the pin's locked + dependencies (policyengine-us 2.2.1). BLAS and OpenMP pools at one thread. +- Inputs: incumbent H5 sha256 6496cc43… (29 slices of 2,000 households); + candidate H5 sha256 2d9c8586… (the d1386 build, 177 slices); ledger + `consumer_facts_us_c5e5bf8` sha256 b8543739…; 33,147 specs in 5 chunks of + 8,192 (chunk 5: 379 specs, including the 11 JCT reforms). +- Host: an 18-core Apple M5 Max shared with other work (1-minute load 30 to + 120 during the run). 2026-11-16, 18:08 to 18:36 UTC. +- Method (`scripts/time_slices.py`): one process loads the yardstick and both + artifacts once, repairs each frame's population mass as the scorer does, + and calls the scorer's `_score_household_slice` with the arguments its + workers pass. One warm-up slice per artifact, then, for each chunk, two + slices per artifact in alternation (incumbent slices 8 and 22, candidate + slices 45 and 133), so load drift hits both alike. The report is rewritten + after every slice. + +### Results + +Seconds per slice, wall clock; CPU time was 94% to 99% of it (92% and 95% +in the two warm-ups). + +| Chunk | Candidate | Incumbent | +|---|---|---| +| 1 | 35.9, 41.9 | 49.9, 33.3 | +| 2 | 42.4, 40.1 | 49.2, 42.9 | +| 3 | 37.2, 39.0 | 43.8, 40.4 | +| 4 | 34.4, 34.9 | 47.5, 41.2 | +| 5 | 202.1, 197.3 | 232.2, 225.8 | + +Warm-up slices (chunk 1): candidate 41.2, incumbent 53.6. Import took 38.1 +s, the yardstick compile 22.5 s, and loading the candidate 11.3 s. The one +process holding both frames read 7.5 to 9.3 GiB current RSS (psutil) after +each slice; the highest psutil sample, every half second, was 10.4 GiB. Its +`ru_maxrss`, the peak the scorer's lines and its 20 GiB guard use, reached +11.31 GiB. + +`chunk-weights.json` gives the candidate's chunk means relative to chunk 1 +(1.00, 1.06, 0.98, 0.89, 5.13) and the one-process totals, extrapolated +from two timed slices per chunk (each chunk's two-slice mean times its +slice count): 62,401 s for the candidate's 885 slices and 11,690 s for the +incumbent's 145, or 4,631 s of slice work on 16 workers at this speed. + +### What this does not establish + +- Speed on Modal. The class runs 16 workers on 16 physical cores; per-core + speed and contention among 16 workers are not measured here. The runbook's + measured + Modal slowdown for single-core materialize work (3.3 to 7.6 times per + chunk) was not measured on this scorer. +- Worker start cost. The pool run below measured it for incumbent workers + on this host; nothing has measured it on Modal or for the candidate. +- The workers' `gc.collect()` after each slice, which this script does not + run. +- Why October's sequential run (`h2h-routea-20261009`) took 5.2, 4.7, 6.2, + 5.4 and 10.4 minutes per incumbent slice in chunks 1 to 5: 6 to 9 times the + incumbent times here in chunks 1 to 4, and 2.7 times in chunk 5. That run + used an older scorer (checkout a469ebe3d), a free-threaded CPython 3.14t + environment, and a heap that grew about 0.6 GiB per slice in chunk 5; + which of these mattered is not tested. +- Within-chunk spread: two slices per chunk, on a loaded host. + +## A three-worker pool run + +- The pinned scorer itself, run as the d844 stage runs it but with + `--workers 3`: same inputs, ledger, batch size and one-thread BLAS and + OpenMP pools, on the same host, shared with other work (its load during + the run was not recorded). 2026-11-16, launched 19:00:11 UTC. +- Its scorer lines, without paths, are the test fixture + `packages/microcosm-build/tests/fixtures/us_h2h/pool-run-3-workers-2cfe3043d.log`. +- The incumbent's pool opened at 19:01:14. Its 145th slice ended at + 20:13:52, 4,358 s later, and the parent released the pool at 20:14:04, + 4,370 s after it opened. +- The candidate's pool never opened. While the incumbent's pool ran, the + candidate H5's folder was moved to an external archive drive at 20:04:13 + (d3015, a stub left at the old path). The scorer opens the candidate only + after the incumbent's pool, so it stopped at 20:14:04 with + `FileNotFoundError`. It was not rerun, because the host was above its + load line for new heavy runs. Both H5s remain in the local Hugging Face + cache, at the sizes and sha256 values the plan pins. + +What the incumbent's pool showed: + +- Workers started on demand, one at a time. From the submit that + triggered each start to the worker's first line took 42, 36 and 44 s, + intervals rebuilt from the log. How much of each blocked the parent is + not measured: CPython's `Process.start()` returns once it has written the + child's arguments down a pipe, and the line comes after the worker's + initializer. +- The estimate's rebuild of the pool from its lines accounts for every + start, and dates every slice's start before its end (no notes). All three + starts fall in the opening burst, so this log cannot tell the start rules + apart: it is consistent with the model, not a test of its steady state. + The test fixture `toy-pool-12-workers-g44.log`, review r3's toy of the + pool on CPython 3.14 with twelve workers, has nine starts after a result, + four of which run the consume loop's start branch (the rest the opening + loop's); it is a toy, not the scorer. Its per-process records (float + clock) are `toy-pool-12-workers-g44-truth.jsonl` beside it, and the test + checks the rebuild against them. +- Whole-second stamps bias the rebuild slow on the first chunks measured. + A completion stamped in a spawning submit's second but landing after it + gives that submit a token, so an idle wait reads as slice time, with no + note. On the toy, three slices are misdated and chunk 1 reads 6.3% slow + (chunk 2 5.5%, chunk 3 0.1% fast) against the per-process truth; on + simulated d844-shaped pools chunk 1 read more than 5% slow in 29 of 200 + (review r4, MODEL-6). The test pins those three slices and those bands. +- Seconds per slice, excluding workers' first slices: 42.9, 41.8, 41.8, + 43.1 and 262.7 in chunks 1 to 5. The one-process means are 41.6, 46.1, + 42.1, 44.3 and 229.0. + - Single slices took 36 to 51 s in chunks 1 to 4 and 195 to 338 s in + chunk 5. + - Chunk 5 ran 6.1 times chunk 1. One process ran it at 5.5 times chunk 1, + and the prior scales by that ratio. + - Chunk 5 slowed within itself: its slices 1 to 12 averaged 227.4 s and + 13 to 29 averaged 287.5 s. Slice 13 started at 19:45:06, about 1,150 s + before the candidate's folder was moved, so the move does not explain + it. The cause is not known; host load is a guess. +- Peak RSS, as the scorer prints it (`ru_maxrss` on macOS): 4.38 to + 8.10 GiB in workers' slice lines (their start lines read 1.85 GiB) and + 3.66 to 5.01 GiB in the parent's. +- `scripts/replay_pool_log.py` replays the estimate's model from each 600 s + poll and compares its predicted last slice with the actual + (`pool-run-replay.txt`). + - Every prediction came early, by 259, 246, 263, 436, 216, 32 and 17 s + (0.4% to 10.0% of the 4,358 s to its last slice). + - The worst came at 2,400 s, when chunk 5's first measured slices were + its fastest: a chunk in progress is paced by the slices that have + ended, and the slow ones were still running. + - The earlier ones follow the prior's chunk-5 ratio: 236 s per slice + predicted, 263 s in the pool. + - On this log the estimate is optimistic. It never overstated the end. + +## Simulated runs on Modal (not measurements) + +`scripts/projection_grid.py` simulates 16-worker d844 runs with the test +pool simulator (`test_support/microcosm_build/h2h_pool_sim.py`). + +- Inputs: the one-process chunk means, times a speed factor f (Modal + seconds per Mac second), and a worker start cost T. +- It polls the estimate every 600 s against the plan's 14,505 s budget, + with `chunk-weights.json` as the prior. +- A run fits when its last slice ends at least 600 s before the budget does: + the estimate's allowance for the comparison and scorecards, which the grid + also gives them. The incumbent's tail took 12 s on the Mac; the + candidate's is not timed, though the scorer's code suggests it is short. + So a run whose last slice ends less than 600 s before the budget counts + as not fitting, and the watcher stops it though it would very likely + complete: f = 2, T = 175 s (last slice at 13,941 s) gets NO-GO at + 1,200 s ($3.06). +- The estimate gives its first NO-GO at the grid's times; the watcher stops + the app a poll later at the earliest, and only when a stream started at + or after the last restart shows a scorer line printed after both the + poll before and that stream's own start + (`docs/us-modal-stage-runbook.md`, the watcher's hang rule). +- Output: `projection-grid.txt`; `projection-grid-chunk5-1.5.txt`, with + chunk 5 a further 1.5 times slower than the prior says for both artifacts; + `projection-grid-candidate-chunk5-{1.2,1.3,1.5}.txt`, with only the + candidate's chunk 5 slower; and `projection-grid-pre-tool-300.txt`, with + `started-at` 300 s before the tool starts. +- The runner's budget counts from the tool's own start, the watcher's from + `started-at`, which `launch.sh` writes before `modal run`. The other grids + start both together. Container start and staging (the runbook allows + 300 s) come out of the watcher's budget only, so for the watcher a run + fits when its last slice ends 600 s plus that gap before the runner's + budget does. +- Cost is the class's non-preemptible list price, $0.00254688 per second. +- The simulator and the estimate implement the same model, so the grid + shows only what the watcher would do if Modal behaved like the model. It + says nothing about Modal's actual speed. + +Results: + +- With chunk 5 as the prior says, the run fits the budget: + - f = 1 with T up to 300 s (14,240 s at T = 300); + - f = 1.5 with T up to 175 s; + - f = 2 with T up to 100 s; + - at no T for f of 3 or more. +- Every run that does not fit gets a NO-GO at the first or second estimate, + 600 to 3,000 s in ($1.53 to $7.64). No run that fits gets one; here every + chunk is the prior times one factor f, so the first estimate's chunk is + as far from the prior as the rest. The grid starts the candidate's + workers as fast as the incumbent's; the estimate uses the incumbent's + start cost until the candidate logs one, so a slower candidate start is + caught about a poll later (review r4: f = 1.5, incumbent starts 100 s, + candidate 700 s, gets GO at 2,400 and 3,000 s and NO-GO at 3,600 s, + $9.17). +- With chunk 5 1.5 times slower, the fits shrink: + - f = 1 with T up to 175 s; + - f = 1.5 with T up to 100 s; + - f = 2 at T = 40 only. +- There, three runs that do not fit get GO until the incumbent's chunk 5 is + measured, then NO-GO by 5,400 s ($13.75). Still no run that fits gets a + NO-GO. +- With only the candidate's chunk 5 slower, nothing before the candidate's + own chunk 5 shows it. The scorer runs chunk-major, so that chunk, more + than half the candidate's slice work, comes last. Runs that do not fit + are caught late or not at all: + - at 1.2 and 1.3 times, the one run that does not fit only through it + (f = 1, T = 300 s) gets GO until 12,000 s ($30.56); + - at 1.5 times, two such runs get NO-GO at 7,800 s ($19.87) and + 12,000 s ($30.56). + No run that fits gets a NO-GO. +- With `started-at` 300 s before the tool, every estimate moves 300 s + later, and the one run that fits with less than 900 s to spare (f = 1, + T = 300 s, 14,240 s) gets a NO-GO at 1,200 s ($3.06). No other row + changes. + +A prior off on one chunk, not all, is what the grid does not cover. The +first estimate measures one chunk and scales its departure from the prior +onto all the work ahead, so it moves by that departure's share of the +scoring still to come. A run that fits with less spare than that can be +stopped at its first estimate, and the stop cannot be undone; a departure +the other way makes the estimate early and a NO-GO late. The test +`test_a_prior_off_on_one_chunk_moves_the_first_estimate_by_its_share` pins +the band: with chunk 1 at 1.1 times the prior, the first estimate is late +by up to a tenth of the scoring after it; a run with less spare than that +error is stopped, and one with a tenth of its run to spare is not. + +The same band comes back later. Once the incumbent's chunk 5 is measured, +its departure from the prior (1.147 in the real pool) is carried onto the +candidate. Review r4 found that 300 to 600 s late on the grid: f = 1, +T = 300 s (231 s spare) gets NO-GO at 5,400 s ($13.75). Once the candidate +has measured chunks of its own, its unmeasured ones scale by one ratio +pooled over them, carrying the incumbent's departures. A candidate that +does not share them still reads late: by about 800 s in review r4's +scenario with the real pool's departures (the run fitted by 898 s, so +the estimate still passed it, by 105 s). A single slice running far past +its chunk's pace is taken to run as far past it again. That reads early +until the poll passes the midpoint of the pace and the slice's real time, +then late, by up to its real time less the pace as the poll nears its end. +One 3,000 s straggler among 40 s slices reads 1,530 s late polled 2,285 s +in, and up to 2,960 s late just before it ends, so it can stop a run that +fits; the real pool's slowest chunk-5 slice was 1.29 times its mean, which +moves no verdict. + +## Lost log lines (simulated, not measurements) + +`scripts/lost_lines.py` damages simulated logs in some of the ways a +restarted log stream can: it removes stretches of whole seconds, or splits +the log there with nothing lost, and it restarts a stream inside one second +without losing a line. It reads the pieces as the watcher's streams and +compares the projection's verdict and estimate with the intact log's at the +same poll. It never loses part of one second's lines; that loss can give a +false NO-GO (below). Output: `lost-lines.txt`; its header gives each +section's command. The property tests draw intact logs only (one stream, or +the same log replayed whole by a second); named examples in the +projection's tests and this offline search cover the lost lines they +construct. + +The cut and boundary searches judge each poll at two budgets per shape: +one 265 s past the true end (the last slice plus the estimate's 600 s +allowance), so the run fits with the spare the d844 shape has at f = 1, +T = 300 s (14,505 s less its 14,240 s true end); and one 600 s short of the +true end, so it overruns. Counts are polls, one per damage case and poll +time. A false NO-GO is a NO-GO from the damaged log, under the fitting +budget, where the intact log gives none. The excess is the damaged +estimate less the intact one at the same poll, where both logs have an +estimate. The search reports it separately for held polls, where the +starts hold applies, and unheld ones (`lost-lines.txt`'s "where the hold +is off"). The starts hold exists because a stretch no stream covers after +a restart (a hole) may contain a pool's worker-start lines: until that +pool logs a start for every worker, the projection turns a time NO-GO (the +estimate past the budget) into WAIT. For the incumbent past its release, +it does so only while the candidate's estimate still uses the incumbent's +start cost, pace, first-slice extra or, for a chunk the candidate has not +measured, departures from the prior. The cut searches poll up to 1,200 s +after the last cut, and the boundary search the next three 600 s polls +after its restart; neither judges a later poll, and a hold can last past +them. At the unheld polls searched, no damage in the search can stop a run +whose intact estimate has more spare than the largest excess; at polls +where only one log has an estimate, or neither, no damaged log gives NO-GO +where the intact log does not, even at the overrunning budget. No damaged +log in the cut or boundary searches gives a stall NO-GO (no scorer line +for an hour, or four times the slowest slice if longer) that the intact +log lacks. The cut and boundary searches project each poll once with no +budget and derive the verdict at each budget from that estimate; the cut +searches also rerun every 50th poll at both budgets, and no rerun verdict +differs from the derived one. + +- d844 cuts, 12 shapes: f = 1, 1.01, 1.02 and 1.5 at T = 300 s; f = 1 and 2 + at T = 150 s; f = 3 at T = 100 s; f = 1 at T = 40 and 600 s; and f = 1 + with uneven start costs (100 s for the first start and 320 s for the + rest, 320 s then 200 s, and 200 s and 400 s alternating). A restart loses + 1, 10 or 60 s at each worker start, pool opening and release line; + nothing, 10 or 60 s every 120 s; or, in two restarts, 10 s at each of a + pair of such lines 300 to 2,400 s apart (all such pairs, or an even + sample of 60 to 90 where a shape has 120 or more). Polls come 5 to + 1,200 s after the last cut. Every shape gives 0 false NO-GOs, and no + unheld poll reads later than the intact log (largest excess 0 s); held + polls read up to 3,300 s late. With a 320 s first start cost and 200 s + for the rest, the intact log itself gives NO-GO at 7,102 polls under the + fitting budget, which leaves 265 s to spare: the estimate's own error, + not the damage's. For example, against that 11,574 s budget (the true + end, 11,309 s, plus 265 s) and polled every 5 s, the intact log gives + NO-GO from +670 to +1,780 s (11,839 s at +1,200 s) and again from +3,975 + to +4,770 s, and GO between and after, with no damage flag. Polling + every 600 s, the watcher would stop that run between +1,270 and +1,780 s + at 103 of the 120 poll phases on a 5 s grid (inferred from its rule, + given a scorer line printed after each restart's poll and the new + stream's start; the projection gave the verdicts). It stops the run when + it polls at +900 + and +1,500 s, say, and not when it polls at +1,200 and +1,800 s. + The grid above gives every run one start cost, so it does not test this + shape. Under the overrunning budget, damaged logs give GO where the + intact log gives NO-GO at 3,004 polls (f = 3, T = 100 s) and 816 (f = 1, + T = 40 s), so the damage misses the stop at those polls. The search polls + only to 1,200 s after a cut, so it does not show whether a later poll + stops those runs; the runner's budget bounds them. +- Random pools drawn as the property tests draw them (seed 3, 100 pools), + with the same cuts (the regular ones every 300 s). The search runs them + twice: once with one to four start costs per pool, where the tests draw + one, and once with each pool's first start cost for every start + (`--constant-starts`). Both give 0 false NO-GOs and a largest excess of + 0 s at unheld polls; held polls read up to 5,039 s late with varied + start costs and 5,664 s with constant ones. Before the fix, the starts + hold (as of aa2addb2d) let false NO-GOs through in pool 94 under + constant start costs: a lost incumbent start line left the rebuild a + worker short, so it placed that worker's slices on another, and the + candidate's estimate, which took that chunk's pace from the misread + incumbent, read 495 s late once the hold stopped applying at the + candidate's first start line. The fix (baf2052287) keeps holding a + released incumbent that is short of starts while the candidate's + estimate uses any of the incumbent's timing, which closes that case + (`test_a_lost_incumbent_start_holds_while_the_candidate_paces_from_it`). + With varied start costs the intact log itself gives NO-GO at 54,346 polls + of runs that fit by 265 s, and at none with constant ones: the estimate's + own error, which the search counts separately and does not attribute to + lost lines. Under the overrunning budget, damaged logs miss the stop at + 4,420 polls (varied) and 7,782 (constant). +- Restarts that lose nothing, across the d844 grid (f = 1 to 3; T = 40 to + 600 s, and 100 s then 320 s): a split every 60 s (in runs that overrun, + up to the intact log's first NO-GO), polled every 600 s against the + plan's 14,505 s budget. In the 10 shapes that fit, no split gives NO-GO, + and 11 to 66 polls per shape (each shape has 105 to 240 splits) turn GO + into WAIT; the search does not log why, and the code points to waits for + the new stream to deliver the running slices' lines (inferred). In the + 18 that overrun, the intact log gives NO-GO 600 to 1,800 s in, and every + split (9 to 29 per shape) gives NO-GO too, all but at most one to three + of them later: the latest, per shape, 600 to 8,400 s after the intact + log ($1.53 to $21.39; 8,400 s at T = 600 s for every f). The cause, + inferred and not traced: a split after the incumbent's pool opens (64 f + seconds in) leaves a stretch no stream covers, which the projection + cannot tell from a restart that lost start lines, so the starts hold + keeps a time NO-GO as WAIT until the incumbent logs its 16th start; a + split before the pool opens leaves the first stream with no records, so + no hole forms. The counts fit that exactly in all 18 shapes: the polls + that turn NO-GO into WAIT equal the splits after the pool opens times the + largest delay in 600 s polls (at f = 1, T = 450 s, 18 splits times 11 + polls gives 198). One split comes before the pool opens at f = 1 and + 1.5, two at f = 2 and three at f = 3. + `test_a_lossless_restart_reads_as_the_intact_log_and_holds_only_a_no_go` + pins the `starts_unconfirmed` flag to the 16th start for one such + restart, and + `test_the_hold_reaches_pools_a_hole_could_cut_and_a_stall_still_stops` + shows a restart that loses nothing holding an estimate past the budget + as WAIT. In all 18 shapes the delay ends at the first 600 s poll at or + after the incumbent's 16th start, as arithmetic on the simulator's start + costs places it (the search does not print start times). The search does + not cover the grids where a NO-GO comes late anyway (only the candidate's + chunk 5 slower). +- Restarts inside one second, at every second with records, polled at the + next three 600 s polls, in the two d844 shapes at f = 1 (T = 300 s, and + 100 s then 320 s) and 30 random pools (seed 3, varied start costs). A new + stream that replays the whole second, or only the last record seen, + gives the intact log's verdict at every poll and no later estimate. A + continuation that splits the second's records between the streams, + losing nothing, gives 0 false NO-GOs, but the random pools read up to + 24 s late (0 s in both d844 shapes) and one poll reads early enough to + miss a stop. The streams meet inside the second, so no hole forms and + the starts hold never applies. Inferred from the code, not traced (the + boundary command in the header passes no `--rows`, so the output does + not name the pool or second): the parse counts a line that both streams + show only as many times as the stream showing it most, so a replay adds + nothing; but when the split falls between the parent's identical `after + receiving` lines (one per slice result it takes) in one second, the + parse keeps only the copies of the stream that shows more of them and + loses the rest. The + rebuild then either no longer fits the log (245 polls turn GO into WAIT + with no estimate, which the code suggests are log gaps) or fits with + misdated slices. The 24 s is the largest excess at the three polls + searched after each split, not a bound: a run whose intact estimate had + less spare than that at such a poll would get a false NO-GO there. +- Not searched: a restart that loses part of one second's lines. The + projection marks a hole only where a stream's first record comes after + the second the earlier streams reached (`_stream_holes` compares + `first > reach`), so when lines on both sides of the loss share that + second, no hole forms and no hold applies. A lost slice line then reads + as a straggler until the parent's receive line for it shows a log gap, + and until then the estimate can give a false NO-GO with no damage flag. + For example, take seed 3's pool 7 (`random_pools(3)` in + `scripts/lost_lines.py`: 11 workers; incumbent chunks of 7 slices at 90, + 213 and 212 s; candidate chunks of 80 at 255, 286 and 217 s; start costs + 221, 325 and 369 s; first-slice extra 183 s; the run's own times as the + prior). A restart in the 08:34:57Z second (+2,097 s) that loses one line, + the incumbent's chunk 2 slice 3/7, keeps its neighbours, slices 2/7 and + 4/7, which share that stamp. Polled at +2,400 s, the intact log + estimates 11,535.2 s and the damaged one 11,718.2 s, with no flag; the + last slice ends at 11,078 s, and with the 600 s allowance at 11,678 s. + Against an 11,700 s budget the damaged log gives NO-GO there and the + intact one GO, though the intact log gives NO-GO itself from +2,895 to + +3,110 s (up to 11,704.0 s, likely from its uneven start costs; + inferred). Against 11,710 s, polled every 5 s through the candidate's + last slice, the intact log never gives NO-GO and the damaged one gives + it from +2,255 to +2,460 s; from +2,495 s the receive line shows the gap, + and the log gap holds WAIT. The cut search removes whole seconds and the + boundary arms lose no lines, so neither covers this case. + The watcher stops the app only on a NO-GO that comes a poll after the + restart an earlier NO-GO set off, with a scorer line printed after that + restart's poll and the new stream's start + (`docs/us-modal-stage-runbook.md`), and this false NO-GO lasts + 205 s, less than a poll. So at 11,710 s the + watcher does not stop the run: its next poll comes after +2,495 s, when + a restart that replays has put the lost line back (GO) or one that does + not leaves the log gap (WAIT). At 11,700 s a restart that replays puts + the line back, and a next poll inside the intact log's own NO-GO stretch + stops the run (34 of the 42 restart times on the 5 s grid). The watcher + could stop a run that fits on a false NO-GO that lasts longer than a + poll. These watcher outcomes come from its rule applied to the + projection's verdicts, not from a run of it, and assume the new stream + shows a scorer line printed after the restart's poll and its own start; + nothing has searched for + longer false NO-GOs. +- At the polls searched, the damage searched costs a late or missed stop, + not a false one, except that a restart splitting one second's lines can + read 24 s late (above). Losing part of one second's lines, which the + search never does, can give a false NO-GO (above). A lost slice line + becomes a log gap once the parent takes its result, and a log gap holds + WAIT for the rest of the run. A lost start holds a time NO-GO as WAIT + while its pool has logged fewer starts than workers: the candidate's for + the rest of its pool, the incumbent's until its release and then while + the candidate's estimate still uses the incumbent's timing. The rebuild + shows a log gap once it needs the missing worker, which in a pool with + fewer slices than two per worker it may never do. A restart that loses + nothing holds the same way, delaying a NO-GO by up to 8,400 s ($21.39) + here. The runner's budget bounds every case: 14,505 s, $36.94 at the + class's list price. +- Not covered: a restart that loses part of one second's lines (above); a + stream that drops lines without ending; Modal's own log streams (nobody + has tried whether a restart replays, or two streams of one app at once). + +What this rests on: + +- Modal's speed for this scorer. The runbook's measured Modal slowdown for + single-core materialize work, 3.3 to 7.6 times per chunk, would not fit at + any start cost. Nothing has measured this scorer on Modal. +- The candidate's start cost. Until its pool logs a start, the estimate uses + the incumbent's. The candidate frame has 6.1 times the households (177 + slices against 29), so that is likely optimistic, though only until the + candidate's first start is logged, slice or not. +- The candidate's chunk ratios in a pool. Only the incumbent's were measured + in one (chunk 5 at 6.1 times chunk 1, against 5.5 in one process); the + candidate's chunk 5 comes last, so a departure there is seen late. +- Loading the candidate. The estimate leaves it out while the incumbent + scores; the grid takes it as 11 s times f. diff --git a/docs/evidence/us-h2h-speed/chunk-weights.json b/docs/evidence/us-h2h-speed/chunk-weights.json new file mode 100644 index 0000000000..d32df6d110 --- /dev/null +++ b/docs/evidence/us-h2h-speed/chunk-weights.json @@ -0,0 +1,34 @@ +{ + "source": "slices-2cfe3043d.json (two timed slices per artifact and chunk; warm-up slices excluded)", + "slices_per_chunk": { + "incumbent": 29, + "candidate": 177 + }, + "candidate_mean_slice_seconds": [ + 38.91, + 41.23, + 38.06, + 34.66, + 199.68 + ], + "incumbent_mean_slice_seconds": [ + 41.59, + 46.05, + 42.11, + 44.33, + 229.01 + ], + "candidate_relative_chunk_seconds": [ + 1.0, + 1.0596, + 0.9782, + 0.8905, + 5.1312 + ], + "slice_seconds_one_process": { + "candidate": 62401, + "incumbent": 11690, + "total": 74091, + "over_16_workers": 4631 + } +} diff --git a/docs/evidence/us-h2h-speed/lost-lines.txt b/docs/evidence/us-h2h-speed/lost-lines.txt new file mode 100644 index 0000000000..1f1e37f213 --- /dev/null +++ b/docs/evidence/us-h2h-speed/lost-lines.txt @@ -0,0 +1,67 @@ +Simulated, not measurements: scripts/lost_lines.py at baf2052287, run 2026-11-17 on , a copy of that commit's tools/, test_support/ and docs/evidence/us-h2h-speed/. +Each section below is the verbatim output of python -I -B scripts/lost_lines.py with, in order: + (1) --section cut-d844 --rows rows-cut-d844.jsonl (2) --section cut-random --pools 100 --seeds 3 --rows rows-cut-random.jsonl + (3) --section cut-random --pools 100 --seeds 3 --constant-starts --rows rows-cut-random-constant.jsonl (4) --section lossless (5) --section boundary; sections (2) and (3) print the same title, and the pool 0 line of (3) shows a single start_cost. +cut: a restart that does not replay loses a stretch (d844) + d844 f=1 T=300 (true end 14240 s): 35804 polls, 8000 with both estimates, max excess 0.0 s where the hold is off (5335 held, max excess there 81.0 s); at the true end +265 s: GO->GO 8000, GO->WAIT 26624, WAIT->WAIT 1180 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 2665, NO-GO->WAIT 31959, WAIT->WAIT 1180; NO-GO from a stall the intact log does not show 0 [288 s] + d844 f=1.01 T=300 (true end 14278 s): 37005 polls, 7972 with both estimates, max excess 0.0 s where the hold is off (5316 held, max excess there 81.0 s); at the true end +265 s: GO->GO 7972, GO->WAIT 27853, WAIT->WAIT 1180 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 2656, NO-GO->WAIT 33169, WAIT->WAIT 1180; NO-GO from a stall the intact log does not show 0 [590 s] + d844 f=1.02 T=300 (true end 14319 s): 36731 polls, 7995 with both estimates, max excess 0.0 s where the hold is off (5308 held, max excess there 81.0 s); at the true end +265 s: GO->GO 7995, GO->WAIT 27556, WAIT->WAIT 1180 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 2687, NO-GO->WAIT 32864, WAIT->WAIT 1180; NO-GO from a stall the intact log does not show 0 [926 s] + d844 f=1 T=150 (true end 9519 s): 34431 polls, 5514 with both estimates, max excess 0.0 s where the hold is off (2791 held, max excess there 492.9 s); at the true end +265 s: GO->GO 5484, GO->WAIT 28157, WAIT->WAIT 790 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 2723, NO-GO->WAIT 30918, WAIT->WAIT 790; NO-GO from a stall the intact log does not show 0 [1284 s] + d844 f=2 T=150 (true end 13985 s): 39276 polls, 7476 with both estimates, max excess 0.0 s where the hold is off (3389 held, max excess there 2330.4 s); at the true end +265 s: GO->GO 7343, GO->WAIT 30535, WAIT->WAIT 1398 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 4087, NO-GO->WAIT 33791, WAIT->WAIT 1398; NO-GO from a stall the intact log does not show 0 [1669 s] + d844 f=1.5 T=300 (true end 16303 s): 40057 polls, 9024 with both estimates, max excess 0.0 s where the hold is off (5515 held, max excess there 296.0 s); at the true end +265 s: GO->GO 9024, GO->WAIT 29754, WAIT->WAIT 1279 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 3509, NO-GO->WAIT 35269, WAIT->WAIT 1279; NO-GO from a stall the intact log does not show 0 [1979 s] + d844 f=3 T=100 (true end 17499 s): 45161 polls, 12115 with both estimates, max excess 0.0 s where the hold is off (6389 held, max excess there 1219.3 s); at the true end +265 s: GO->GO 11703, GO->WAIT 31774, WAIT->GO 92, WAIT->WAIT 1592 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->GO 3004, NO-GO->NO-GO 5726, NO-GO->WAIT 34747, WAIT->GO 92, WAIT->WAIT 1592; NO-GO from a stall the intact log does not show 0 [2546 s] + d844 f=1 T=40 (true end 6356 s): 30199 polls, 4698 with both estimates, max excess 0.0 s where the hold is off (1788 held, max excess there 1203.1 s); at the true end +265 s: GO->GO 4624, GO->WAIT 24985, WAIT->GO 56, WAIT->WAIT 534 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->GO 816, NO-GO->NO-GO 2910, NO-GO->WAIT 25883, WAIT->GO 56, WAIT->WAIT 534; NO-GO from a stall the intact log does not show 0 [2920 s] + d844 f=1 T=600 (true end 23840 s): 41744 polls, 10211 with both estimates, max excess 0.0 s where the hold is off (7533 held, max excess there 81.0 s); at the true end +265 s: GO->GO 10211, GO->WAIT 29835, WAIT->WAIT 1698 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 2678, NO-GO->WAIT 37368, WAIT->WAIT 1698; NO-GO from a stall the intact log does not show 0 [3293 s] + d844 f=1 T=[100, 320, 320]... (true end 14440 s): 38664 polls, 7815 with both estimates, max excess 0.0 s where the hold is off (5153 held, max excess there 3300.0 s); at the true end +265 s: GO->GO 7815, GO->WAIT 29856, WAIT->WAIT 993 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: GO->GO 1596, GO->WAIT 7690, NO-GO->NO-GO 2459, NO-GO->WAIT 25926, WAIT->WAIT 993; NO-GO from a stall the intact log does not show 0 [3658 s] + d844 f=1 T=[320, 200, 200]... (true end 11309 s): 35336 polls, 6545 with both estimates, max excess 0.0 s where the hold is off (3881 held, max excess there 683.5 s); at the true end +265 s: GO->GO 5196, GO->WAIT 21941, NO-GO->GO 32, NO-GO->NO-GO 118, NO-GO->WAIT 6952, WAIT->WAIT 1097 (false NO-GO 0; the intact log's own NO-GO 7102); at the true end -600 s: NO-GO->NO-GO 2664, NO-GO->WAIT 31575, WAIT->WAIT 1097; NO-GO from a stall the intact log does not show 0 [3985 s] + d844 f=1 T=[200, 400, 200]... (true end 14240 s): 38144 polls, 7927 with both estimates, max excess 0.0 s where the hold is off (5231 held, max excess there 1600.0 s); at the true end +265 s: GO->GO 7892, GO->WAIT 29041, WAIT->WAIT 1211 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: GO->GO 621, GO->WAIT 2988, NO-GO->NO-GO 2600, NO-GO->WAIT 30724, WAIT->WAIT 1211; NO-GO from a stall the intact log does not show 0 [4337 s] +direct judgements: 18090 checked, 0 differ from the derived verdict; 4337 s +cut: a restart that does not replay loses a stretch (random) + seed 3 pool 0 {'workers': 8, 'incumbent_seconds': [298, 86, 209, 262, 53], 'candidate_seconds': [26, 260, 152, 139, 118], 'incumbent_slices': 23, 'candidate_slices': 61, 'start_cost': [204, 328, 78, 119], 'first_slice_extra': 162}: max excess 0.0 s + seed 3, 100 pools: 1668873 polls, 174070 with both estimates, max excess 0.0 s where the hold is off (119423 held, max excess there 5039.0 s); at the true end +265 s: GO->GO 154385, GO->WAIT 1199331, NO-GO->GO 954, NO-GO->NO-GO 643, NO-GO->WAIT 52749, WAIT->GO 327, WAIT->WAIT 260484 (false NO-GO 0; the intact log's own NO-GO 54346); at the true end -600 s: GO->GO 8283, GO->WAIT 76414, NO-GO->GO 4420, NO-GO->NO-GO 54127, NO-GO->WAIT 1264818, WAIT->GO 121, WAIT->WAIT 260690; NO-GO from a stall the intact log does not show 0 [4684 s] +direct judgements: 66664 checked, 0 differ from the derived verdict; 4684 s +cut: a restart that does not replay loses a stretch (random) + seed 3 pool 0 {'workers': 8, 'incumbent_seconds': [298, 86, 209, 262, 53], 'candidate_seconds': [26, 260, 152, 139, 118], 'incumbent_slices': 23, 'candidate_slices': 61, 'start_cost': 204, 'first_slice_extra': 162}: max excess 0.0 s + seed 3, 100 pools: 1646161 polls, 176182 with both estimates, max excess 0.0 s where the hold is off (121451 held, max excess there 5664.0 s); at the true end +265 s: GO->GO 161387, GO->WAIT 1236313, WAIT->GO 1142, WAIT->WAIT 247319 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->GO 7782, NO-GO->NO-GO 54731, NO-GO->WAIT 1335187, WAIT->GO 333, WAIT->WAIT 248128; NO-GO from a stall the intact log does not show 0 [4689 s] +direct judgements: 65750 checked, 0 differ from the derived verdict; 4689 s +lossless: a split every 60 s that loses nothing, polled every 600 s + d844 f=1 T=40 (fits, intact NO-GO at - s): 105 splits; GO->GO 539, GO->WAIT 11 + d844 f=1 T=100 (fits, intact NO-GO at - s): 132 splits; GO->GO 884, GO->WAIT 26 + d844 f=1 T=175 (fits, intact NO-GO at - s): 171 splits; GO->GO 1505, GO->WAIT 25 + d844 f=1 T=300 (fits, intact NO-GO at - s): 237 splits; GO->GO 2684, GO->WAIT 66, WAIT->WAIT 10 + d844 f=1 T=450 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 198, WAIT->WAIT 10; first NO-GO up to 6600 s later ($16.81) + d844 f=1 T=600 (overruns, intact NO-GO at 1800 s): 29 splits; NO-GO->NO-GO 29, NO-GO->WAIT 392, WAIT->WAIT 30; first NO-GO up to 8400 s later ($21.39) + d844 f=1 T=[100, 320, 320]... (fits, intact NO-GO at - s): 240 splits; GO->GO 2950, GO->WAIT 50 + d844 f=1.5 T=40 (fits, intact NO-GO at - s): 145 splits; GO->GO 1007, GO->WAIT 43 + d844 f=1.5 T=100 (fits, intact NO-GO at - s): 170 splits; GO->GO 1488, GO->WAIT 42 + d844 f=1.5 T=175 (fits, intact NO-GO at - s): 207 splits; GO->GO 2066, GO->WAIT 34 + d844 f=1.5 T=300 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 126, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) + d844 f=1.5 T=450 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 198, WAIT->WAIT 10; first NO-GO up to 6600 s later ($16.81) + d844 f=1.5 T=600 (overruns, intact NO-GO at 1800 s): 29 splits; NO-GO->NO-GO 29, NO-GO->WAIT 392, WAIT->WAIT 30; first NO-GO up to 8400 s later ($21.39) + d844 f=1.5 T=[100, 320, 320]... (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 126, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) + d844 f=2 T=40 (fits, intact NO-GO at - s): 187 splits; GO->GO 1653, GO->WAIT 57 + d844 f=2 T=100 (fits, intact NO-GO at - s): 206 splits; GO->GO 2034, GO->WAIT 66 + d844 f=2 T=175 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 51, WAIT->WAIT 10; first NO-GO up to 1800 s later ($4.58) + d844 f=2 T=300 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 119, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) + d844 f=2 T=450 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 187, WAIT->WAIT 10; first NO-GO up to 6600 s later ($16.81) + d844 f=2 T=600 (overruns, intact NO-GO at 1800 s): 29 splits; NO-GO->NO-GO 29, NO-GO->WAIT 378, WAIT->WAIT 30; first NO-GO up to 8400 s later ($21.39) + d844 f=2 T=[100, 320, 320]... (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 119, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) + d844 f=3 T=40 (overruns, intact NO-GO at 600 s): 9 splits; NO-GO->NO-GO 9, NO-GO->WAIT 6; first NO-GO up to 600 s later ($1.53) + d844 f=3 T=100 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 16, WAIT->WAIT 10; first NO-GO up to 600 s later ($1.53) + d844 f=3 T=175 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 48, WAIT->WAIT 10; first NO-GO up to 1800 s later ($4.58) + d844 f=3 T=300 (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 112, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) + d844 f=3 T=450 (overruns, intact NO-GO at 1800 s): 29 splits; NO-GO->NO-GO 29, NO-GO->WAIT 260, WAIT->WAIT 30; first NO-GO up to 6000 s later ($15.28) + d844 f=3 T=600 (overruns, intact NO-GO at 1800 s): 29 splits; NO-GO->NO-GO 29, NO-GO->WAIT 364, WAIT->WAIT 30; first NO-GO up to 8400 s later ($21.39) + d844 f=3 T=[100, 320, 320]... (overruns, intact NO-GO at 1200 s): 19 splits; NO-GO->NO-GO 19, NO-GO->WAIT 112, WAIT->WAIT 10; first NO-GO up to 4200 s later ($10.70) +direct judgements: 0 checked, 0 differ from the derived verdict; 308 s +boundary: a restart inside one second + d844 f=1 T=300, split: 624 polls, 584 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 584, GO->WAIT 40 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 584, NO-GO->WAIT 40; NO-GO from a stall the intact log does not show 0 + d844 f=1 T=300, replay-second: 855 polls, 851 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 851, WAIT->WAIT 4 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 851, WAIT->WAIT 4; NO-GO from a stall the intact log does not show 0 + d844 f=1 T=300, replay-last: 855 polls, 851 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 851, WAIT->WAIT 4 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: NO-GO->NO-GO 851, WAIT->WAIT 4; NO-GO from a stall the intact log does not show 0 + d844 f=1 T=[100, 320, 320]..., split: 654 polls, 614 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 614, GO->WAIT 40 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: GO->GO 18, GO->WAIT 6, NO-GO->NO-GO 596, NO-GO->WAIT 34; NO-GO from a stall the intact log does not show 0 + d844 f=1 T=[100, 320, 320]..., replay-second: 885 polls, 885 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 885 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: GO->GO 90, NO-GO->NO-GO 795; NO-GO from a stall the intact log does not show 0 + d844 f=1 T=[100, 320, 320]..., replay-last: 885 polls, 885 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 885 (false NO-GO 0; the intact log's own NO-GO 0); at the true end -600 s: GO->GO 90, NO-GO->NO-GO 795; NO-GO from a stall the intact log does not show 0 + all 32 shapes, split: 6685 polls, 6407 with both estimates, max excess 24.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 6257, GO->WAIT 245, NO-GO->NO-GO 150, WAIT->WAIT 33 (false NO-GO 0; the intact log's own NO-GO 150); at the true end -600 s: GO->GO 52, GO->WAIT 8, NO-GO->GO 1, NO-GO->NO-GO 6354, NO-GO->WAIT 237, WAIT->WAIT 33; NO-GO from a stall the intact log does not show 0 + all 32 shapes, replay-second: 10149 polls, 9922 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 9619, NO-GO->NO-GO 303, WAIT->WAIT 227 (false NO-GO 0; the intact log's own NO-GO 303); at the true end -600 s: GO->GO 198, NO-GO->NO-GO 9724, WAIT->WAIT 227; NO-GO from a stall the intact log does not show 0 + all 32 shapes, replay-last: 10149 polls, 9922 with both estimates, max excess 0.0 s where the hold is off (0 held, max excess there -); at the true end +265 s: GO->GO 9619, NO-GO->NO-GO 303, WAIT->WAIT 227 (false NO-GO 0; the intact log's own NO-GO 303); at the true end -600 s: GO->GO 198, NO-GO->NO-GO 9724, WAIT->WAIT 227; NO-GO from a stall the intact log does not show 0 +direct judgements: 0 checked, 0 differ from the derived verdict; 177 s diff --git a/docs/evidence/us-h2h-speed/pool-run-replay.txt b/docs/evidence/us-h2h-speed/pool-run-replay.txt new file mode 100644 index 0000000000..75fa9cc0c3 --- /dev/null +++ b/docs/evidence/us-h2h-speed/pool-run-replay.txt @@ -0,0 +1,10 @@ +pool opened 2026-11-16T19:01:14Z; last slice 2026-11-16T20:13:52Z +(4358 s for 145 slices on 3 workers) + poll s done chunks measured predicted last slice error s error % + 600 35 1,2 2026-11-16T20:09:33Z -259 -5.9 + 1200 78 1,2,3 2026-11-16T20:09:46Z -246 -5.6 + 1800 116 1,2,3,4 2026-11-16T20:09:29Z -263 -6.0 + 2400 125 1,2,3,4,5 2026-11-16T20:06:36Z -436 -10.0 + 3000 131 1,2,3,4,5 2026-11-16T20:10:16Z -216 -4.9 + 3600 137 1,2,3,4,5 2026-11-16T20:13:19Z -32 -0.7 + 4200 143 1,2,3,4,5 2026-11-16T20:13:34Z -17 -0.4 diff --git a/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.2.txt b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.2.txt new file mode 100644 index 0000000000..f1b170b997 --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.2.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.2x beyond the prior (candidate only); budget 14505 s; started-at 0 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 6836 17.41 yes | 600 1.53 GO 6382.4 | - - + 1 100 | 8449 21.52 yes | 600 1.53 GO 7995.0 | - - + 1 175 | 10774 27.44 yes | 600 1.53 GO 10320.0 | - - + 1 300 | 14720 36.94 no | 1200 3.06 GO 14263.7 | 12000 30.56 + 1 450 | 19520 36.94 no | 1200 3.06 NO-GO 19063.7 | 1200 3.06 + 1 600 | 24320 36.94 no | 1800 4.58 NO-GO 23863.7 | 1800 4.58 + 1.5 40 | 9461 24.10 yes | 600 1.53 GO 8723.8 | - - + 1.5 100 | 10963 27.92 yes | 600 1.53 GO 10193.4 | - - + 1.5 175 | 13136 33.46 yes | 600 1.53 GO 12366.8 | - - + 1.5 300 | 17011 36.94 no | 1200 3.06 NO-GO 16241.8 | 1200 3.06 + 1.5 450 | 21767 36.94 no | 1200 3.06 NO-GO 21000.4 | 1200 3.06 + 1.5 600 | 26567 36.94 no | 1800 4.58 NO-GO 25800.4 | 1800 4.58 + 2 40 | 12183 31.03 yes | 600 1.53 GO 11193.6 | - - + 2 100 | 13352 34.01 yes | 600 1.53 GO 12365.2 | - - + 2 175 | 15501 36.94 no | 1200 3.06 NO-GO 14514.3 | 1200 3.06 + 2 300 | 19376 36.94 no | 1200 3.06 NO-GO 18389.3 | 1200 3.06 + 2 450 | 24028 36.94 no | 1200 3.06 NO-GO 23042.2 | 1200 3.06 + 2 600 | 28818 36.94 no | 1800 4.58 NO-GO 27832.2 | 1800 4.58 + 3 40 | 17571 36.94 no | 600 1.53 NO-GO 16121.5 | 600 1.53 + 3 100 | 18939 36.94 no | 1200 3.06 NO-GO 17488.6 | 1200 3.06 + 3 175 | 20543 36.94 no | 1200 3.06 NO-GO 19091.0 | 1200 3.06 + 3 300 | 24136 36.94 no | 1200 3.06 NO-GO 22684.3 | 1200 3.06 + 3 450 | 28786 36.94 no | 1800 4.58 NO-GO 27334.3 | 1800 4.58 + 3 600 | 33436 36.94 no | 1800 4.58 NO-GO 31984.3 | 1800 4.58 + 4 40 | 22979 36.94 no | 1200 3.06 NO-GO 20998.8 | 1200 3.06 + 4 100 | 24146 36.94 no | 1200 3.06 NO-GO 22148.1 | 1200 3.06 + 4 175 | 25683 36.94 no | 1200 3.06 NO-GO 23687.7 | 1200 3.06 + 4 300 | 29312 36.94 no | 1800 4.58 NO-GO 27316.9 | 1800 4.58 + 4 450 | 33523 36.94 no | 1800 4.58 NO-GO 31528.5 | 1800 4.58 + 4 600 | 38173 36.94 no | 1800 4.58 NO-GO 36178.5 | 1800 4.58 + 5 40 | 28377 36.94 no | 1200 3.06 NO-GO 25935.3 | 1200 3.06 + 5 100 | 29581 36.94 no | 1200 3.06 NO-GO 27139.8 | 1200 3.06 + 5 175 | 31403 36.94 no | 1800 4.58 NO-GO 28961.1 | 1800 4.58 + 5 300 | 34085 36.94 no | 1800 4.58 NO-GO 31646.9 | 1800 4.58 + 5 450 | 38262 36.94 no | 1800 4.58 NO-GO 35823.5 | 1800 4.58 + 5 600 | 42912 36.94 no | 2400 6.11 NO-GO 40473.5 | 2400 6.11 + 7.6 40 | 42475 36.94 no | 1800 4.58 NO-GO 38759.7 | 1800 4.58 + 7.6 100 | 43543 36.94 no | 1800 4.58 NO-GO 39816.1 | 1800 4.58 + 7.6 175 | 45003 36.94 no | 1800 4.58 NO-GO 41278.7 | 1800 4.58 + 7.6 300 | 47841 36.94 no | 2400 6.11 NO-GO 44117.6 | 2400 6.11 + 7.6 450 | 51305 36.94 no | 2400 6.11 NO-GO 47582.6 | 2400 6.11 + 7.6 600 | 55842 36.94 no | 3000 7.64 NO-GO 52119.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.3.txt b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.3.txt new file mode 100644 index 0000000000..239748b7ab --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.3.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.3x beyond the prior (candidate only); budget 14505 s; started-at 0 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 7076 18.02 yes | 600 1.53 GO 6382.4 | - - + 1 100 | 8689 22.13 yes | 600 1.53 GO 7995.0 | - - + 1 175 | 11014 28.05 yes | 600 1.53 GO 10320.0 | - - + 1 300 | 14960 36.94 no | 1200 3.06 GO 14263.7 | 12000 30.56 + 1 450 | 19760 36.94 no | 1200 3.06 NO-GO 19063.7 | 1200 3.06 + 1 600 | 24560 36.94 no | 1800 4.58 NO-GO 23863.7 | 1800 4.58 + 1.5 40 | 9821 25.01 yes | 600 1.53 GO 8723.8 | - - + 1.5 100 | 11323 28.84 yes | 600 1.53 GO 10193.4 | - - + 1.5 175 | 13496 34.37 yes | 600 1.53 GO 12366.8 | - - + 1.5 300 | 17371 36.94 no | 1200 3.06 NO-GO 16241.8 | 1200 3.06 + 1.5 450 | 22127 36.94 no | 1200 3.06 NO-GO 21000.4 | 1200 3.06 + 1.5 600 | 26927 36.94 no | 1800 4.58 NO-GO 25800.4 | 1800 4.58 + 2 40 | 12663 32.25 yes | 600 1.53 GO 11193.6 | - - + 2 100 | 13832 35.23 yes | 600 1.53 GO 12365.2 | - - + 2 175 | 15981 36.94 no | 1200 3.06 NO-GO 14514.3 | 1200 3.06 + 2 300 | 19856 36.94 no | 1200 3.06 NO-GO 18389.3 | 1200 3.06 + 2 450 | 24508 36.94 no | 1200 3.06 NO-GO 23042.2 | 1200 3.06 + 2 600 | 29298 36.94 no | 1800 4.58 NO-GO 27832.2 | 1800 4.58 + 3 40 | 18291 36.94 no | 600 1.53 NO-GO 16121.5 | 600 1.53 + 3 100 | 19659 36.94 no | 1200 3.06 NO-GO 17488.6 | 1200 3.06 + 3 175 | 21263 36.94 no | 1200 3.06 NO-GO 19091.0 | 1200 3.06 + 3 300 | 24856 36.94 no | 1200 3.06 NO-GO 22684.3 | 1200 3.06 + 3 450 | 29506 36.94 no | 1800 4.58 NO-GO 27334.3 | 1800 4.58 + 3 600 | 34156 36.94 no | 1800 4.58 NO-GO 31984.3 | 1800 4.58 + 4 40 | 23939 36.94 no | 1200 3.06 NO-GO 20998.8 | 1200 3.06 + 4 100 | 25106 36.94 no | 1200 3.06 NO-GO 22148.1 | 1200 3.06 + 4 175 | 26643 36.94 no | 1200 3.06 NO-GO 23687.7 | 1200 3.06 + 4 300 | 30272 36.94 no | 1800 4.58 NO-GO 27316.9 | 1800 4.58 + 4 450 | 34483 36.94 no | 1800 4.58 NO-GO 31528.5 | 1800 4.58 + 4 600 | 39133 36.94 no | 1800 4.58 NO-GO 36178.5 | 1800 4.58 + 5 40 | 29577 36.94 no | 1200 3.06 NO-GO 25935.3 | 1200 3.06 + 5 100 | 30781 36.94 no | 1200 3.06 NO-GO 27139.8 | 1200 3.06 + 5 175 | 32603 36.94 no | 1800 4.58 NO-GO 28961.1 | 1800 4.58 + 5 300 | 35285 36.94 no | 1800 4.58 NO-GO 31646.9 | 1800 4.58 + 5 450 | 39462 36.94 no | 1800 4.58 NO-GO 35823.5 | 1800 4.58 + 5 600 | 44112 36.94 no | 2400 6.11 NO-GO 40473.5 | 2400 6.11 + 7.6 40 | 44299 36.94 no | 1800 4.58 NO-GO 38759.7 | 1800 4.58 + 7.6 100 | 45367 36.94 no | 1800 4.58 NO-GO 39816.1 | 1800 4.58 + 7.6 175 | 46827 36.94 no | 1800 4.58 NO-GO 41278.7 | 1800 4.58 + 7.6 300 | 49665 36.94 no | 2400 6.11 NO-GO 44117.6 | 2400 6.11 + 7.6 450 | 53129 36.94 no | 2400 6.11 NO-GO 47582.6 | 2400 6.11 + 7.6 600 | 57666 36.94 no | 3000 7.64 NO-GO 52119.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.5.txt b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.5.txt new file mode 100644 index 0000000000..363c560442 --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid-candidate-chunk5-1.5.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.5x beyond the prior (candidate only); budget 14505 s; started-at 0 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 7556 19.24 yes | 600 1.53 GO 6382.4 | - - + 1 100 | 9169 23.35 yes | 600 1.53 GO 7995.0 | - - + 1 175 | 11494 29.27 yes | 600 1.53 GO 10320.0 | - - + 1 300 | 15440 36.94 no | 1200 3.06 GO 14263.7 | 12000 30.56 + 1 450 | 20240 36.94 no | 1200 3.06 NO-GO 19063.7 | 1200 3.06 + 1 600 | 25040 36.94 no | 1800 4.58 NO-GO 23863.7 | 1800 4.58 + 1.5 40 | 10541 26.85 yes | 600 1.53 GO 8723.8 | - - + 1.5 100 | 12043 30.67 yes | 600 1.53 GO 10193.4 | - - + 1.5 175 | 14216 36.21 yes | 600 1.53 GO 12366.8 | - - + 1.5 300 | 18091 36.94 no | 1200 3.06 NO-GO 16241.8 | 1200 3.06 + 1.5 450 | 22847 36.94 no | 1200 3.06 NO-GO 21000.4 | 1200 3.06 + 1.5 600 | 27647 36.94 no | 1800 4.58 NO-GO 25800.4 | 1800 4.58 + 2 40 | 13623 34.70 yes | 600 1.53 GO 11193.6 | - - + 2 100 | 14792 36.94 no | 600 1.53 GO 12365.2 | 7800 19.87 + 2 175 | 16941 36.94 no | 1200 3.06 NO-GO 14514.3 | 1200 3.06 + 2 300 | 20816 36.94 no | 1200 3.06 NO-GO 18389.3 | 1200 3.06 + 2 450 | 25468 36.94 no | 1200 3.06 NO-GO 23042.2 | 1200 3.06 + 2 600 | 30258 36.94 no | 1800 4.58 NO-GO 27832.2 | 1800 4.58 + 3 40 | 19731 36.94 no | 600 1.53 NO-GO 16121.5 | 600 1.53 + 3 100 | 21099 36.94 no | 1200 3.06 NO-GO 17488.6 | 1200 3.06 + 3 175 | 22703 36.94 no | 1200 3.06 NO-GO 19091.0 | 1200 3.06 + 3 300 | 26296 36.94 no | 1200 3.06 NO-GO 22684.3 | 1200 3.06 + 3 450 | 30946 36.94 no | 1800 4.58 NO-GO 27334.3 | 1800 4.58 + 3 600 | 35596 36.94 no | 1800 4.58 NO-GO 31984.3 | 1800 4.58 + 4 40 | 25859 36.94 no | 1200 3.06 NO-GO 20998.8 | 1200 3.06 + 4 100 | 27026 36.94 no | 1200 3.06 NO-GO 22148.1 | 1200 3.06 + 4 175 | 28563 36.94 no | 1200 3.06 NO-GO 23687.7 | 1200 3.06 + 4 300 | 32192 36.94 no | 1800 4.58 NO-GO 27316.9 | 1800 4.58 + 4 450 | 36403 36.94 no | 1800 4.58 NO-GO 31528.5 | 1800 4.58 + 4 600 | 41053 36.94 no | 1800 4.58 NO-GO 36178.5 | 1800 4.58 + 5 40 | 31977 36.94 no | 1200 3.06 NO-GO 25935.3 | 1200 3.06 + 5 100 | 33181 36.94 no | 1200 3.06 NO-GO 27139.8 | 1200 3.06 + 5 175 | 35003 36.94 no | 1800 4.58 NO-GO 28961.1 | 1800 4.58 + 5 300 | 37685 36.94 no | 1800 4.58 NO-GO 31646.9 | 1800 4.58 + 5 450 | 41862 36.94 no | 1800 4.58 NO-GO 35823.5 | 1800 4.58 + 5 600 | 46512 36.94 no | 2400 6.11 NO-GO 40473.5 | 2400 6.11 + 7.6 40 | 47935 36.94 no | 1800 4.58 NO-GO 38759.7 | 1800 4.58 + 7.6 100 | 49003 36.94 no | 1800 4.58 NO-GO 39816.1 | 1800 4.58 + 7.6 175 | 50463 36.94 no | 1800 4.58 NO-GO 41278.7 | 1800 4.58 + 7.6 300 | 53301 36.94 no | 2400 6.11 NO-GO 44117.6 | 2400 6.11 + 7.6 450 | 56765 36.94 no | 2400 6.11 NO-GO 47582.6 | 2400 6.11 + 7.6 600 | 61302 36.94 no | 3000 7.64 NO-GO 52119.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/projection-grid-chunk5-1.5.txt b/docs/evidence/us-h2h-speed/projection-grid-chunk5-1.5.txt new file mode 100644 index 0000000000..2ec9f2280a --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid-chunk5-1.5.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.5x beyond the prior (both artifacts); budget 14505 s; started-at 0 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 7786 19.83 yes | 600 1.53 GO 6382.4 | - - + 1 100 | 9399 23.94 yes | 600 1.53 GO 7995.0 | - - + 1 175 | 11724 29.86 yes | 600 1.53 GO 10320.0 | - - + 1 300 | 15599 36.94 no | 1200 3.06 GO 14263.7 | 5400 13.75 + 1 450 | 20355 36.94 no | 1200 3.06 NO-GO 19063.7 | 1200 3.06 + 1 600 | 25155 36.94 no | 1800 4.58 NO-GO 23863.7 | 1800 4.58 + 1.5 40 | 10883 27.72 yes | 600 1.53 GO 8723.8 | - - + 1.5 100 | 12385 31.54 yes | 600 1.53 GO 10193.4 | - - + 1.5 175 | 14558 36.94 no | 600 1.53 GO 12366.8 | 3600 9.17 + 1.5 300 | 18433 36.94 no | 1200 3.06 NO-GO 16241.8 | 1200 3.06 + 1.5 450 | 23083 36.94 no | 1200 3.06 NO-GO 21000.4 | 1200 3.06 + 1.5 600 | 27818 36.94 no | 1800 4.58 NO-GO 25800.4 | 1800 4.58 + 2 40 | 14081 35.86 yes | 600 1.53 GO 11193.6 | - - + 2 100 | 15250 36.94 no | 600 1.53 GO 12365.2 | 2400 6.11 + 2 175 | 17399 36.94 no | 1200 3.06 NO-GO 14514.3 | 1200 3.06 + 2 300 | 21274 36.94 no | 1200 3.06 NO-GO 18389.3 | 1200 3.06 + 2 450 | 25924 36.94 no | 1200 3.06 NO-GO 23042.2 | 1200 3.06 + 2 600 | 30574 36.94 no | 1800 4.58 NO-GO 27832.2 | 1800 4.58 + 3 40 | 20419 36.94 no | 600 1.53 NO-GO 16121.5 | 600 1.53 + 3 100 | 21787 36.94 no | 1200 3.06 NO-GO 17488.6 | 1200 3.06 + 3 175 | 23391 36.94 no | 1200 3.06 NO-GO 19091.0 | 1200 3.06 + 3 300 | 26984 36.94 no | 1200 3.06 NO-GO 22684.3 | 1200 3.06 + 3 450 | 31634 36.94 no | 1800 4.58 NO-GO 27334.3 | 1800 4.58 + 3 600 | 36284 36.94 no | 1800 4.58 NO-GO 31984.3 | 1800 4.58 + 4 40 | 26775 36.94 no | 1200 3.06 NO-GO 20998.8 | 1200 3.06 + 4 100 | 27942 36.94 no | 1200 3.06 NO-GO 22148.1 | 1200 3.06 + 4 175 | 29479 36.94 no | 1200 3.06 NO-GO 23687.7 | 1200 3.06 + 4 300 | 33108 36.94 no | 1800 4.58 NO-GO 27316.9 | 1800 4.58 + 4 450 | 37319 36.94 no | 1800 4.58 NO-GO 31528.5 | 1800 4.58 + 4 600 | 41969 36.94 no | 1800 4.58 NO-GO 36178.5 | 1800 4.58 + 5 40 | 33123 36.94 no | 1200 3.06 NO-GO 25935.3 | 1200 3.06 + 5 100 | 34327 36.94 no | 1200 3.06 NO-GO 27139.8 | 1200 3.06 + 5 175 | 36149 36.94 no | 1800 4.58 NO-GO 28961.1 | 1800 4.58 + 5 300 | 38831 36.94 no | 1800 4.58 NO-GO 31646.9 | 1800 4.58 + 5 450 | 43008 36.94 no | 1800 4.58 NO-GO 35823.5 | 1800 4.58 + 5 600 | 47658 36.94 no | 2400 6.11 NO-GO 40473.5 | 2400 6.11 + 7.6 40 | 49677 36.94 no | 1800 4.58 NO-GO 38759.7 | 1800 4.58 + 7.6 100 | 50745 36.94 no | 1800 4.58 NO-GO 39816.1 | 1800 4.58 + 7.6 175 | 52205 36.94 no | 1800 4.58 NO-GO 41278.7 | 1800 4.58 + 7.6 300 | 55043 36.94 no | 2400 6.11 NO-GO 44117.6 | 2400 6.11 + 7.6 450 | 58507 36.94 no | 2400 6.11 NO-GO 47582.6 | 2400 6.11 + 7.6 600 | 63044 36.94 no | 3000 7.64 NO-GO 52119.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/projection-grid-pre-tool-300.txt b/docs/evidence/us-h2h-speed/projection-grid-pre-tool-300.txt new file mode 100644 index 0000000000..c85b2c9848 --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid-pre-tool-300.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.0x beyond the prior (both artifacts); budget 14505 s; started-at 300 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 6356 16.19 yes | 600 1.53 GO 6682.4 | - - + 1 100 | 7969 20.30 yes | 600 1.53 GO 8295.0 | - - + 1 175 | 10294 26.22 yes | 600 1.53 GO 10620.0 | - - + 1 300 | 14240 36.27 yes | 1200 3.06 NO-GO 14563.7 | 1200 3.06 FALSE + 1 450 | 19040 36.94 no | 1200 3.06 NO-GO 19363.7 | 1200 3.06 + 1 600 | 23840 36.94 no | 1800 4.58 NO-GO 24163.7 | 1800 4.58 + 1.5 40 | 8753 22.29 yes | 600 1.53 GO 9023.8 | - - + 1.5 100 | 10255 26.12 yes | 600 1.53 GO 10493.4 | - - + 1.5 175 | 12428 31.65 yes | 600 1.53 GO 12666.8 | - - + 1.5 300 | 16303 36.94 no | 1200 3.06 NO-GO 16541.8 | 1200 3.06 + 1.5 450 | 21059 36.94 no | 1200 3.06 NO-GO 21300.4 | 1200 3.06 + 1.5 600 | 25859 36.94 no | 1800 4.58 NO-GO 26100.4 | 1800 4.58 + 2 40 | 11223 28.58 yes | 600 1.53 GO 11493.6 | - - + 2 100 | 12392 31.56 yes | 600 1.53 GO 12665.2 | - - + 2 175 | 14541 36.94 no | 1200 3.06 NO-GO 14814.3 | 1200 3.06 + 2 300 | 18416 36.94 no | 1200 3.06 NO-GO 18689.3 | 1200 3.06 + 2 450 | 23068 36.94 no | 1200 3.06 NO-GO 23342.2 | 1200 3.06 + 2 600 | 27858 36.94 no | 1800 4.58 NO-GO 28132.2 | 1800 4.58 + 3 40 | 16131 36.94 no | 600 1.53 NO-GO 16421.5 | 600 1.53 + 3 100 | 17499 36.94 no | 1200 3.06 NO-GO 17788.6 | 1200 3.06 + 3 175 | 19103 36.94 no | 1200 3.06 NO-GO 19391.0 | 1200 3.06 + 3 300 | 22696 36.94 no | 1200 3.06 NO-GO 22984.3 | 1200 3.06 + 3 450 | 27346 36.94 no | 1800 4.58 NO-GO 27634.3 | 1800 4.58 + 3 600 | 31996 36.94 no | 1800 4.58 NO-GO 32284.3 | 1800 4.58 + 4 40 | 21071 36.94 no | 1200 3.06 NO-GO 21298.8 | 1200 3.06 + 4 100 | 22238 36.94 no | 1200 3.06 NO-GO 22448.1 | 1200 3.06 + 4 175 | 23775 36.94 no | 1200 3.06 NO-GO 23987.7 | 1200 3.06 + 4 300 | 27404 36.94 no | 1800 4.58 NO-GO 27616.9 | 1800 4.58 + 4 450 | 31615 36.94 no | 1800 4.58 NO-GO 31828.5 | 1800 4.58 + 4 600 | 36265 36.94 no | 1800 4.58 NO-GO 36478.5 | 1800 4.58 + 5 40 | 25977 36.94 no | 1200 3.06 NO-GO 26235.3 | 1200 3.06 + 5 100 | 27181 36.94 no | 1200 3.06 NO-GO 27439.8 | 1200 3.06 + 5 175 | 29003 36.94 no | 1800 4.58 NO-GO 29261.1 | 1800 4.58 + 5 300 | 31685 36.94 no | 1800 4.58 NO-GO 31946.9 | 1800 4.58 + 5 450 | 35862 36.94 no | 1800 4.58 NO-GO 36123.5 | 1800 4.58 + 5 600 | 40512 36.94 no | 2400 6.11 NO-GO 40773.5 | 2400 6.11 + 7.6 40 | 38839 36.94 no | 1800 4.58 NO-GO 39059.7 | 1800 4.58 + 7.6 100 | 39907 36.94 no | 1800 4.58 NO-GO 40116.1 | 1800 4.58 + 7.6 175 | 41367 36.94 no | 1800 4.58 NO-GO 41578.7 | 1800 4.58 + 7.6 300 | 44205 36.94 no | 2400 6.11 NO-GO 44417.6 | 2400 6.11 + 7.6 450 | 47669 36.94 no | 2400 6.11 NO-GO 47882.6 | 2400 6.11 + 7.6 600 | 52206 36.94 no | 3000 7.64 NO-GO 52419.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/projection-grid.txt b/docs/evidence/us-h2h-speed/projection-grid.txt new file mode 100644 index 0000000000..12801271b7 --- /dev/null +++ b/docs/evidence/us-h2h-speed/projection-grid.txt @@ -0,0 +1,44 @@ +chunk 5 slowed 1.0x beyond the prior (both artifacts); budget 14505 s; started-at 0 s before the tool + f T | tool s $ fits | first s $ verdict est s | NO-GO s $ + 1 40 | 6356 16.19 yes | 600 1.53 GO 6382.4 | - - + 1 100 | 7969 20.30 yes | 600 1.53 GO 7995.0 | - - + 1 175 | 10294 26.22 yes | 600 1.53 GO 10320.0 | - - + 1 300 | 14240 36.27 yes | 1200 3.06 GO 14263.7 | - - + 1 450 | 19040 36.94 no | 1200 3.06 NO-GO 19063.7 | 1200 3.06 + 1 600 | 23840 36.94 no | 1800 4.58 NO-GO 23863.7 | 1800 4.58 + 1.5 40 | 8753 22.29 yes | 600 1.53 GO 8723.8 | - - + 1.5 100 | 10255 26.12 yes | 600 1.53 GO 10193.4 | - - + 1.5 175 | 12428 31.65 yes | 600 1.53 GO 12366.8 | - - + 1.5 300 | 16303 36.94 no | 1200 3.06 NO-GO 16241.8 | 1200 3.06 + 1.5 450 | 21059 36.94 no | 1200 3.06 NO-GO 21000.4 | 1200 3.06 + 1.5 600 | 25859 36.94 no | 1800 4.58 NO-GO 25800.4 | 1800 4.58 + 2 40 | 11223 28.58 yes | 600 1.53 GO 11193.6 | - - + 2 100 | 12392 31.56 yes | 600 1.53 GO 12365.2 | - - + 2 175 | 14541 36.94 no | 1200 3.06 NO-GO 14514.3 | 1200 3.06 + 2 300 | 18416 36.94 no | 1200 3.06 NO-GO 18389.3 | 1200 3.06 + 2 450 | 23068 36.94 no | 1200 3.06 NO-GO 23042.2 | 1200 3.06 + 2 600 | 27858 36.94 no | 1800 4.58 NO-GO 27832.2 | 1800 4.58 + 3 40 | 16131 36.94 no | 600 1.53 NO-GO 16121.5 | 600 1.53 + 3 100 | 17499 36.94 no | 1200 3.06 NO-GO 17488.6 | 1200 3.06 + 3 175 | 19103 36.94 no | 1200 3.06 NO-GO 19091.0 | 1200 3.06 + 3 300 | 22696 36.94 no | 1200 3.06 NO-GO 22684.3 | 1200 3.06 + 3 450 | 27346 36.94 no | 1800 4.58 NO-GO 27334.3 | 1800 4.58 + 3 600 | 31996 36.94 no | 1800 4.58 NO-GO 31984.3 | 1800 4.58 + 4 40 | 21071 36.94 no | 1200 3.06 NO-GO 20998.8 | 1200 3.06 + 4 100 | 22238 36.94 no | 1200 3.06 NO-GO 22148.1 | 1200 3.06 + 4 175 | 23775 36.94 no | 1200 3.06 NO-GO 23687.7 | 1200 3.06 + 4 300 | 27404 36.94 no | 1800 4.58 NO-GO 27316.9 | 1800 4.58 + 4 450 | 31615 36.94 no | 1800 4.58 NO-GO 31528.5 | 1800 4.58 + 4 600 | 36265 36.94 no | 1800 4.58 NO-GO 36178.5 | 1800 4.58 + 5 40 | 25977 36.94 no | 1200 3.06 NO-GO 25935.3 | 1200 3.06 + 5 100 | 27181 36.94 no | 1200 3.06 NO-GO 27139.8 | 1200 3.06 + 5 175 | 29003 36.94 no | 1800 4.58 NO-GO 28961.1 | 1800 4.58 + 5 300 | 31685 36.94 no | 1800 4.58 NO-GO 31646.9 | 1800 4.58 + 5 450 | 35862 36.94 no | 1800 4.58 NO-GO 35823.5 | 1800 4.58 + 5 600 | 40512 36.94 no | 2400 6.11 NO-GO 40473.5 | 2400 6.11 + 7.6 40 | 38839 36.94 no | 1800 4.58 NO-GO 38759.7 | 1800 4.58 + 7.6 100 | 39907 36.94 no | 1800 4.58 NO-GO 39816.1 | 1800 4.58 + 7.6 175 | 41367 36.94 no | 1800 4.58 NO-GO 41278.7 | 1800 4.58 + 7.6 300 | 44205 36.94 no | 2400 6.11 NO-GO 44117.6 | 2400 6.11 + 7.6 450 | 47669 36.94 no | 2400 6.11 NO-GO 47582.6 | 2400 6.11 + 7.6 600 | 52206 36.94 no | 3000 7.64 NO-GO 52119.3 | 3000 7.64 diff --git a/docs/evidence/us-h2h-speed/scripts/launch-local.sh b/docs/evidence/us-h2h-speed/scripts/launch-local.sh new file mode 100755 index 0000000000..097a15d365 --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/launch-local.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Run time_slices.py against a checkout at the scorer pin. Set ROOT (the +# checkout, which the scorer's `git rev-parse HEAD` needs as the working +# directory), PYTHON (a venv with the pin's locked dependencies), INCUMBENT, +# CANDIDATE, LEDGER and OUT. +set -euo pipefail +export PYTHONDONTWRITEBYTECODE=1 OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1 +HERE=$(cd "$(dirname "$0")" && pwd) +cd "$ROOT" +exec "$PYTHON" -I -B "$HERE/time_slices.py" "$ROOT" "$INCUMBENT" "$CANDIDATE" "$LEDGER" "$OUT" diff --git a/docs/evidence/us-h2h-speed/scripts/lost_lines.py b/docs/evidence/us-h2h-speed/scripts/lost_lines.py new file mode 100644 index 0000000000..d96bc55270 --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/lost_lines.py @@ -0,0 +1,490 @@ +"""Lost log lines and the watcher's verdict, in simulated runs. + +Not a measurement. A log stream that ends is restarted by the watcher as a +new file; if the new stream does not replay what the app printed, the lines +in between are lost, and whether ``modal app logs`` replays, and from where, +is untried. This script damages simulated logs (test_support's pool +simulator, the model the estimate assumes) the ways a restart can, reads the +pieces as the watcher's streams, and compares the verdict of +tools/us_head_to_head_projection.py with the intact log's at the same poll. + +The estimate does not depend on the budget (the time margin is 0), so each +poll is judged once, with no budget, and the verdict at any budget follows: +NO-GO when the log stalls, or when the estimated end passes the budget and no +pool's starts are unconfirmed (``starts_unconfirmed``, which holds a time +NO-GO as WAIT); WAIT when there is no estimate or the hold applies; GO +otherwise. Every 50th poll is also judged directly at both budgets below, +and the count of mismatches is printed. A run with S seconds of spare is +stopped falsely where the damaged log gives NO-GO and the intact one does +not, so each search reports the largest **excess** at the polls the hold +leaves free: the damaged estimate less the intact estimate at the same poll. +A run whose intact estimate has more spare than that is never stopped by the +damage searched here. The largest excess at held polls is reported too: it +is what the hold guards against. Each search also gives every verdict +transition (intact -> damaged) at two budgets: a tight fit, the true end +plus 265 s (the spare of the d844 shape at f = 1, T = 300 s), and an +overrun, the true end less 600 s. The true end counts the estimate's 600 s +tail allowance. The intact log's own NO-GO at the tight fit is counted +apart: that is the estimate's error, not the damage's. + +Sections: + +- cut-d844, cut-random: a restart that does not replay loses [s, s + w): + w = 1, 10 and 60 s ending or starting at each worker start, pool opening + and release line, and w = 0 (nothing lost), 10 and 60 s every 120 s (d844) + or 300 s (random), plus pairs of 10 s cuts at two start lines 300 to + 2,400 s apart (two restarts): every pair when there are fewer than 120, + else an even sample of 60 to 90. Polls come every 5 s to 300 s after the + last cut and every 30 s to 1,200 s, so the first ones see the new stream + still empty. +- boundary: a restart inside one second, at every second with records: the + log split there with nothing lost (a continuation), a replay from that + second's first record, and a replay of only the last record seen, each + polled at the next three 600 s polls. +- lossless: the d844 log split with nothing lost every 60 s, polled every + 600 s as the watcher does: every verdict transition, and how much later + than the intact log's the split log's first NO-GO comes (a missed stop). + +Shapes: d844 (16 workers, this folder's slice means times f, worker start +cost T or one cost per start with the last repeating, chunk-weights.json as +the prior), and random pools drawn as the property tests draw them (1 to 16 +workers, 1 to 5 chunks of 20 to 300 s slices) with one to four start costs of +1 to 400 s, the last repeating, and their own slice times as the prior. +``--constant-starts`` keeps each random pool's first start cost for every +start and draws the same pools otherwise, which separates what varying start +costs do to the estimate from what the damage does. + +usage: python -I scripts/lost_lines.py CHECKOUT --section SECTION + [--pools N] [--seeds 3,7,11] [--rows ROWS.jsonl] [--constant-starts] +""" + +from __future__ import annotations + +import argparse +import importlib.util +import json +import random +import sys +import time +from collections import Counter +from pathlib import Path + +parser = argparse.ArgumentParser() +parser.add_argument("checkout", type=Path) +parser.add_argument( + "--section", + choices=("cut-d844", "cut-random", "boundary", "lossless"), + required=True, +) +parser.add_argument("--pools", type=int, default=100) +parser.add_argument("--seeds", default="3,7,11") +parser.add_argument("--rows", type=Path, help="JSON lines for polls with excess > 0") +parser.add_argument( + "--constant-starts", + action="store_true", + help="random pools keep only their first start cost (the same pools otherwise)", +) +args = parser.parse_args() +sys.path.insert(0, str(args.checkout)) +from test_support.microcosm_build import h2h_pool_sim as sim # noqa: E402 + +spec = importlib.util.spec_from_file_location( + "us_head_to_head_projection", args.checkout / "tools/us_head_to_head_projection.py" +) +projection = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = projection +spec.loader.exec_module(projection) + +START = 1_794_816_000 +BIG = 10**9 +SPARE = 265 +SHORT = 600 +RATE = 0.00254688 # USD per second, the class's non-preemptible list price +weights_path = args.checkout / "docs/evidence/us-h2h-speed/chunk-weights.json" +weights = json.loads(weights_path.read_text()) +D844_PRIOR = projection._prior(weights_path) +rows = args.rows.open("w") if args.rows else None +direct = Counter() + + +def offset(line: str) -> float | None: + times = projection.parse_log([line]).record_times + return times[0] if times else None + + +def d844_run(f: float, start_cost) -> sim.Run: + return sim.run( + started_at=START, + workers=16, + incumbent_seconds=[ + round(x * f) for x in weights["incumbent_mean_slice_seconds"] + ], + candidate_seconds=[ + round(x * f) for x in weights["candidate_mean_slice_seconds"] + ], + incumbent_slices=29, + candidate_slices=177, + start_cost=start_cost, + first_slice_extra=round(5 * f), + load_seconds=round(64 * f), + candidate_load_seconds=round(11 * f), + scorecard_seconds=600, + ) + + +def random_pools(seed: int, count: int): + rng = random.Random(seed) + for k in range(count): + workers = rng.randint(1, 16) + chunks = rng.randint(1, 5) + params = dict( + workers=workers, + incumbent_seconds=[rng.randint(20, 300) for _ in range(chunks)], + candidate_seconds=[rng.randint(20, 300) for _ in range(chunks)], + incumbent_slices=rng.randint(1, 3 * workers), + candidate_slices=rng.randint(1, 10 * workers), + start_cost=[rng.randint(1, 400) for _ in range(rng.randint(1, 4))], + first_slice_extra=rng.randint(0, 200), + ) + if args.constant_starts: + params["start_cost"] = params["start_cost"][0] + yield f"seed {seed} pool {k}", params, sim.run(started_at=START, **params) + + +def own_prior(run: sim.Run): + return projection.Prior( + candidate=tuple(map(float, run.candidate_seconds)), + incumbent=tuple(map(float, run.incumbent_seconds)), + candidate_slices=run.candidate_slices, + ) + + +class Shape: + def __init__(self, name, run, workers, prior, scorecard) -> None: + self.name, self.run, self.workers, self.prior = name, run, workers, prior + # The estimate's end is the last slice plus a 600 s tail allowance. + self.truth = run.tool_end - START + 600 - scorecard + self.full = run.log() + self.offsets = [offset(line) for line in self.full] + + def limits(self, budget: float = BIG): + return projection.Limits( + workers=self.workers, + started_at=START, + max_wall_seconds=budget, + prior=self.prior, + ) + + def upto(self, at: float) -> list[str]: + return [ + line for line, t in zip(self.full, self.offsets) if t is None or t <= at + ] + + +def d844_shape(f, start_cost) -> Shape: + label = start_cost if isinstance(start_cost, int) else f"{start_cost[:3]}..." + return Shape(f"d844 f={f} T={label}", d844_run(f, start_cost), 16, D844_PRIOR, 600) + + +def end_of(report: dict) -> float | None: + estimate = report.get("estimate") + return estimate["estimated_tool_seconds_from_start"] if estimate else None + + +def verdict_at(report: dict, budget: float) -> str: + """The verdict ``report``, judged with no budget, gives at ``budget``.""" + + if report["verdict"] == "NO-GO": + return "NO-GO" # a stall, at any budget + end = end_of(report) + if end is None: + return "WAIT" + if end > budget: + return "WAIT" if report.get("starts_unconfirmed") else "NO-GO" + if report["verdict"] == "WAIT": + return "WAIT" + return "GO" + + +class Tally: + def __init__(self, truth: float = 0.0) -> None: + self.budgets = {"fit": truth + SPARE, "short": truth - SHORT} + self.pairs = {label: Counter() for label in self.budgets} + self.polls = self.estimates = self.held = self.stalls = 0 + self.excess = self.held_excess = float("-inf") + + def add(self, intact, damaged, ctx, judge=None) -> None: + self.polls += 1 + for label, budget in self.budgets.items(): + pair = (verdict_at(intact, budget), verdict_at(damaged, budget)) + self.pairs[label][pair] += 1 + if judge is not None and self.polls % 50 == 0: + direct["checked"] += 1 + if judge(budget) != pair[1]: + direct["mismatched"] += 1 + print(f" MISMATCH {ctx} budget {budget}", flush=True) + if damaged["verdict"] == "NO-GO" and intact["verdict"] != "NO-GO": + self.stalls += 1 + ends = end_of(intact), end_of(damaged) + if None not in ends: + self.estimates += 1 + excess = ends[1] - ends[0] + if damaged.get("starts_unconfirmed"): + self.held += 1 + self.held_excess = max(self.held_excess, excess) + else: + self.excess = max(self.excess, excess) + if excess > 0 and rows: + rows.write(json.dumps({**ctx, "excess": round(excess, 1)}) + "\n") + + def merge(self, other: Tally) -> None: + for label in self.pairs: + self.pairs[label].update(other.pairs[label]) + self.polls += other.polls + self.estimates += other.estimates + self.held += other.held + self.stalls += other.stalls + self.excess = max(self.excess, other.excess) + self.held_excess = max(self.held_excess, other.held_excess) + + def line(self) -> str: + def table(counter: Counter) -> str: + return ", ".join(f"{i}->{d} {n}" for (i, d), n in sorted(counter.items())) + + def seconds(value: float) -> str: + return "-" if value == float("-inf") else f"{value:.1f} s" + + fit = self.pairs["fit"] + false = fit[("GO", "NO-GO")] + fit[("WAIT", "NO-GO")] + own = sum(n for (i, _), n in fit.items() if i == "NO-GO") + return ( + f"{self.polls} polls, {self.estimates} with both estimates, max excess " + f"{seconds(self.excess)} where the hold is off ({self.held} held, max " + f"excess there {seconds(self.held_excess)}); at the true end +{SPARE} " + f"s: {table(fit)} (false NO-GO {false}; the intact log's own NO-GO " + f"{own}); at the true end -{SHORT} s: {table(self.pairs['short'])}; " + f"NO-GO from a stall the intact log does not show {self.stalls}" + ) + + +POLLS = list(range(5, 301, 5)) + list(range(330, 1201, 30)) + + +def streams_for(shape: Shape, cuts, at) -> list[list[str]]: + """The streams restarts at each cut ``(s, w)`` leave, losing [s, s + w).""" + + pairs = list(zip(shape.full, shape.offsets)) + out = [[line for line, t in pairs if t is None or t < cuts[0][0]]] + for (a, wa), (b, _) in zip(cuts, cuts[1:]): + out.append([line for line, t in pairs if t is not None and a + wa <= t < b]) + s, w = cuts[-1] + out.append([line for line, t in pairs if t is not None and s + w <= t <= at]) + return out + + +def cut_search(shape: Shape, grid: int) -> Tally: + offsets = shape.offsets + seen = sorted({t for t in offsets if t is not None}) + marks = [ + t + for line, t in zip(shape.full, offsets) + if t is not None + and any(k in line for k in ("initializing", "before starting", "releasing")) + ] + cuts: set = set() + for t in marks: + for w in (1, 10, 60): + cuts.update({((t, w),), ((t - w + 1, w),)}) + for t in range(int(seen[0]), int(seen[-1]), grid): + for w in (0, 10, 60): + cuts.add(((t, w),)) + doubles = [ + ((a, 10), (b, 10)) + for i, a in enumerate(marks) + for b in marks[i + 1 :] + if 300 <= b - a <= 2400 + ] + cases = sorted(cuts) + doubles[:: max(1, len(doubles) // 60)] + limits = shape.limits() + tally = Tally(shape.truth) + intact_at: dict = {} + for case in cases: + if any( + w and not any(t is not None and s <= t < s + w for t in offsets) + for s, w in case + ): + continue # loses nothing, yet is not a w = 0 split + last = case[-1][0] + case[-1][1] + for d in POLLS: + at = last + d + if at >= shape.run.candidate.end: + break + if at not in intact_at: + intact_at[at] = projection.project( + projection.parse_log(shape.upto(at)), limits, at + ) + streams = streams_for(shape, case, at) + damaged = projection.project(projection.parse_logs(streams), limits, at) + + def judge(budget, streams=streams, at=at): + parsed = projection.parse_logs(streams) + return projection.project(parsed, shape.limits(budget), at)["verdict"] + + ctx = { + "shape": shape.name, + "cuts": [(s - START, w) for s, w in case], + "poll": at - START, + } + tally.add(intact_at[at], damaged, ctx, judge) + return tally + + +def boundary_search(shape: Shape) -> dict[str, Tally]: + offsets = shape.offsets + limits = shape.limits() + arms = { + arm: Tally(shape.truth) for arm in ("split", "replay-second", "replay-last") + } + end = shape.run.candidate.end - START + for s in sorted({t for t in offsets if t is not None}): + idx = [i for i, t in enumerate(offsets) if t == s] + i0, i1 = idx[0], idx[-1] + 1 + polls = [p for p in range(600, int(end) + 1, 600) if START + p >= s][:3] + for p in polls: + at = START + p + log = shape.upto(at) + intact = projection.project(projection.parse_log(log), limits, at) + cases = { + "replay-second": [log[:i1], log[i0:]], + "replay-last": [log[:i1], log[i1 - 1 :]], + } + if i1 - i0 >= 2: + k = i0 + (i1 - i0) // 2 + cases["split"] = [log[:k], log[k:]] + for arm, streams in cases.items(): + damaged = projection.project(projection.parse_logs(streams), limits, at) + ctx = {"shape": shape.name, "arm": arm, "second": s - START, "poll": p} + arms[arm].add(intact, damaged, ctx) + return arms + + +def lossless_line(f, start_cost) -> str: + shape = d844_shape(f, start_cost) + limits = shape.limits(14_505) + stop = min(shape.run.tool_end - START, 14_505) + polls = range(600, int(stop) + 1, 600) + + def judge(at, streams): + return projection.project(projection.parse_logs(streams), limits, at)["verdict"] + + intact = {p: judge(START + p, [shape.upto(START + p)]) for p in polls} + first_no_go = next((p for p in polls if intact[p] == "NO-GO"), None) + transitions: Counter = Counter() + delay = 0.0 + splits = 0 + pairs = list(zip(shape.full, shape.offsets)) + for split in range(60, int(first_no_go or stop), 60): + splits += 1 + first = [line for line, t in pairs if t is None or t < START + split] + for poll in polls: + if poll < split: + continue + at = START + poll + second = [ + line for line, t in pairs if t is not None and START + split <= t <= at + ] + verdict = judge(at, [first, second]) + transitions[intact[poll], verdict] += 1 + if first_no_go is not None and verdict == "NO-GO": + delay = max(delay, poll - first_no_go) + break + else: + if first_no_go is not None: + delay = max(delay, stop - first_no_go) + fits = shape.run.tool_end - START <= 14_505 + line = ( + f" {shape.name} ({'fits' if fits else 'overruns'}, intact NO-GO at " + f"{first_no_go or '-'} s): {splits} splits; " + + ", ".join(f"{i}->{d} {n}" for (i, d), n in sorted(transitions.items())) + ) + if first_no_go is not None: + line += f"; first NO-GO up to {delay:.0f} s later (${delay * RATE:.2f})" + return line + + +D844_SHAPES = [ + (1, 300), + (1.01, 300), + (1.02, 300), + (1, 150), + (2, 150), + (1.5, 300), + (3, 100), + (1, 40), + (1, 600), + (1, [100] + [320] * 15), + (1, [320] + [200] * 15), + (1, [200, 400] * 8), +] + +began = time.monotonic() +if args.section == "cut-d844": + print("cut: a restart that does not replay loses a stretch (d844)", flush=True) + for f, start_cost in D844_SHAPES: + shape = d844_shape(f, start_cost) + tally = cut_search(shape, 120) + print( + f" {shape.name} (true end {shape.truth:.0f} s): {tally.line()} " + f"[{time.monotonic() - began:.0f} s]", + flush=True, + ) +elif args.section == "cut-random": + print("cut: a restart that does not replay loses a stretch (random)", flush=True) + for seed in (int(s) for s in args.seeds.split(",")): + total = Tally() + worst = float("-inf") + for name, params, run in random_pools(seed, args.pools): + shape = Shape( + name, run, params["workers"], own_prior(run), sim.SCORECARD_SECONDS + ) + tally = cut_search(shape, 300) + total.merge(tally) + if tally.excess > worst: + worst = tally.excess + print( + f" {name} {params}: max excess {tally.excess:.1f} s", flush=True + ) + print( + f" seed {seed}, {args.pools} pools: {total.line()} " + f"[{time.monotonic() - began:.0f} s]", + flush=True, + ) +elif args.section == "boundary": + print("boundary: a restart inside one second", flush=True) + shapes = [d844_shape(1, 300), d844_shape(1, [100] + [320] * 15)] + shapes += [ + Shape(name, run, params["workers"], own_prior(run), sim.SCORECARD_SECONDS) + for name, params, run in random_pools(3, 30) + ] + totals = {arm: Tally() for arm in ("split", "replay-second", "replay-last")} + for shape in shapes: + for arm, tally in boundary_search(shape).items(): + totals[arm].merge(tally) + if shape.name.startswith("d844"): + print(f" {shape.name}, {arm}: {tally.line()}", flush=True) + for arm, total in totals.items(): + print(f" all {len(shapes)} shapes, {arm}: {total.line()}", flush=True) +else: + print( + "lossless: a split every 60 s that loses nothing, polled every 600 s", + flush=True, + ) + for f in (1, 1.5, 2, 3): + for start_cost in (40, 100, 175, 300, 450, 600, [100] + [320] * 15): + print(lossless_line(f, start_cost), flush=True) +print( + f"direct judgements: {direct['checked']} checked, " + f"{direct['mismatched']} differ from the derived verdict; " + f"{time.monotonic() - began:.0f} s", + flush=True, +) diff --git a/docs/evidence/us-h2h-speed/scripts/mutation_check.py b/docs/evidence/us-h2h-speed/scripts/mutation_check.py new file mode 100644 index 0000000000..a21beeb66c --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/mutation_check.py @@ -0,0 +1,341 @@ +"""Seed faults in the d844 early-stop estimate and check its tests catch each. + +Each fault is one edit to ``tools/us_head_to_head_projection.py``. The script +applies it in place, runs the estimate's test file, and restores the module +whatever happens; it refuses to start if the module differs from the +checkout's HEAD, so a run that is killed can be undone with ``git checkout``. +Every run gets a fresh Hypothesis example database, so an example saved +under one fault cannot replay under the next and fake a catch. A fault that +no test catches is reported as SURVIVED and the script exits nonzero. + +Run from the repository root: + uv run python docs/evidence/us-h2h-speed/scripts/mutation_check.py + +``--runner`` replaces ``python -m pytest`` with another command that takes +pytest's arguments (a wrapper that sets up an engine-free environment, say). +``--only TEXT`` (repeatable) seeds only the faults whose name contains TEXT. +""" + +from __future__ import annotations + +import argparse +import os +import shlex +import subprocess +import sys +import tempfile +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +MODULE = ROOT / "tools" / "us_head_to_head_projection.py" +TESTS = ( + ROOT + / "packages" + / "microcosm-build" + / "tests" + / "engine_free" + / "us" + / "test_us_head_to_head_projection.py" +) +MUTATIONS = { + "the opening burst is workers, not twice that": ( + " opening = min(2 * workers, total)\n", + " opening = min(workers, total)\n", + ), + "receive lines are ignored": ( + " receipt = receives[task - 1] if len(receives) >= task else None\n", + " receipt = None\n", + ), + "a token-taking submit is dated by its result, not its receive line": ( + " taken += 1\n submitted[2 * workers + task] = received\n", + " taken += 1\n submitted[2 * workers + task] = ready\n", + ), + "a full-pool submit is dated by its result, not its receive line": ( + " # The pool is full, so this submit starts no worker either.\n" + " submitted[2 * workers + task] = received\n", + " submitted[2 * workers + task] = ready\n", + ), + "the replay starts every remaining worker at once": ( + " elif spawns < workers:\n" + " advance(clock + start_cost)\n" + " add_worker()\n", + " elif spawns < workers:\n" + " while spawns < workers:\n" + " add_worker()\n", + ), + "replayed worker starts cost nothing": ( + " advance(clock + start_cost)\n", + " advance(clock)\n", + ), + "replayed submits never take a token": ( + " if tokens:\n tokens -= 1\n", + " if False:\n tokens -= 1\n", + ), + "a worker's first slice costs nothing extra": ( + " took = seconds[chunk_of(task)] + (0.0 if who in has_run else first_extra)\n", + " took = seconds[chunk_of(task)]\n", + ), + "workers' first slices count toward the chunk's pace": ( + " if task in firsts:\n first.append", + " if False:\n first.append", + ), + "unmeasured chunks scale from the fastest result": ( + " seconds[chunk] = max(\n", + " seconds[chunk] = min(\n", + ), + "no allowance for the comparison and scorecards": ( + ' "end": last + limits.post_scoring_seconds,\n', + ' "end": last,\n', + ), + "NO-GO comes 600 s late": ( + " elif end > time_line:\n", + " elif end > time_line + 600:\n", + ), + "an unexplained start is never put back on its submit": ( + " while (\n" + " spawns < min(workers, len(inits)) and inits[spawns] <= ready and taken\n" + " ):\n", + " while False:\n", + ), + "candidate starts count only after its first slice": ( + " return Timing({}, {}, [], _start_cost(history), list(history.notes))\n", + " return Timing({}, {}, [], None, list(history.notes))\n", + ), + "an overdue running slice ends now": ( + " end = 2 * now - end\n", + " end = now\n", + ), + "the candidate's fill ignores the incumbent's measured chunks": ( + " if carried:\n", + " if False:\n", + ), + "a lost slice line is not a gap": ( + " gaps.append(task)\n", + " pass\n", + ), + "streams that began late can still say GO": ( + ' verdict = "NO-GO" if reasons else "WAIT" if held or budget_unseen else "GO"\n', + ' verdict = "NO-GO" if reasons else "WAIT" if held else "GO"\n', + ), + "a start logged in its submit's second is taken as an earlier submit's": ( + "inits[spawns] <= ready and taken\n", + "inits[spawns] < ready and taken\n", + ), + "a pool without its opening line is not a gap": ( + " if pool.opened is None and (pool.inits or pool.receives or pool.by_task):\n", + " if False:\n", + ), + "the carried fill takes the slowest result, not one pooled ratio": ( + 'measured["candidate"], candidate.chunks, fill_prior, pooled=bool(carried)\n', + 'measured["candidate"], candidate.chunks, fill_prior, pooled=False\n', + ), + "records from before started-at count as this attempt's": ( + " early = sum(1 for t in parsed.record_times if t < limits.started_at)\n", + " early = 0\n", + ), + "streams with a hole report none": ( + " holes.append((reach, first))\n", + " pass\n", + ), + "before any record the stall allowance never starts": ( + " last = max(seen, default=limits.started_at)\n", + " last = max(seen, default=now)\n", + ), + "a rebuild that starts slices after they end is not a gap": ( + " unplaced = len(_unplaced(pool, history))\n", + " unplaced = 0\n", + ), + "a submit or start the rebuild cannot explain is not a gap": ( + " *history.unexplained,\n", + "", + ), + "a slice from before a hole with no line yet is no suspect": ( + " if tasks:\n", + " if False:\n", + ), + "a newest stream with nothing in it yet is no hole": ( + " reopened = len(kept) > 1 and not kept[-1] and any(kept[:-1])\n", + " reopened = False\n", + ), + "slices from before a hole with no line yet hold nothing": ( + " waiting.append(\n" + ' "a log stream restarted without replaying (a hole), and "\n' + ' + ", ".join(\n' + ' f"{len(t)} of the {name}\'s slices"', + " [].append(\n" + ' "a log stream restarted without replaying (a hole), and "\n' + ' + ", ".join(\n' + ' f"{len(t)} of the {name}\'s slices"', + ), + "suspects count from the start of the hole, not its end": ( + " hole_end = holes[-1][1] if holes else None\n", + " hole_end = holes[-1][0] if holes else None\n", + ), + "an empty newest stream holds nothing": ( + ' report["newest_stream_empty"] = True\n waiting.append(\n', + ' report["newest_stream_empty"] = True\n [].append(\n', + ), + "the stall check runs while the newest stream is empty": ( + " stall = None if reopened else _stall(seen, candidate, slowest, limits, now)\n", + " stall = _stall(seen, candidate, slowest, limits, now)\n", + ), + "a hole never leaves a pool's starts unconfirmed": ( + " and len(pool.inits) < workers\n", + " and False\n", + ), + "the hold lifts a start before every worker has logged one": ( + " and len(pool.inits) < workers\n", + " and len(pool.inits) < workers - 1\n", + ), + "a hole that ended before a pool opened holds it": ( + " end >= pool.opened and (released[name] is None or start < released[name])\n", + " (released[name] is None or start < released[name])\n", + ), + "a hole that began after a pool released holds it": ( + " end >= pool.opened and (released[name] is None or start < released[name])\n", + " end >= pool.opened\n", + ), + "a released incumbent is never held": ( + ' if "incumbent" in short and reads_incumbent:\n', + " if False:\n", + ), + "a released incumbent's hold lifts at the candidate's first start": ( + ' reads_incumbent = estimate is None or estimate.pop("reads_incumbent")\n', + " reads_incumbent = estimate is None or (\n" + ' estimate.pop("reads_incumbent") and not candidate.inits\n' + " )\n", + ), + "a released incumbent stays held for the rest of the run": ( + ' reads_incumbent = estimate is None or estimate.pop("reads_incumbent")\n', + ' reads_incumbent = estimate is None or estimate.pop("reads_incumbent") or 1\n', + ), + "a pace from the incumbent does not hold it": ( + ' pace_from = "incumbent x prior"\n reads_incumbent = True\n', + ' pace_from = "incumbent x prior"\n', + ), + "a fill carrying the incumbent does not hold it": ( + " reads_incumbent = True\n more.append(\n", + " more.append(\n", + ), + "unconfirmed starts hold no NO-GO": ( + " if end > time_line and unconfirmed:\n", + " if end > time_line and False:\n", + ), + "the hold also holds a stall": ( + " if stall:\n reasons.append(stall)\n", + " if stall and not held:\n reasons.append(stall)\n", + ), + "the start cost is the slowest logged start, not the mean": ( + " return sum(costs) / len(costs) if costs else None\n", + " return max(costs) if costs else None\n", + ), + "a stream beginning in the second the log reached adds that second up": ( + " best[text] = max(best.get(text, 0), count)\n", + " best[text] = (\n" + " best.get(text, 0) + count\n" + " if begins == reach\n" + " else max(best.get(text, 0), count)\n" + " )\n", + ), + "a restart repeating the last second's records is not reported": ( + " parsed.overlaps.append(begins)\n", + " pass\n", + ), + "an opening submit that started no logged worker is explained": ( + " unexplained.append(\n" + ' "an opening submit the model says starts a worker did not"\n', + " [].append(\n" + ' "an opening submit the model says starts a worker did not"\n', + ), + "streams are read in glob order, app-10 before app-2": ( + ' return sorted(paths, key=lambda path: int(path.stem.removeprefix("app-")))\n', + " return list(paths)\n", + ), + "the command line reads the streams in the order given": ( + " for path in _stream_order(args.logs)\n", + " for path in args.logs\n", + ), + "an ATTEMPTS: line stands in for the BUDGET line": ( + " and not parsed.budget_lines\n", + " and not parsed.budget_seconds\n", + ), +} + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument( + "--runner", + default=f"{shlex.quote(sys.executable)} -m pytest", + help="command that runs pytest with the arguments after it", + ) + parser.add_argument( + "--only", + action="append", + default=[], + help="seed only the faults whose name contains this text", + ) + args = parser.parse_args() + chosen = { + name: edit + for name, edit in MUTATIONS.items() + if not args.only or any(text in name for text in args.only) + } + head = subprocess.run( + ["git", "-C", str(ROOT), "show", f"HEAD:{MODULE.relative_to(ROOT)}"], + capture_output=True, + text=True, + check=True, + ).stdout + original = MODULE.read_text() + if original != head: + print(f"{MODULE} differs from HEAD; commit or restore it first") + return 2 + for name, (old, _) in MUTATIONS.items(): + if original.count(old) != 1: + print(f"fault {name!r} no longer matches the module exactly once") + return 2 + survived = [] + try: + for name, (old, new) in chosen.items(): + MODULE.write_text(original.replace(old, new)) + with tempfile.TemporaryDirectory() as store: + env = {**os.environ, "HYPOTHESIS_STORAGE_DIRECTORY": store} + result = subprocess.run( + [ + *shlex.split(args.runner), + "-q", + "-x", + "-p", + "no:randomly", + "-p", + "no:cacheprovider", + str(TESTS), + ], + capture_output=True, + text=True, + env=env, + ) + caught = result.returncode == 1 + failed = [ + line.split("::")[-1].split(" ")[0] + for line in result.stdout.splitlines() + if line.startswith("FAILED") + ] + if caught: + print(f"killed {name}: {', '.join(failed) or 'a test failed'}") + elif result.returncode == 0: + print(f"SURVIVED {name}") + survived.append(name) + else: + print(f"ERROR {name}: pytest exited {result.returncode}") + print(result.stdout[-2000:], result.stderr[-2000:]) + survived.append(name) + finally: + MODULE.write_text(original) + print(f"{len(chosen) - len(survived)} of {len(chosen)} faults caught") + return 1 if survived else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/docs/evidence/us-h2h-speed/scripts/projection_grid.py b/docs/evidence/us-h2h-speed/scripts/projection_grid.py new file mode 100644 index 0000000000..206a05122d --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/projection_grid.py @@ -0,0 +1,153 @@ +"""Simulated d844 runs and the watcher's verdicts on them, from the Mac times. + +Not a measurement. For each speed factor f (Modal seconds per Mac second, +the same for every chunk unless --chunk5 says otherwise; --chunk5-artifact +candidate slows only the candidate's chunk 5) and worker start +cost T, it simulates one 16-worker run with test_support's pool simulator +(on-demand worker starts as CPython makes them, chunk-major tasks, twice the +workers outstanding, in-order consumption) from this folder's per-chunk +slice means, then polls tools/us_head_to_head_projection.py every 600 s, as +the watcher does, against the plan's 14,505 s budget, with this folder's +chunk-weights.json as the prior. Start-up is the Mac's import, compile and +load times times f; the comparison and scorecards are taken as 600 s; each +worker's first slice carries 5 s more, times f. Slices within a chunk take +the same time, so workers run in step. + +Columns: the simulated tool's seconds and cost to its end (the runner stops +it at 14,505 s); the poll and cost of the first verdict other than WAIT, +with its estimate; the first NO-GO's poll and cost; FALSE when a NO-GO came +for a run that fits. + +A run fits when its last slice ends at least 600 s before the budget +ends: the estimate's allowance for the comparison and scorecards. The +runner's budget counts from the tool's own start; the watcher's counts from +started-at, which launch.sh writes before `modal run`, so container start +and staging come out of the watcher's budget only. --pre-tool sets that gap +(0 by default: both budgets start together). + +usage: python -I scripts/projection_grid.py CHECKOUT [--chunk5 FACTOR] + [--chunk5-artifact both|candidate] [--pre-tool SECONDS] +""" + +from __future__ import annotations + +import argparse +import importlib.util +import json +import sys +from pathlib import Path + +parser = argparse.ArgumentParser() +parser.add_argument("checkout", type=Path) +parser.add_argument( + "--chunk5", + type=float, + default=1.0, + help="chunk 5 runs this many times slower on Modal than the prior says", +) +parser.add_argument( + "--chunk5-artifact", + choices=("both", "candidate"), + default="both", + help="which artifacts' chunk 5 --chunk5 slows", +) +parser.add_argument( + "--pre-tool", + type=int, + default=0, + help="seconds from started-at to the tool's own start", +) +args = parser.parse_args() +sys.path.insert(0, str(args.checkout)) +from test_support.microcosm_build import h2h_pool_sim as sim # noqa: E402 + +spec = importlib.util.spec_from_file_location( + "us_head_to_head_projection", args.checkout / "tools/us_head_to_head_projection.py" +) +projection = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = projection +spec.loader.exec_module(projection) + +weights_path = args.checkout / "docs/evidence/us-h2h-speed/chunk-weights.json" +weights = json.loads(weights_path.read_text()) +prior = projection._prior(weights_path) +cand = weights["candidate_mean_slice_seconds"] +inc = weights["incumbent_mean_slice_seconds"] +RATE = 0.00254688 # USD per second, 16 CPU, 288 GiB, non-preemptible +BUDGET = 14505 +STARTUP = 38 + 23 + 3 # import, compile, load the incumbent (Mac seconds) +BETWEEN = 11 # load the candidate (Mac seconds) +POST = 600 +POLL = 600 +START = 1_794_816_000 + + +def scaled(means: list[float], f: float, slow: bool = True) -> list[int]: + out = [round(x * f) for x in means] + out[-1] = round(means[-1] * f * (args.chunk5 if slow else 1.0)) + return out + + +SLOW_INCUMBENT = args.chunk5_artifact == "both" +print( + f"chunk 5 slowed {args.chunk5}x beyond the prior " + f"({'both artifacts' if SLOW_INCUMBENT else 'candidate only'}); " + f"budget {BUDGET} s; started-at {args.pre_tool} s before the tool" +) +print( + f"{'f':>4} {'T':>4} | {'tool s':>7} {'$':>6} {'fits':>4} | " + f"{'first s':>7} {'$':>6} {'verdict':>7} {'est s':>7} | {'NO-GO s':>7} {'$':>6}" +) +for f in (1, 1.5, 2, 3, 4, 5, 7.6): + for start_cost in (40, 100, 175, 300, 450, 600): + run = sim.run( + started_at=START, + workers=16, + incumbent_seconds=scaled(inc, f, SLOW_INCUMBENT), + candidate_seconds=scaled(cand, f), + incumbent_slices=29, + candidate_slices=177, + start_cost=start_cost, + first_slice_extra=round(5 * f), + load_seconds=round(STARTUP * f), + candidate_load_seconds=round(BETWEEN * f), + scorecard_seconds=POST, + ) + end = run.tool_end - START + fits = end <= BUDGET + limits = projection.Limits( + workers=16, + started_at=START - args.pre_tool, + max_wall_seconds=BUDGET, + prior=prior, + ) + first = no_go = None + at = START + POLL + while at <= START + min(end, BUDGET): + report = projection.project(projection.parse_log(run.log(at)), limits, at) + if first is None and report["verdict"] != "WAIT": + first = (at - START, report) + if report["verdict"] == "NO-GO": + no_go = at - START + break + at += POLL + row = ( + f"{f:>4} {start_cost:>4} | {end:>7.0f} {min(end, BUDGET) * RATE:>6.2f} " + f"{'yes' if fits else 'no':>4} | " + ) + if first is None: + row += f"{'-':>7} {'-':>6} {'WAIT':>7} {'-':>7} | " + else: + seconds, report = first + estimate = report.get("estimate", {}).get( + "estimated_tool_seconds_from_start", "-" + ) + row += ( + f"{seconds:>7.0f} {seconds * RATE:>6.2f} {report['verdict']:>7} " + f"{estimate:>7} | " + ) + if no_go is None: + row += f"{'-':>7} {'-':>6}" + else: + row += f"{no_go:>7.0f} {no_go * RATE:>6.2f}" + (" FALSE" if fits else "") + print(row, flush=True) diff --git a/docs/evidence/us-h2h-speed/scripts/replay_pool_log.py b/docs/evidence/us-h2h-speed/scripts/replay_pool_log.py new file mode 100644 index 0000000000..c6559c6ca2 --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/replay_pool_log.py @@ -0,0 +1,72 @@ +"""The estimate's replay on the one real pool log: predicted against actual end. + +A measurement of the model on CPython's pool, not of Modal. The log is the +pinned scorer's incumbent pool with three workers on the Mac +(packages/microcosm-build/tests/fixtures/us_h2h/); the candidate's pool never +opened (see README). Every 600 s from the pool's opening, as the watcher +polls, it rebuilds the pool from the lines up to then, replays it forward +with the paces measured so far (unmeasured chunks scaled by +chunk-weights.json) and prints the predicted last slice against the actual. + +usage: python -I scripts/replay_pool_log.py CHECKOUT +""" + +from __future__ import annotations + +import importlib.util +import sys +from pathlib import Path + +checkout = Path(sys.argv[1]) +spec = importlib.util.spec_from_file_location( + "us_head_to_head_projection", checkout / "tools" / "us_head_to_head_projection.py" +) +projection = importlib.util.module_from_spec(spec) +assert spec.loader is not None +sys.modules[spec.name] = projection +spec.loader.exec_module(projection) + +log = ( + checkout + / "packages/microcosm-build/tests/fixtures/us_h2h/pool-run-3-workers-2cfe3043d.log" +) +events = projection.parse_log(log.read_text().splitlines()).events +prior = projection._prior(checkout / "docs/evidence/us-h2h-speed/chunk-weights.json") +WORKERS = 3 +full = projection._pool(events, "incumbent") +assert full.opened is not None and full.slices_per_chunk and full.chunks +actual = max(full.by_task.values()) +span = actual - full.opened +print( + f"pool opened {projection._utc(full.opened)}; last slice {projection._utc(actual)}" +) +print(f"({span:.0f} s for {full.done} slices on {WORKERS} workers)") +print(" poll s done chunks measured predicted last slice error s error %") +at = full.opened + 600 +while at < actual: + pool = projection._pool([e for e in events if e.at <= at], "incumbent") + history = projection.reconstruct(pool, WORKERS, at) + timing = projection.timing(pool, history, 3) + if not timing.chunk_seconds or history is None: + print(f"{at - full.opened:7.0f} {pool.done:5d} WAIT") + else: + seconds, _ = projection._filled( + timing.chunk_seconds, full.chunks, prior.incumbent + ) + last, _ = projection.replay( + now=at, + workers=WORKERS, + total=full.chunks * full.slices_per_chunk, + per_chunk=full.slices_per_chunk, + seconds=seconds, + start_cost=timing.start_cost or 0.0, + first_extra=timing.first_extra(seconds) or 0.0, + history=history, + finished={t: when for t, when in pool.by_task.items() if when <= at}, + ) + measured = ",".join(str(c) for c in sorted(timing.chunk_seconds)) + print( + f"{at - full.opened:7.0f} {pool.done:5d} {measured:15s} " + f"{projection._utc(last)} {last - actual:+8.0f} {100 * (last - actual) / span:+6.1f}" + ) + at += 600 diff --git a/docs/evidence/us-h2h-speed/scripts/time_slices.py b/docs/evidence/us-h2h-speed/scripts/time_slices.py new file mode 100644 index 0000000000..16d1e94cd2 --- /dev/null +++ b/docs/evidence/us-h2h-speed/scripts/time_slices.py @@ -0,0 +1,169 @@ +"""Time the real scorer's slices for both d844 artifacts, interleaved, untraced. + +Purpose: give review r2 (PROJ-1, N1) a measured per-chunk candidate/incumbent +slice-time ratio, and a candidate-based Mac estimate, without Modal. Loads the +yardstick once and both artifacts once, then for each registry chunk scores +incumbent and candidate slices in alternation (so host-load drift hits both +alike). One process, no tracing. Writes the report after every slice. + +usage: python -I time_slices.py ROOT INCUMBENT_H5 CANDIDATE_H5 LEDGER OUT_JSON +ROOT is a microcosm checkout at the plan's scorer pin (2cfe3043d). +""" + +from __future__ import annotations + +import hashlib +import json +import os +import resource +import sys +import threading +import time +from pathlib import Path + +ROOT, INCUMBENT, CANDIDATE, LEDGER, OUT = map(Path, sys.argv[1:6]) +sys.path[:0] = [ + str(ROOT / "tools"), + *map(str, sorted((ROOT / "packages").glob("*/src"))), +] +os.environ["PYTHONDONTWRITEBYTECODE"] = "1" +for name in ( + "OMP_NUM_THREADS", + "OPENBLAS_NUM_THREADS", + "MKL_NUM_THREADS", + "NUMEXPR_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", +): + os.environ[name] = "1" + +import numpy as np # noqa: E402, F401 - loaded after the thread limits above +import psutil # noqa: E402 + +BATCH = 2000 +ABORT_RSS = 28 * 1024**3 # shared host: stop well before trouble +process = psutil.Process() +peak = {"rss": 0} + + +def watch() -> None: + while True: + time.sleep(0.5) + rss = process.memory_info().rss + peak["rss"] = max(peak["rss"], rss) + if rss >= ABORT_RSS: + os._exit(75) + + +threading.Thread(target=watch, daemon=True).start() +report: dict = { + "started_utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), + "root": str(ROOT), + "batch": BATCH, + "python": sys.version, + "phases": [], + "slices": [], +} + + +def save() -> None: + report["max_sampled_rss_gib"] = round(peak["rss"] / 1024**3, 3) + OUT.write_text(json.dumps(report, indent=2) + "\n") + + +def phase(name: str, began: float) -> None: + report["phases"].append( + { + "phase": name, + "seconds": round(time.monotonic() - began, 1), + "rss_gib": round(process.memory_info().rss / 1024**3, 3), + } + ) + save() + print(json.dumps(report["phases"][-1]), flush=True) + + +t = time.monotonic() +import score_us_release_head_to_head as scorer # noqa: E402 + +phase("import", t) +t = time.monotonic() +yardstick = scorer.compile_yardstick( + ledger_facts=LEDGER, + age_targets=False, + allow_unaged_dollar_targets=True, + congressional_district_vintage_crosswalk=( + scorer.release.default_congressional_district_vintage_crosswalk_path() + ), +) +phase("compile_yardstick", t) +frames = {} +for name, path in (("incumbent", INCUMBENT), ("candidate", CANDIDATE)): + t = time.monotonic() + artifact = scorer.load_artifact(path) + frame, _ = scorer.release._with_base_population_mass_repair(artifact.frame) + del artifact + batches = tuple( + scorer.release._household_position_batches(frame.n("household"), BATCH) + ) + frames[name] = (frame, batches) + phase(f"load_{name}", t) + +specs_all = yardstick.registry.specs +chunk_size = scorer.MATERIALIZE_SCORE_CHUNK_SPECS +chunks = max(1, -(-len(specs_all) // chunk_size)) +report["spec_count"] = len(specs_all) +report["chunks"] = chunks +report["slices_per_artifact"] = {k: len(v[1]) for k, v in frames.items()} +save() + + +def score(name: str, chunk: int, index: int, role: str) -> None: + frame, batches = frames[name] + start = (chunk - 1) * chunk_size + specs = specs_all[start : start + chunk_size] + weights = yardstick.loss_weights[start : start + len(specs)] + wall, cpu = time.monotonic(), time.process_time() + result = scorer._score_household_slice( + frame, + specs, + batches[index], + chunk_loss_weights=weights, + artifact_name=name, + chunk_label=f"chunk {chunk}/{chunks}", + slice_index=index, + slice_count=len(batches), + maximum_microsim_batch_size=BATCH, + ) + row = { + "artifact": name, + "chunk": chunk, + "slice": index + 1, + "role": role, + "spec_count": len(specs), + "wall_s": round(time.monotonic() - wall, 2), + "cpu_s": round(time.process_time() - cpu, 2), + "rss_gib": round(process.memory_info().rss / 1024**3, 3), + "ru_maxrss_gib": round( + resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024**3, 3 + ), + "load1": round(os.getloadavg()[0], 1), + "score_sha256": hashlib.sha256( + result.estimates.tobytes() + result.targets.tobytes() + ).hexdigest()[:16], + } + del result + report["slices"].append(row) + save() + print(json.dumps(row), flush=True) + + +# One warm-up slice each in chunk 1 (engine caches fill on first use). +score("incumbent", 1, 0, "warmup") +score("candidate", 1, 0, "warmup") +picks = {"incumbent": (7, 21), "candidate": (44, 132)} +for chunk in range(1, chunks + 1): + for rep in range(2): + score("incumbent", chunk, picks["incumbent"][rep], "timed") + score("candidate", chunk, picks["candidate"][rep], "timed") +report["finished_utc"] = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) +save() diff --git a/docs/evidence/us-h2h-speed/slices-2cfe3043d.json b/docs/evidence/us-h2h-speed/slices-2cfe3043d.json new file mode 100644 index 0000000000..7cddeba907 --- /dev/null +++ b/docs/evidence/us-h2h-speed/slices-2cfe3043d.json @@ -0,0 +1,324 @@ +{ + "started_utc": "2026-11-16T18:08:20Z", + "root": "/Users/maxghenis/PolicyEngine/_worktrees/microcosm-h2h-2cfe3043d", + "batch": 2000, + "python": "3.14.7 (main, Sep 1 2026, 14:05:28) [Clang 22.1.3 ]", + "phases": [ + { + "phase": "import", + "seconds": 38.1, + "rss_gib": 1.422 + }, + { + "phase": "compile_yardstick", + "seconds": 22.5, + "rss_gib": 2.413 + }, + { + "phase": "load_incumbent", + "seconds": 2.9, + "rss_gib": 3.625 + }, + { + "phase": "load_candidate", + "seconds": 11.3, + "rss_gib": 9.541 + } + ], + "slices": [ + { + "artifact": "incumbent", + "chunk": 1, + "slice": 1, + "role": "warmup", + "spec_count": 8192, + "wall_s": 53.59, + "cpu_s": 49.15, + "rss_gib": 7.488, + "ru_maxrss_gib": 11.313, + "load1": 120.1, + "score_sha256": "bd3bca174d3861eb" + }, + { + "artifact": "candidate", + "chunk": 1, + "slice": 1, + "role": "warmup", + "spec_count": 8192, + "wall_s": 41.22, + "cpu_s": 39.05, + "rss_gib": 7.859, + "ru_maxrss_gib": 11.313, + "load1": 73.8, + "score_sha256": "0575557539dd317c" + }, + { + "artifact": "incumbent", + "chunk": 1, + "slice": 8, + "role": "timed", + "spec_count": 8192, + "wall_s": 49.9, + "cpu_s": 47.26, + "rss_gib": 8.382, + "ru_maxrss_gib": 11.313, + "load1": 49.0, + "score_sha256": "91467bf4d98bad4e" + }, + { + "artifact": "candidate", + "chunk": 1, + "slice": 45, + "role": "timed", + "spec_count": 8192, + "wall_s": 35.93, + "cpu_s": 34.58, + "rss_gib": 8.418, + "ru_maxrss_gib": 11.313, + "load1": 47.3, + "score_sha256": "35f4016a370167ef" + }, + { + "artifact": "incumbent", + "chunk": 1, + "slice": 22, + "role": "timed", + "spec_count": 8192, + "wall_s": 33.28, + "cpu_s": 32.67, + "rss_gib": 8.421, + "ru_maxrss_gib": 11.313, + "load1": 50.6, + "score_sha256": "dab50bb1feb26c26" + }, + { + "artifact": "candidate", + "chunk": 1, + "slice": 133, + "role": "timed", + "spec_count": 8192, + "wall_s": 41.9, + "cpu_s": 40.22, + "rss_gib": 8.428, + "ru_maxrss_gib": 11.313, + "load1": 67.9, + "score_sha256": "453365e5daf79efc" + }, + { + "artifact": "incumbent", + "chunk": 2, + "slice": 8, + "role": "timed", + "spec_count": 8192, + "wall_s": 49.19, + "cpu_s": 47.43, + "rss_gib": 8.294, + "ru_maxrss_gib": 11.313, + "load1": 74.8, + "score_sha256": "417697c39121b481" + }, + { + "artifact": "candidate", + "chunk": 2, + "slice": 45, + "role": "timed", + "spec_count": 8192, + "wall_s": 42.36, + "cpu_s": 40.44, + "rss_gib": 8.108, + "ru_maxrss_gib": 11.313, + "load1": 46.8, + "score_sha256": "781786945eb53099" + }, + { + "artifact": "incumbent", + "chunk": 2, + "slice": 22, + "role": "timed", + "spec_count": 8192, + "wall_s": 42.91, + "cpu_s": 41.13, + "rss_gib": 8.066, + "ru_maxrss_gib": 11.313, + "load1": 43.6, + "score_sha256": "8f1f762cd314dd2d" + }, + { + "artifact": "candidate", + "chunk": 2, + "slice": 133, + "role": "timed", + "spec_count": 8192, + "wall_s": 40.11, + "cpu_s": 38.62, + "rss_gib": 8.116, + "ru_maxrss_gib": 11.313, + "load1": 55.8, + "score_sha256": "3ca632471dbb9eec" + }, + { + "artifact": "incumbent", + "chunk": 3, + "slice": 8, + "role": "timed", + "spec_count": 8192, + "wall_s": 43.79, + "cpu_s": 42.41, + "rss_gib": 8.477, + "ru_maxrss_gib": 11.313, + "load1": 56.3, + "score_sha256": "87ac9713611765e9" + }, + { + "artifact": "candidate", + "chunk": 3, + "slice": 45, + "role": "timed", + "spec_count": 8192, + "wall_s": 37.15, + "cpu_s": 36.79, + "rss_gib": 8.468, + "ru_maxrss_gib": 11.313, + "load1": 56.7, + "score_sha256": "9214de495f622e43" + }, + { + "artifact": "incumbent", + "chunk": 3, + "slice": 22, + "role": "timed", + "spec_count": 8192, + "wall_s": 40.44, + "cpu_s": 38.9, + "rss_gib": 8.452, + "ru_maxrss_gib": 11.313, + "load1": 50.5, + "score_sha256": "2d68a0a21015d419" + }, + { + "artifact": "candidate", + "chunk": 3, + "slice": 133, + "role": "timed", + "spec_count": 8192, + "wall_s": 38.98, + "cpu_s": 37.4, + "rss_gib": 8.432, + "ru_maxrss_gib": 11.313, + "load1": 56.0, + "score_sha256": "b3d6a4aff33d810b" + }, + { + "artifact": "incumbent", + "chunk": 4, + "slice": 8, + "role": "timed", + "spec_count": 8192, + "wall_s": 47.51, + "cpu_s": 45.15, + "rss_gib": 8.106, + "ru_maxrss_gib": 11.313, + "load1": 64.9, + "score_sha256": "406eeb34522446c8" + }, + { + "artifact": "candidate", + "chunk": 4, + "slice": 45, + "role": "timed", + "spec_count": 8192, + "wall_s": 34.39, + "cpu_s": 32.55, + "rss_gib": 8.058, + "ru_maxrss_gib": 11.313, + "load1": 55.1, + "score_sha256": "25ae286b0789e2dc" + }, + { + "artifact": "incumbent", + "chunk": 4, + "slice": 22, + "role": "timed", + "spec_count": 8192, + "wall_s": 41.15, + "cpu_s": 39.1, + "rss_gib": 8.08, + "ru_maxrss_gib": 11.313, + "load1": 39.4, + "score_sha256": "b36b6b4a5e86407a" + }, + { + "artifact": "candidate", + "chunk": 4, + "slice": 133, + "role": "timed", + "spec_count": 8192, + "wall_s": 34.92, + "cpu_s": 33.28, + "rss_gib": 8.084, + "ru_maxrss_gib": 11.313, + "load1": 42.6, + "score_sha256": "0b9147750db68169" + }, + { + "artifact": "incumbent", + "chunk": 5, + "slice": 8, + "role": "timed", + "spec_count": 379, + "wall_s": 232.2, + "cpu_s": 225.73, + "rss_gib": 9.021, + "ru_maxrss_gib": 11.313, + "load1": 54.0, + "score_sha256": "81ddea5d6ffe7603" + }, + { + "artifact": "candidate", + "chunk": 5, + "slice": 45, + "role": "timed", + "spec_count": 379, + "wall_s": 202.06, + "cpu_s": 193.92, + "rss_gib": 9.287, + "ru_maxrss_gib": 11.313, + "load1": 94.0, + "score_sha256": "0c872709128bd410" + }, + { + "artifact": "incumbent", + "chunk": 5, + "slice": 22, + "role": "timed", + "spec_count": 379, + "wall_s": 225.82, + "cpu_s": 213.34, + "rss_gib": 9.319, + "ru_maxrss_gib": 11.313, + "load1": 30.6, + "score_sha256": "deed90ec9ea57424" + }, + { + "artifact": "candidate", + "chunk": 5, + "slice": 133, + "role": "timed", + "spec_count": 379, + "wall_s": 197.3, + "cpu_s": 188.48, + "rss_gib": 9.343, + "ru_maxrss_gib": 11.313, + "load1": 48.6, + "score_sha256": "89679c7459cb350a" + } + ], + "max_sampled_rss_gib": 10.416, + "spec_count": 33147, + "chunks": 5, + "slices_per_artifact": { + "incumbent": 29, + "candidate": 177 + }, + "finished_utc": "2026-11-16T18:36:21Z" +} diff --git a/docs/us-modal-stage-route-a-h2h-plan.json b/docs/us-modal-stage-route-a-h2h-plan.json new file mode 100644 index 0000000000..f29fe87b76 --- /dev/null +++ b/docs/us-modal-stage-route-a-h2h-plan.json @@ -0,0 +1,38 @@ +{ + "schema": "microcosm-modal-us-stage-plan/1", + "tool": "us-release-head-to-head", + "stage": "score", + "run_id": "route-a-h2h-d844-d1386-r1", + "source": { + "commit": "2cfe3043d747b929e349c8de2486acf80b5f17f2", + "branch": "main" + }, + "inputs": { + "incumbent_h5": { + "uri": "volume://cas/sha256/6496cc4393d4d3c6574f76eca231de5898c803b9067645591fd5c4d3e65aee84/populace_us_2024.h5", + "sha256": "6496cc4393d4d3c6574f76eca231de5898c803b9067645591fd5c4d3e65aee84" + }, + "candidate_h5": { + "uri": "volume://cas/sha256/2d9c8586c45c32e5ca27357317f4de93b526cc51dd28b15b71ed43e47e142e79/populace_us_2024.h5", + "sha256": "2d9c8586c45c32e5ca27357317f4de93b526cc51dd28b15b71ed43e47e142e79" + }, + "ledger_facts": { + "uri": "volume://cas/sha256/b85437390021777e746f507c5890305496baf5fc7f2c78ba08ddb090f4839801/consumer_facts_us_c5e5bf8.jsonl", + "sha256": "b85437390021777e746f507c5890305496baf5fc7f2c78ba08ddb090f4839801" + } + }, + "options": { + "workers": 16, + "maximum_microsim_batch_size": 2000 + }, + "env": { + "PYTHONUNBUFFERED": "1", + "OMP_NUM_THREADS": "1", + "MKL_NUM_THREADS": "1", + "OPENBLAS_NUM_THREADS": "1", + "NUMEXPR_NUM_THREADS": "1", + "BLIS_NUM_THREADS": "1" + }, + "max_wall_seconds": 14505, + "nonpreemptible": true +} diff --git a/docs/us-modal-stage-runbook.md b/docs/us-modal-stage-runbook.md index 42e28f32a3..1e778d3bc3 100644 --- a/docs/us-modal-stage-runbook.md +++ b/docs/us-modal-stage-runbook.md @@ -3,7 +3,7 @@ Epic #956 acceleration item E: heavy US stages should not have to queue on the one 128 GiB build machine. This runbook covers the smallest working path: a registered tool run on Modal from a pinned commit, with inputs fetched by -digest and outputs listed with sha256 receipts. Six tools are registered +digest and outputs listed with sha256 receipts. Seven tools are registered (`TOOLS` in the plan module): `tools/build_us_acs_local_release.py` (tool `us-acs-local-release`, stages `materialize`, `calibrate`, `qa`, `finalize`, `package`, or `all`), Route A's PUF-support base, @@ -15,7 +15,9 @@ its default-pool registration `us-puf-support-base-income-2023-2025` (the rerun's command on income years 2023-2025; see "The default-pool template"), the ACS multispine staging builder, `tools/build_us_acs_multispine_base.py` (tool `us-acs-multispine-staging`, -stage `all`; see "ACS multispine staging"), and `runner-smoke` (stage +stage `all`; see "ACS multispine staging"), the US head-to-head scorer, +`tools/score_us_release_head_to_head.py` (tool `us-release-head-to-head`, +stage `score`; see "Route A head-to-head (d844)"), and `runner-smoke` (stage `smoke`), an inline script that proves the run path on any pushed commit (see "Commands"). @@ -30,7 +32,15 @@ Two files do the work: and, for the base, `packages/microcosm-build/tests/engine_free/us/test_us_modal_stage_puf_support_base.py`. Staging tests are in - `packages/microcosm-build/tests/engine_free/us/test_us_modal_stage_acs_multispine_staging.py`. + `packages/microcosm-build/tests/engine_free/us/test_us_modal_stage_acs_multispine_staging.py`, + and the scorer's in + `packages/microcosm-build/tests/engine_free/us/test_us_modal_stage_release_head_to_head.py`. + +The actual subprocess parser probe is covered by +`packages/microcosm-build/tests/engine_contract/us/test_us_modal_stage_release_head_to_head.py` +in `tools/ci_test_plan.py`'s `engine-contract-us` group. Importing the scorer +loads the US engine through a sibling tool, so this regression runs in US +engine CI. Nothing here uploads to the Hugging Face Hub, changes `releases.json` or notifies anyone. The furthest a stage goes is `package`, which writes the @@ -416,24 +426,27 @@ local wall times in this table understate Modal's wall and cost. | check | n/a | check | 2 cores, 8 GiB, 30 min timeout | cents | | PUF-support base (`all`) | 72.5 GB, 2,788 s wall, 6,238 CPU-s | base | 4 cores (limit 4), 112 GiB, 4 h 35 min timeout | about $0.84 ($2.52 non-preemptible) | | ACS multispine staging (`all`) | 42.4 GB, 7,218 s wall, 103,105 CPU-s | acs-staging | 16 cores (limit 16), 80 GiB, 17 h timeout | about $2.79 ($8.38 non-preemptible) | +| Route A head-to-head (`score`) | Mac only: 11.31 GiB peak `ru_maxrss` for one process holding both frames, 8.10 GiB peak `ru_maxrss` printed by 3 incumbent workers; no candidate worker measured; time on Modal not measured | head-to-head | 16 cores (limit 16), 288 GiB (limit 288), 15,705 s (4 h 22 min) timeout from the $40 cap | $40.00 non-preemptible compute through the timeout | The prices are Modal's list prices for standard compute, read from [modal.com/pricing](https://modal.com/pricing) on 22 September 2026 and -unchanged on 29 September and 13 October: +unchanged on 29 September, 10 October and 13 October: $0.0000131 per core-second and $0.00000222 per GiB-second. Modal bills the higher of the request and actual use (modal.com/docs/guide/resources). The heavy class costs about $1.21 an hour at its request, so an 8-hour timeout costs about $9.70 at the request; CPU or memory used above the request bills above that. With `"nonpreemptible": true` every figure is three times -higher: about $3.63 an hour for the heavy class. The base and acs-staging -classes set CPU limits equal to their requests; the others are request-only -for CPU, -and every class is request-only for memory, so a stage that used more cores -or more memory than its request would be billed for them. The engine pass in +higher: about $3.63 an hour for the heavy class. The base, acs-staging and +head-to-head classes set CPU limits equal to their requests; the others are +request-only for CPU. The head-to-head class also sets a memory limit equal +to its request; every other class is request-only for memory, so a stage +that used more cores or more memory than its request would be billed for +them. The engine pass in materialize is single-threaded (CPU seconds roughly equal wall seconds), so extra cores would not speed it up. The table leaves out volume storage and -image builds. The base class is sized in "Route A's base stage" below; -the acs-staging class is sized in "ACS multispine staging". +image builds. The base class is sized in "Route A's base stage" below, +the acs-staging class in "ACS multispine staging", and the head-to-head +class in "Route A head-to-head (d844)". ## Commands @@ -1692,6 +1705,651 @@ state files. It does not accept a budget stop as a successful staging build. A receipt verifies artifact bytes; the later release's existing gates and certification still determine whether the release is accepted. +## Route A head-to-head (d844) + +`docs/us-modal-stage-route-a-h2h-plan.json` compares the d1386 Route A +build (`populace-us-2024-b5db384-8b0c1950b65f-20261024T083103Z`) with the US +default (`populace-us-2024-spm-20260915`) on the frozen +`consumer_facts_us_c5e5bf8.jsonl` ledger, the register d844 fixed before any +result. The d1386 build was calibrated on `consumer_facts_us_51aa40f.jsonl` +and the default on an older feed, so neither was fit to this register. The +plan pins scorer commit `2cfe3043d747b929e349c8de2486acf80b5f17f2` on +`main`, which carries #1171 (`--workers`, the per-slice release of Core's +variable modules, and the recycling guard) and locks policyengine-us 2.2.1, +the engine the d1386 manifest names. The runner registration comes from this +checkout. A plan's pin is immutable and freezes the yardstick: to pick up a +later scorer change, update `source.commit`, then repeat the local +validation and the Modal check. + +The stage runs the local comparison's argv with staged paths and +`--workers 16` added: + +```text +--incumbent X --candidate Y --ledger-facts Z --out-prefix P --maximum-microsim-batch-size 2000 --workers 16 +``` + +Only `workers`, `maximum_microsim_batch_size` and `worker_max_slices` are +plan options. The d844 plan does not set `worker_max_slices`, so each +worker lives for its artifact's whole pool. The scorer refuses recycling +below Python 3.14.7, and the image's `3.14` resolves to 3.14.2 on Modal's +2025.06 image builder (`modal/builder/base-images.json` in modal 1.3.0). +Check mode reports the image venv's Python under `environment.python` and +under the parser probe's `python`, and when a plan sets `worker_max_slices` +it runs the scorer's own `_assert_worker_recycling_supported` in the image +(`ToolSpec.option_preflights`), so a recycling plan fails the check instead +of the paid run. Every path flag, `--out-prefix`, the candidate-manifest +pin, both spellings of each boolean, and the alternative batch-size +spelling are runner-owned. The builder omits `--age-targets` and +`--allow-unaged-dollar-targets`, so the scorer uses the same defaults as the +sequential run: `False` and `True`, respectively. The crosswalk and candidate +pool/attestation flags are also omitted; the scorer chooses its normal +bundled crosswalk. Changing this scoring yardstick requires a reviewed +registration change. The plan sets the five native numerical thread counts +to `1`, so sixteen spawned workers do not each start a sixteen-thread +BLAS/OpenMP pool. That is an execution choice; the engine-free argv test +does not prove numerical parity across platforms or thread counts. + +Both H5 inputs retain the filename `populace_us_2024.h5` in separate CAS +directories and stage to `/work/inputs/incumbent_h5/populace_us_2024.h5` +and `/work/inputs/candidate_h5/populace_us_2024.h5`. Keep the `.h5` suffix +and this filename: `_resolved_artifact_path` preserves them for the loader +and artifact identity. Do not upload either H5 under an extensionless hash. +The incumbent is 826,917,837 bytes, the candidate 2,509,287,855 bytes and +the ledger 164,603,204 bytes. + +**What the run does.** The scorer compiles the register once (33,147 +specs in five chunks of up to 8,192; chunk 5 holds 379, among them the +eleven JCT reform measures), then scores the incumbent in one pool of +spawned workers and the candidate in a fresh pool. Each artifact has the +same number of 2,000-household slices in every chunk: 29 for the +incumbent and 177 for the candidate, so 145 and 885 slices. Each worker +receives the repaired frame once, when it starts. + +**Memory.** Class `head-to-head` requests 16 physical cores and 288 GiB, +each limited at the request: 16 GiB for each of 16 workers plus 32 GiB for +the parent, which retains the original and repaired frames. Two limits bound +it, and the go/no-go watcher below judges neither. The class's hard limit +OOM-kills the container. The scorer's own guard (`MAX_RSS_BYTES`, 20 GiB) +raises `MemoryError` in any process whose peak RSS reaches it at a logged +boundary. What has been measured, all on the Mac +(`docs/evidence/us-h2h-speed`): + +- One process holding both frames peaked at 10.4 GiB of current RSS, + sampled every half second, and at 11.31 GiB of `ru_maxrss`, the peak the + scorer's lines and its guard use. +- In a three-worker pool run of the pinned scorer, incumbent workers' slice + lines printed 4.38 to 8.10 GiB of `ru_maxrss` (their start lines 1.85 GiB) + and the parent's 3.66 to 5.01 GiB. +- No candidate worker has run. "About 12 GiB per candidate worker" is an + inference from the September candidate's frame (5.45 GiB in-process and + 2.17 GiB pickled, measured 10 October). + +Earlier runs and probes: + +- October's sequential run, under the older scorer, grew 37 to 60 MiB per + slice in chunks 2 to 4 (166 MiB per slice in chunk 1, from the loaded + frame) and died of a `MemoryError` at 20.3 GiB in chunk 5. +- The local probe of 11 November, on the d1386 frame and the current scorer, + saw the traced heap grow 22 to 45 MB per slice after a one-time step at + slice 3, over six slices of chunk 5 only. +- The 23 September materialize acceptance attempt peaked at 66.3 to 74.5 GB + on Modal against 51.0 GB on the Mac (1.30 to 1.46 times). + +An OOM-kill writes **no final receipt and mirrors no output**. Inspect the +container logs and Modal's measurements, and do not assume the absence of a +receipt means the attempt was free. The receipt's `peak_rss_bytes` is a +child-process peak from `RUSAGE_CHILDREN`, not the sum of sixteen workers. + +**Time.** All of the timing below comes from the Mac +(`docs/evidence/us-h2h-speed`). + +One process scored a slice in these times: + +| Artifact | Chunks 1 to 4 | Chunk 5 | +|---|---|---| +| Candidate | 34 to 42 s | about 200 s | +| Incumbent | 33 to 50 s | 226 to 232 s | + +Extrapolated from two timed slices per chunk, all 1,030 slices come to +about 74,100 s of slice work, or 4,631 s on 16 workers. + +The scorer's pool starts workers on demand, one at a time. A submit that +finds no result token free starts a worker. Each start blocks the parent +while the child imports the scorer and reads its arguments. On the Mac, +the rebuilt pool dates the incumbent's three starts at 42, 36 and 44 s from +the submit to the worker's first line. Those are intervals the model dates +from the log, not measured blocks: `Process.start()` returns once the +child's arguments are written, and the line comes after the worker's +initializer, so how much of each interval blocked the parent is not +measured. + +Nothing has timed this scorer on Modal, or a candidate worker's start +anywhere. A simulation of 16-worker runs from the Mac times (not a +measurement: `projection-grid.txt` there) shows when the run fits the $40 +budget: when its last slice ends at least 600 s before the budget does, the +allowance the estimate keeps for the comparison and scorecards. The +watcher's budget runs from `started-at`, written before `modal run`, so the +container's start and staging come out of it too: with 300 s of those, the +f = 1, T = 300 s run below gets `NO-GO` at 1,200 s, and the watcher stops +it a poll later at the earliest, although it fits the runner's budget +(`projection-grid-pre-tool-300.txt`). Let f be Modal's time +per slice over the Mac's: + +- at f up to 1, if a worker starts in 300 s or less; +- at f up to 1.5, if a worker starts in 175 s or less; +- at f up to 2, if a worker starts in 100 s or less; +- at f of 3 or more, never. + +The runbook's measured Modal slowdown for single-core materialize work, 3.3 +to 7.6 times per chunk, would not fit. October's sequential run, under an +older scorer on free-threaded CPython, took 5 to 10 minutes per slice. That +is 6 to 9 times the Mac times above in chunks 1 to 4, for reasons not +tested. + +**Placement and the cap.** The plan runs non-preemptible. The scorer has no +resume. At the preemption rate measured in "Preemption and restarts" (about +0.67 per hour), a preemptible attempt of two to four hours, the span of +the simulated runs that fit, would finish only 26% to 7% of the time. + +`HEAD_TO_HEAD_COST_CAP_USD` sets the class timeout: the cap divided by the +class's non-preemptible list price, +`(16 × $0.0000131 + 288 × $0.00000222) × 3 = $0.00254688` per second +($9.17 an hour). At Max's $40 cap (10 October) that is 15,705 seconds +(4.4 hours). The plan's `max_wall_seconds` of 14,505 leaves the runner's +900-second reserve and 300 seconds for staging. Whether $40 is enough +depends on Modal's speed for this scorer, which only a run can measure. The +watcher below stops a run that will not fit. + +Raising the cap changes `HEAD_TO_HEAD_COST_CAP_USD`, the plan's +`max_wall_seconds` (the new timeout less 1,200) and the figures the plan +tests pin. The CPU and +memory limits equal their requests, so the timeout bounds one attempt's +compute bill. This ceiling is not a cap on total Modal account spend. These +stay outside it: + +- startup and image work outside the timeout; +- the check; +- storage; +- timeout-enforcement overshoot. + +A changed plan is a new plan sha256 with a fresh runner budget. Record every +attempt's spend for this comparison in the run folder, and keep the total +inside Max's cap yourself. + +Stage the inputs in the `policyengine` workspace. Set these variables to +the existing local files; the ledger path is the one used by Route A's +base. `upload-commands` only hashes files and prints commands: it performs +no upload. Run it first to refuse a digest mismatch before uploading. +If a CAS file already exists (the base may have staged the ledger), skip +that `put` and let check mode verify its digest; do not overwrite it. Both +H5s are in the `policyengine/populace-us` Hugging Face dataset under the +revisions named for their releases. A download of each, or the local +Hugging Face cache's copy, serves as the local file: `upload-commands` +rehashes whatever it is given. + +```bash +# Pin the workspace for every Modal command here (see below). +export MODAL_PROFILE=policyengine MODAL_ENVIRONMENT=main +INCUMBENT_H5=/path/to/populace-us-2024-spm-20260915/populace_us_2024.h5 +CANDIDATE_H5=/path/to/populace-us-2024-b5db384-8b0c1950b65f-20261024T083103Z/populace_us_2024.h5 +LEDGER_FACTS=/path/to/consumer_facts_us_c5e5bf8.jsonl +python3 tools/modal_us_stage_plan.py upload-commands \ + docs/us-modal-stage-route-a-h2h-plan.json \ + incumbent_h5="$INCUMBENT_H5" candidate_h5="$CANDIDATE_H5" ledger_facts="$LEDGER_FACTS" + +modal volume put microcosm-us-stage-inputs "$INCUMBENT_H5" \ + cas/sha256/6496cc4393d4d3c6574f76eca231de5898c803b9067645591fd5c4d3e65aee84/populace_us_2024.h5 +modal volume put microcosm-us-stage-inputs "$CANDIDATE_H5" \ + cas/sha256/2d9c8586c45c32e5ca27357317f4de93b526cc51dd28b15b71ed43e47e142e79/populace_us_2024.h5 +modal volume put microcosm-us-stage-inputs "$LEDGER_FACTS" \ + cas/sha256/b85437390021777e746f507c5890305496baf5fc7f2c78ba08ddb090f4839801/consumer_facts_us_c5e5bf8.jsonl + +# Validate locally, then check on Modal. +python3 tools/modal_us_stage_plan.py validate docs/us-modal-stage-route-a-h2h-plan.json +MICROCOSM_MODAL_PLAN=docs/us-modal-stage-route-a-h2h-plan.json \ + modal run tools/modal_us_stage.py +``` + +Require `CHECK OK`, including the pinned parser and all three volume +digests, before the paid run. Launch the paid run under launchd, never from a +session shell: a restart of the launching session kills a session-owned +client, and Modal then cancels the paid input (this happened to Route A's +base on 2026-09-29). Launch it with `--run --spawn`, which returns once the +stage is spawned (see "Commands"), and record the launch time, the app id +(`ap-…`) and the printed `function_call_id`. From the checkout that holds +this plan: + +Each attempt gets its own local folder, `modal-runs/$R/attempt-N`: the +plan's run id, and so `runs/$R` on the volume, stays the same across +attempts, but the watcher must not read an earlier attempt's streams. It +refuses a folder whose streams hold scorer lines from before `started-at`. + +Pin the Modal workspace and environment for every Modal command of the +attempt: the uploads and the check above, the launch, the watcher and the +fetch below. Another session can switch the active profile (`modal profile activate`, +`modal token new` or `modal token set`) or environment (`modal config +set-environment`) mid-run; the app list and the stop would then read +another workspace, and uploads would land where the pinned launch cannot +read them, using up the attempt on a failed start. `~/.modal.toml` on the +build Mac sets no environment +(checked 2026-11-16), so the workspace's default, `main`, is inferred: +confirm it with `modal environment list` before the launch. The watcher +refuses to start unless both are set. + +```bash +R=route-a-h2h-d844-d1386-r1 +A="modal-runs/$R/attempt-1" # attempt-2 for a second attempt, and so on +mkdir -p "$A" +cat > "$A/launch.sh" < $A/started-at +exec modal run --detach tools/modal_us_stage.py --run --spawn +SH +chmod +x "$A/launch.sh" +``` + +Submit that script as a transient launchd job. On the build Mac the helper +is `lsubmit.sh