Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #655

Raw Markdown for agents: https://autobot.eidonix.com/p/9a06035a-0a5e-4562-b5ce-3aecc5623f8d.md

#1 [high] PR #655 verified mechanism and release paths (head f7f4d253)

Verified in tree at PR head:

#2 [high] Findings: contracts, metrics, docs, robustness (PR #655)

F1 (Major, process/contract): New server-global safety guard not modelled in verification. Guard added at checkpoints.rs:1018-1043 (concurrency cap of one in-flight discovery) plus RequestScheduler field scheduler.rs:661 and three release paths (2690-2692, 2700-2702, 3067-3069). docs/design-review.md:209-240: "Run the TLA+ models and Rust trace-conformance suite ... whenever changing admission, fences, generations, cancellation, ... snapshot aliases ..." and "Modifying the Helios scheduler ... without running—and updating when behavior, transitions, or supported bounds change—the applicable TLA+ models ... is a blocking design failure, regardless of whether CPU unit tests pass." search_code "discovery|snapshot_discovery" in verification/ => No matches: nothing models the new transition (CheckpointReservation.tla models Guard/Armed/Copying/Published + TerminalDestination only, per dossier). PR body says only "CheckpointReservation.tla reservation invariants are unchanged". Fix: extend the model with a discovery-slot state (or state in the body why the guard is outside the model's domain) and run check.py --mutations per design-review.md:226-228.

F2 (Minor, metric contract): zero-priced copy breaks documented meaning of the extra-work counter. checkpoints.rs:1043 let cost = measured.or_else(|| discovering.then_some(0)); -> 1075 request.checkpoint_copy_ns = cost; -> 1083-1097 commit_checkpoint_copies adds cost (0) to stats.checkpoint_extra_work_ns. Meanwhile scheduler.rs:2699 self.stats.checkpoint_endpoint_captures += 1; counts it. docs/api.md:355-356 still says flare_checkpoint_extra_work_nanoseconds_total "sums charged predicted extra prefill and copy work; it is not a GPU timing measurement" with no exception, though the four design docs now disclose the zero price (scheduling-runtime-design.md:625-628, core-design.md:1455-1457, cli-design.md:706-708, README:379-382). Impact: one copy per cold-discovery event (once per process lifetime per unmeasured state) is invisible to the counter operators size with; captures and nanos diverge. Fix: add the exception sentence to docs/api.md:355-356 (or count the discovery copy at the retained/next-measured price).

F3 (Minor, doc contradiction): scheduling-runtime-design.md:625-631 puts "terminal capture allows at most one in-flight discovery capture (priced at zero)" immediately before the unchanged "There is no fixed capture count or concurrency-based snapshot share." Same at core-design.md:1444-1445 ("no capture-count limit or allocation of a fixed snapshot share to each request") vs 1455-1457. The slot IS a server-global concurrency cap of one. Fix: qualify both sentences with "apart from the single cold-discovery capture above".

F4 (Minor, robustness adjacent to new code): measured_duration conflates "no declared Snapshot batch" with "unmeasured". checkpoints.rs:1039-1043: with an empty Snapshot batch list measured is None, discovering is true whenever fraction>0 and the slot is free, so a terminal capture is allocated at zero and request.terminal_snapshot set (scheduler.rs:2899) -> phase Snapshot -> phase_plan(GraphKind::Snapshot) has zero candidates -> policy.rs:1817-1825 .expect("requested lifecycle operation must be feasible") panics. Before the change this was a safe skip (fresh_duration -> None). Live reachability is currently blocked by manifest validation (model/catalog.rs:140-148 requires Snapshot graphs for every lifecycle batch) and by limits.snapshots == 0 early return (checkpoints.rs:1030), so this is a latent panic, not a live bug. Fix: gate discovering on !self.costs.batches(GraphKind::Snapshot).is_empty().

Verified sound (state plainly, no finding): single-threaded scheduler so no lock/HOL contention added; measured_duration is O(#batches) hash lookups inside the per-planning-scope memoized checkpoint_selections cache (checkpoints.rs:410-428, opened at policy.rs:1531/1784), so no hot-path blowup; RequestHandle is slot+generation and request() filters on equality (scheduler.rs:1233-1239), so a recycled slot cannot alias the discovery handle; snapshot_discovery_in_flight treats Finishing as free (1018-1023) and retire clears before any early return (3067-3069), so cancel/finish/shutdown cannot lock discovery out; the finish_early/preemption terminal path (scheduler.rs:1430-1457) bypasses the slot but still executes a Snapshot graph, so it can measure cost without claiming or leaking the slot; the claim happens only after a row is obtained (1069-1072) and storage refusal only bumps checkpoint_skip_storage (1078), asserted by the new test at checkpoints.rs:4204-4212; PR body claims about Prefill retention (cost.rs:654-682), 9-sample window reset on next execution (cost.rs:852-861) and TTL-caused fresh_duration skips (cost.rs:513-517) are accurate.

Not verified / out of scope: no log or metric dump behind the four live SM120 scenarios; no TP>1, multi-host, SM103/SM121 or core-load compatibility run; scripts/scheduling_sim genuinely has no checkpoint ActionCosts model, so that checklist N/A is accurate.

#3 [high] Research summary

Reviewed PR #655 at head f7f4d253 with the correctness/contracts/system-consequences lens. I read the full diff, helios/src/scheduler/cost.rs (ActionCosts, Estimate, observed_duration_ns, observe), helios/src/scheduler/checkpoints.rs (checkpoint_selection_uncached, checkpoint_copy_allowed, allocate_terminal_capture, commit_checkpoint_copies, commit_checkpoint_plans, the new tests), helios/src/scheduler.rs (LiveRequest, complete/status-3 path, captures loop, retire/cancel/finish, finish_early/preempt, request()/handle equality, stats), policy.rs (select_plan/available_plan/phase_plan, materialize expect), refresh.rs, service.rs, docs/{api,core-design,scheduling-runtime-design,cli-design,design-review}.md, helios/README.md, and the manifest validation in model/catalog.rs.

Four findings, recorded in the scratchpad with citations and verbatim quotes: (1) Major/process — the new server-global discovery guard is lifecycle-covered code but nothing in verification/ models it, contrary to docs/design-review.md:209-240; (2) Minor — the zero-priced discovery copy makes flare_checkpoint_extra_work_nanoseconds_total under-report while docs/api.md:355-356 still claims it sums charged copy work, even though all four design docs disclose the zero price; (3) Minor — the new "at most one in-flight discovery capture" sentence sits next to unchanged "no capture-count limit / no concurrency-based snapshot share" claims (scheduling-runtime-design.md:625-631, core-design.md:1444-1457); (4) Minor/latent — measured_duration conflates "no declared Snapshot batch" with "unmeasured", so an empty Snapshot batch list plus a positive fraction would allocate a zero-priced terminal capture and eventually hit the expect("requested lifecycle operation must be feasible") panic in policy.rs:1817-1825; currently blocked by manifest validation and the limits.snapshots == 0 early return, so latent rather than live.

I found the rest of the change sound and said so explicitly: single-threaded scheduler so no added lock/HOL contention; measured_duration runs inside the per-planning-scope memoized selection cache; the Option<RequestHandle> slot cannot alias a recycled request (handle equality is filtered in request()); snapshot_discovery_in_flight treats Finishing as free and retire clears before any early return, so cancel/finish/shutdown cannot lock discovery out; the claim happens only after a row is obtained, so storage refusal does not burn the slot (asserted by a new test); the preemption/finish_early terminal path bypasses the slot but still executes a Snapshot graph, so it can measure without claiming or leaking. PR-body claims about Prefill retention, the 9-sample window reset, and the TTL-induced fresh_duration skips are accurate; the four live SM120 scenarios have no logs or metric dumps and cover one GPU/model/TP1 only, and there is still no human maintainer review.

#4 [high] Tests, claim accuracy, parity and contention checks (PR #655)

Test/claim accuracy checks done against the tree at f7f4d253: