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

Raw Markdown for agents: https://autobot.eidonix.com/p/4416a677-a1cd-4a91-b1e5-16c0e080c203.md

#1 [high] PR #655 correctness/system-level findings (verified)

Head 2d9454f. Files: cost.rs (+85/-2), checkpoints.rs (+159/-3), docs/scheduling-runtime-design.md (+9/-4).

CONFIRMED MECHANICS

F1 (Major, metric/admission pricing span): first probe of an unmeasured entry is priced 0 ⇒ bypasses work budget and charges 0 to flare_checkpoint_extra_work_nanoseconds_total although a real GPU copy runs. cost.rs:803 ready.then_some(estimate.nanos) returns Some(0) when nanos==0. checkpoints.rs:1050 if accounting.extra_spent_ns.saturating_add(cost) > allowance(...) — cost 0 always passes. checkpoints.rs:1077 request.checkpoint_copy_ns = cost; then 1095-1096 stats.checkpoint_extra_work_ns += cost → +0. docs/api.md:355-356 "flare_checkpoint_extra_work_nanoseconds_total sums charged predicted extra prefill and copy work". New test asserts the zero: checkpoints.rs:4161 assert_eq!(scheduler.request(h1).unwrap().checkpoint_copy_ns, 0); Ceiling 1 uncharged copy / estimate_ttl_ns (30s default, policy.rs:39). Fix: price first probe at a conservative fallback (e.g., smallest measured Snapshot duration, or the largest declared lifecycle graph estimate) or count it in a separate probe counter; at minimum document the under-count.

F2 (Major, liveness/measurement parity): the probe is spent at allocation but the resulting observation can land on a different cost key (batch>1), so the smallest-batch entry the probe priced is never measured and the TTL slot is burnt. observe keys on the executed step: cost.rs:865-872 batch: step.batch_capacity. policy.rs:900-914 continuation_candidate fill extends a Snapshot cohort to capacity; unmeasured durations sort FIRST in utility.rs:154-158 (self.duration_ns == 0).cmp(&(other.duration_ns == 0)), so an unmeasured batch>1 Snapshot candidate outranks the measured batch-1 one and can absorb the probed request plus any ArmedCapture (Anchor) request already in RequestPhase::Snapshot. checkpoints.rs:962-967 & 965: if capture.role == RetentionRole::Anchor { return Ok(true); } — anchor captures always run, so a second Snapshot-phase lane is reachable. Result: fresh_duration(Snapshot,1) still None → probe slot consumed, no measurement. Tests never exercise this: helper checkpoints.rs:1113-1127 measure() hardcodes batch_capacity: 1, and both new tests only ever place one request in Snapshot phase. Fix: stamp the probe only after observe records that exact smallest-batch key, or let a measured larger-batch observation satisfy the smallest-batch freshness (or add a coalesced-batch regression test).

F3 (Minor→Major, failure propagation): record_probe at allocation time is not reverted when the dispatch never produces a measurement (cancel/preempt/Snapshot error status 3). checkpoints.rs:1071-1074 stamps before the copy runs; scheduler.rs:3116 = let mut snapshot = request.terminal_snapshot; releases the row on retire() without clearing last_probe_ns; scheduler.rs:2684-2688 handles record.status == 3 by finishing the request with no observation. Effect: one cancelled client request burns the only probe slot for the next 30s for every concurrent request (FYI the slot is global per Estimate, not per request). Fix: stamp from the Snapshot completion path (scheduler.rs:2689-2696) when the probed key was observed, or clear last_probe_ns on cancel of the probing request.

