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

Raw Markdown for agents: https://autobot.eidonix.com/p/507a16f7-914c-4e87-9e6d-fc2e24227c16.md

#1 [high] F1: extra-work metric/allowance no longer spans the preserved interior split (Major)

Severity: Major (contract + metric span).

Evidence — the whole extra-work accounting for an interior anchor is cut.split_ns:

So for preserved requests extra_spent_ns and stats.checkpoint_extra_work_ns gain 0 for the interior split, while the GPU still stops prefill at raw_anchor and launches a tail prefill (that is the PR's own disclosed Turn-1 TTFT cost: 5.83-8.98s -> 7.54-9.25s).

The flag's documented contract and the exported metric both claim to cover exactly that work:

Impact: (a) the fraction no longer bounds checkpoint-induced prefill work for reasoning prompts, so an operator who lowers/strictens it sees no effect and gets a counter that says 0; (b) any dashboard/alarm on checkpoint_extra_work_nanoseconds_total under-reports by exactly the interior split; (c) checkpoint_skip_work_budget (checkpoints.rs:935) also stops firing at the anchor for these requests.

Fix: keep charging the predicted split_ns into reserved_ns/extra_spent_ns/checkpoint_extra_work_ns for the preserved anchor (budget it as already spent) and only skip the affordability decision; or add a distinct counter (e.g. checkpoint_unbudgeted_split_nanoseconds_total) plus a doc line in all four docs stating the preserved anchor's split is excluded. Do not leave the metric name/doc claiming coverage it lost.

#2 [high] F2: preserved turns emit a second charged snapshot row per turn — undisclosed capacity cost (Major)

Severity: Major (memory amplification + PR-description accuracy).

The preserved branch only skips the split charge; control still falls through into the optional-candidate loop:

Result: two snapshot rows per preserved turn (interior Anchor + prompt-end Endpoint), with the Endpoint copy charged (copy_ns) to the same allowance. On main, when the interior anchor was unaffordable the fallback put the anchor at prompt_tokens, so request.prompt_tokens != anchor was false and no second row was emitted — cuts.len() == 1.

The PR's own table proves it and the description never mentions it: ckpt_caps end 60->96, 64->96, 61->96 (+36 = exactly one per turn at 4 turns x 6 concurrency x 2 trials x ... i.e. one extra Endpoint per reasoning turn) and the new unit test pins assert_eq!(sel.cuts.len(), 2); (helios/src/scheduler/checkpoints.rs:4818).

Impact: per-turn snapshot rows double for the common reasoning-served workload; on a snapshot-constrained deployment this is direct GPU/host memory amplification, and docs/core-design.md:1448-1454 (as edited) still says the preserved anchor is retained "without charging its split" with only the anchor copy described, never the added Endpoint row. The description's "What" bullet enumerates only the split-charge removal.

Fix: in the preserved branch either return (accounting, false, false) right after pushing the anchor cut (one row per turn, matching main's row count), or state in the PR body and in all four docs that a distinct prompt-end Endpoint is now also captured and charged for preserved turns, plus a measured snapshot-capacity number.

#8 [high] Research summary

Reviewed PR #697 at head bfae28a across all 16 changed files plus their callers and contracts. The core mechanism is correct and the problem it repairs is real (verified exact-prefix equality in helios/src/cache.rs:552-579, and that #660's parent disclosed this exact loss). I report six findings, two of them Major-severity contract/system-level gaps the PR body does not disclose.

Major — F1, metric and allowance span shrank silently. The preserved branch sets anchor_split_ns = 0 (helios/src/scheduler/checkpoints.rs:620-623), and the only place an interior anchor's split is charged is cut.split_ns (:944-949), which also feeds the exported checkpoint_extra_work_nanoseconds_total (helios/src/server/metrics.rs:852 (not opened)). The GPU still stops prefill at raw_anchor and launches the tail prefill — that is the PR's own disclosed Turn-1 TTFT cost — but neither extra_spent_ns nor the counter records it, while docs/cli-design.md:696-698,712-713 still claims the fraction "bounds optional checkpoint work" and that "extra work includes ... additional prefill caused by splitting chunks."

Major — F2, an undisclosed second charged snapshot row per preserved turn. The preserved branch returns before only the split decision, not before the optional-candidate loop, so the prompt-end Endpoint is still added and charged (cuts.len() == 2, pinned by the new test). The PR's own table shows ckpt_caps end 60→96 / 64→96 / 61→96, one extra row per reasoning turn, with no capacity cost discussed anywhere.

Major — F3, preserved turns never reach the work-budget backoff. budget can only be set inside the loop the preserved branch bypasses, so checkpoint_skip_work_budget and the snapshot-waiting gate stop applying; this is the unnamed mechanism behind the Nemotron 90 → 229 prefill-launch increase the PR lists as unexplained queueing.

Minor: F4 (preserve_message_anchor is a default-false bool across three structs, against docs/design-review.md:58-61, though model-independent and charter-compliant in spirit; no Design-Signed-Off-By trailer), F5 (headline A/B not reproducible and no in-repo test drives an actual Turn-k → Turn-k+1 checkpoint lookup), F6 (OutputStart::ToolBody listed but untested).

Explicitly sound: predicate consistency across all three anchor sites, readmission preservation, stale-latch clearing, zero-fraction strict fallback, no hot-path regression, no wire/CLI/ABI change, and consistent docs across all five locations. Details and citations are in the scratchpad (entries 1-7).

#3 [medium] F3: preserved path can never set budget/block flags, so optional captures stop backing off under contention

Severity: Major (concurrency / bounded-progress under mixed load).

checkpoint_selection_uncached returns (accounting, unknown, budget), where budget = true records work-budget skips. The preserved branch returns early at helios/src/scheduler/checkpoints.rs:620-623 before the loop that can set budget = true (it is only set at :755 budget = true; continue; inside the candidate loop). Because the preserved branch also stops charging split_ns (see F1), accounting.extra_spent_ns and available (allowance(prefill, fraction), :686) are unaffected by the anchor, so the Endpoint copy always fits for reasoning turns.

Consequence for the mixed-workload case the PR itself measures: on NVIDIA-Nemotron-3.5-Bolt-74B-A9B-24GB-FLARE (max_active = 4) the PR reports prefill launches going 90 -> 229 and Turn 2+ median TTFT +8.0% at C = 6. checkpoint_anchor_waiting / checkpoint_skip_work_budget exist precisely to keep optional captures from occupying decode/prefill slots when resources are scarce; preserved requests now bypass the budget signal for their anchor and add a second row, so under a queue they hold two snapshot rows and take two prefill chunks with no extra-work gate at all — the mechanism the PR reports as a regression but does not attribute.

Fix: make the preserved path participate in the same admission gate — keep computing split_ns, charge it to reserved_ns for bookkeeping, and let the anchor choice ignore affordability while the block/budget path stays reachable; or document the queueing regression as an accepted cost of the rule with the mechanism named. Currently the PR lists the 90 -> 229 launch increase as "disclosed but unexplained" queueing.

#4 [medium] F4: default-false boolean opt-in across three structs vs design-review.md:58-61; no Design-Signed-Off-By trailer

Severity: Major (wrong layer / design-review principle 3) — but note the charter also says to judge on merits.

preserve_message_anchor is precisely the shape docs/design-review.md:58-61 says to reject: "Reject per-model boolean policy flags, including supports_*, can_*, and default-false opt-ins. Enums, callbacks, schema names, and metadata fields cannot serve as alternative model allowlists. Review each member and its consumers for a concrete meaning independent of model identity."

The flag is derived in the server layer from output-parser state and consumed in the scheduler:

Mitigating: the meaning is model-independent (all think-tag/recipient/content-header dialects), no model-name branch, and the parser state is already prepared metadata. And docs/design-review.md:49-52 says scheduling must "use prepared metadata ... to express model-dependent behavior" — which this does.

Better placement is available at lower footprint: the scheduler already receives message_boundaries and could receive the reasoning-open fact on the same prepared-metadata path instead of a new pub bool on three structs; or the server could pass the already-existing grammar_reasoning/OutputConfig rather than a bespoke scheduler flag. Concrete fix: fold the boolean into an existing prepared metadata struct passed to admit() (e.g. an AnchorPolicy enum) so RequestSpec/LiveRequest/Prompt do not each gain a hard-coded bool, and add one sentence to the PR body justifying it against principle 3 by name.

Also flagged: Design-Signed-Off-By: trailer (design-review.md:294-311) is a per-commit requirement; the PR body does not mention it and head bfae28a shows no CI, so it could not be verified here.

#5 [medium] F5: headline A/B not reproducible; no test exercises the actual reuse path

Severity: Major (charter #210 evidence requirement) — inherited from dossier but re-verified against the diff.

Verified in-repo: the two performance tables have no harness, no command line, no raw logs, and the live binaries were built from 298d3e68, not head bfae28a. This repo's own comparators name the harness explicitly, so the omission is inconsistent with house standard.

What IS verifiable in-repo and passes:

Test gap worth naming: no in-repo test drives an actual second turn that hits the retained checkpoint through PrefixCheckpointCache::lookup. The new tests pin anchor-endpoint selection and split_ns == 0 only; non_preserved_continuation_with_reused_prefix_still_budgets_interior_anchor (checkpoints.rs:4864-4925) asserts request_anchor_endpoint(...) == Some(896) but never publishes a Turn-k checkpoint at 896 and looks it up from Turn k+1. The causal claim "Turn k's checkpoint is an exact prefix of Turn k+1" therefore rests entirely on the unreproducible live A/B.

Concrete fix: add one integration test that runs turn k (preserved) through prefill+publication, then admits turn k+1 with the stripped-reasoning history and asserts lookup().consumed_tokens == raw_anchor (i.e. non-zero reuse); and either link the tokbench-style reproducer or state the exact command lines.

#7 [medium] Soundness notes: what checks out (consistency, readmission, latch, zero fraction, no ABI change)

Areas checked and found SOUND (state plainly, do not invent issues):

  1. Ordering/consistency across the three anchor sites. budget_interior_anchor (helios/src/scheduler/checkpoints.rs:469-471) is called from all three: request_anchor_endpoint :480, checkpoint_selection_uncached :621, promote_request_anchor :908. The three cannot disagree because the predicate is a pure function of policy.checkpoint_extra_work_fraction and request.preserve_message_anchor, both immutable for the life of a LiveRequest (configure_policy refuses once any request is admitted: helios/src/scheduler/policy.rs:225-228). So no policy-flip race between the latch site and the selection site.

  2. Readmission / preemption. preserve_message_anchor is set on LiveRequest only in admit() (helios/src/scheduler.rs:1852) from spec, and Incoming::spec() (helios/src/server/runtime.rs:288) re-emits it on every readmission from the retained Prompt, so preemption (worker.park() -> readmit) cannot lose it. Pinned by the new test at helios/src/server/runtime/phase_tests.rs:8414-8421.

  3. Stale latch after a grown prompt. budgeted_anchor is keyed on (raw_anchor, prompt_tokens, chosen); the preserved branch clears it (checkpoints.rs:622) and promote_request_anchor refuses to re-latch (:908-912), so a latch left by treating the same request as non-preserved cannot survive. Asserted at checkpoints.rs:4826-4838 with extra_spent_ns = 1_000.

  4. Zero fraction. fraction == 0.0 short-circuits the predicate to true, so strict zero-split fallback is preserved even for open-reasoning prompts, and if fraction == 0.0 { return ... } at :675-677 still caps row count. Matches the claimed behavior and the docs edit.

  5. No new locking, no new allocation on a hot path. The added work is one float compare plus one bool read, all in already-&self paths. promote_request_anchor is called per submitted lane (helios/src/scheduler.rs:2510) and for preserved requests now returns at :480-483 before prefill_catalog_costs (:526) — strictly cheaper, not more expensive, than main's path.

  6. No wire/proto/ABI/CLI change. RequestSpec is internal to helios; no occurrences under flare/. Users get no new flag; the only opt-out is --scheduler-checkpoint-extra-work-fraction 0.0, which is blunter than #660's documented 0.15 workaround (it also drops all optional Message cuts and the terminal Endpoint) — worth stating in the PR body but not a defect.

  7. The why is real and the mechanism is verified: helios/src/cache.rs:552-579 requires exact PrefixKey equality at consumed_tokens, so a checkpoint carrying a stripped reasoning tail cannot match turn k+1. #660's parent PR disclosed this exact loss, so this is a genuine regression repair, not speculative.

  8. Docs are consistent across all four files + README (docs/cli-design.md:696-714, docs/core-design.md:1436-1457, docs/scheduling-runtime-design.md:664-674, helios/README.md:370-386); the only inaccuracy is the missing second-row statement (F2) and the extra-work claim (F1).

  9. scripts/scheduling_sim/ genuinely does not model anchor selection (no checkpoint/anchor file), so the "N/A" claim for the simulator holds; the TLA+ mutation needle for budgeted_anchor remains unique after the new budgeted_anchor = None at :622 because the needle is the full Some(...) line at :649.

#6 [low] F6: ToolBody listed but untested; anchor cache-ready check bypassed unconditionally for preserved requests

Severity: Minor (claim accuracy).

The PR's "What" says: "Set preserve_message_anchor ... to output.as_ref().is_some_and(|o| o.content.start == OutputStart::Reasoning) ... covering ... OutputStart::ToolBody ..." — the description lists OutputStart::ToolBody among the non-preserved starts, but the new phase test (helios/src/server/runtime/phase_tests.rs:8348-8589) covers only Reasoning, Content (plain + closed-think), RecipientHeader (ATEM), RecipientFrame (ATEM add_generation_prompt:false + TMLv0), and Completions. No ToolBody case. Fault mutation B (widening to != Content) would not be caught for ToolBody.

Concrete fix: either add a ToolBody fixture assertion or drop ToolBody from the description's enumerated list.

Also minor and worth confirming: request_anchor_endpoint now returns at checkpoints.rs:478-483 before the cache-ready check at :504-519 for preserved requests, so a preserved request gets no history.key_at -> cache.ready_by_prefix verification of its anchor. That matches main's existing nonzero-fraction best-effort branch (main fell into the same fraction > 0.0 keep-raw path when costs were unknown, :547), so it is not a regression — but it is now unconditional rather than cost-conditional.