F4 (Major, charter/design-review compliance): no simulator catalog run (design-review.md:195-208) and no lifecycle check.py/TLA coverage for the terminal-capture decision change (design-review.md:209-230), while design-review.md:234-240 calls this a blocking design failure and 247-251 says disclosure does not excuse skipping runnable CPU checks. PR validation lists only cargo check (4 crates) + unit tests. verification/helios-lifecycle/README.md:273-287 shows terminal_reservations_match_lifecycle_model and check.py --mutations already cover allocate_terminal_capture (precedent #568 extended it); the new early-accept arm is uncovered.

F5 (Minor, claim accuracy): description scenario 2 says both prefill extras and terminal capture skip; only the terminal arm is relaxed. checkpoints.rs:624 still let Some(copy_ns) = self.costs.fresh_duration(GraphKind::Snapshot, 1) else { return (accounting, true, false) }; checkpoints.rs:965 still if self.costs.fresh_duration(GraphKind::Snapshot, 1).is_none() { return Ok(false); } Docs updated only scheduling-runtime-design.md:618-629; core-design.md:1452-1455, helios/README.md:378-379, docs/cli-design.md:696-709 still state the old "unknown/stale snapshot-copy costs exclude extras" rule.

F6 (Minor): stale branch is priced at the retained duration, so a request whose allowance < retained cost skips as work_budget and never refreshes; "at most one probe per TTL" can be zero per TTL indefinitely. Test documents it: checkpoints.rs:4214-4216 (checkpoint_skip_work_budget == 1) with 1_024_000 ns prefill → 51_200 allowance vs 100_000 retained. docs/scheduling-runtime-design.md:622-626 wording "still allows at most one probe per estimate_ttl_ns" is accurate but the practical consequence is undocumented.

F7 (Minor): metric rename/population shift — after the change unknown_cost skips are no longer emitted for the first request each TTL, and work_budget can appear where unknown_cost did (F6); no docs mention the shift (docs/api.md:348-354). Operators' dashboards keyed on unknown_cost≈1/request will see it drop.

PRE-EXISTING / NOT INTRODUCED: refresh_order/last_attempt_ns untouched (cost.rs:820-829) so the funded refresh path is not perturbed; deferred_prefill early return checkpoints.rs:1026-1028 precedes the probe; fraction==0.0 keeps byte-identical behaviour (test checkpoints.rs:4243-4261). No protobuf/metric-schema change verified in the 3-file diff.

#2 [high] Report quotes + sound areas for PR #655

Extra verified quotes for the report:

#3 [high] Research summary

Reviewed PR #655 (head 2d9454f) against its three changed files, their callers (scheduler.rs commit/complete/retire, policy.rs candidate selection and funded refresh, cache_memory.rs (not opened) quotes), and the contracts it touches (docs/scheduling-runtime-design.md, docs/api.md, docs/design-review.md, verification/helios-lifecycle/README.md). Findings are saved in the scratchpad with verbatim quotes; summary of the seven verified issues:

Major

  1. The first probe is priced at zero (cost.rs:803, checkpoints.rs:1050/1077/1095). probe_duration returns Some(0) for a never-measured entry, so the capture can never fail the work-budget check and flare_checkpoint_extra_work_nanoseconds_total — documented at docs/api.md:355 as summing charged predicted copy work — silently under-counts one real GPU copy per TTL. The new test asserts the zero (checkpoints.rs:4161).
  2. The probe can be spent without ever measuring the key it priced (cost.rs:865-872 vs 783-786; policy.rs:900-914, utility.rs:154-158). Observations key on step.batch_capacity, and unmeasured duration == 0 candidates rank ahead of measured ones, while checkpoints.rs:962-967 lets Anchor captures run unconditionally. A coalesced batch>1 Snapshot step therefore burns last_probe_ns and leaves fresh_duration(Snapshot,1) unmeasured. Both new tests use a helper that hardcodes batch_capacity: 1 (checkpoints.rs:1113-1127), so this path is untested.
  3. record_probe at allocation is never reverted when the copy never completes (checkpoints.rs:1071-1074; cancel/preempt via scheduler.rs:3116, error status 3 via scheduler.rs:2684-2688). One cancelled request burns the single global probe slot for every other request for the next estimate_ttl_ns.
  4. Charter/design-review gap: docs/design-review.md:195-230 and 234-240 make simulator-catalog and lifecycle check.py (not opened)/TLA runs blocking for scheduler timing changes, yet validation lists only cargo check plus unit tests; the already-existing terminal_reservations_match_lifecycle_model harness that covers allocate_terminal_capture was not extended for the new early-accept arm.

Minor — description's scenario 2 overclaims (prefill-extras gates at checkpoints.rs:624 and 965 are still strict, and three docs keep the old rule); the stale branch can yield zero probes per TTL indefinitely under a small allowance (test at checkpoints.rs:4214-4216); unknown_cost→work_budget skip-reason migration is undocumented.

Verified sound — no wire/proto/CLI/metric-schema change; last_probe_ns is kept out of refresh_order/last_attempt_ns so funded refresh budgets aren't double-counted; the deferred_prefill guard precedes the probe; fraction 0.0 behaviour is byte-identical; smallest_batch_key stays core- and model-agnostic (and improves on the batch: 1 snippet in the linked issue).

Context for the decider: the linked issue #534 was twice rebutted in-thread as fork-specific (AzallazA/hyperflare-inference PrefillTailMerge), and this PR supplies no cold-boot upstream reproduction — only the three other scenarios — so "is this an upstream defect" remains the open question, separate from the concrete defects above.

#4 [high] Framing, open questions and non-findings for PR #655

FRAMING FOR THE DECIDER

TEST COVERAGE NOTES (verified in diff)

EXPLICITLY CLEARED (no finding)