Correctness report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/27f0b7c5-e42e-40a4-b3de-60a22ebc7cad.md

Review of PR #540 — helios: cost-refresh recovery, prompt+output SAM copy-drafts, and calibrated wide copy-verify

Lens: Correctness — does the change work everywhere it reaches (callers, configurations, platforms, state transitions, compatibility with existing artifacts)?

Key findings

  1. Blocking — the wide copy-verify feature is dead on the core-export path. heliopause/src/export/binding.rs:196-202 rewrites draft_source to "MTP" for every speculative graph while converting the preparation manifest to the wire Execution. The PR adds draft_source = 2 (COPY_DRAFT) to that manifest on the Python side (ignition/preparation/execution.py:32,102-108,316-319) and teaches the in-process reader to honour it (heliopause/src/python.rs:225-233), but the export path is untouched and overwrites it. Every exported core therefore re-imports its wide copy graphs as MTP graphs with a draft depth beyond the learned drafts, and helios/src/runtime_core/selection.rs:277-298 prunes them.
  2. Should fix — the same line coerces instead of rejecting. The export path performs no validation of draft_source; the sibling reader does (python.rs:230 returns "unsupported graph draft_source"). Because the field is also the only key that triggers the copy-only contract checks (helios/src/execution/manifest.rs:845-846, helios/src/model/catalog.rs:93-131 — no GPU confidence, no speculative_prefix_limits, four copy input buffers), a mislabelled graph is not merely dropped: it skips those checks.
  3. Nit — two encodings for one field, no round-trip test. binding.rs:201 writes the prost_reflect enum name string; python.rs:225-233 reads an integer u32 (1/2, 0 = none). Nothing in the suite round-trips a manifest containing draft_source = 2 through binding::execution, which is why this slipped through.
  4. Three other candidates were investigated and dropped as non-defects or unreachable (details in "Candidates checked and dropped"). A fourth — SAM state across preempt/re-admit — was settled from code as a behaviour note, not a defect (see below), and still deserves a regression test.

1. Blocking — exported cores relabel copy-draft graphs as MTP and drop them

Where: heliopause/src/export/binding.rs:196-202

if kind == "speculative" || kind == "mixed" && speculative {
    if !graph.contains_key("draft_tokens") {
        return Err(super::invalid("speculative graph lacks explicit proposal depth"));
    }
    graph.insert("verify_tokens".into(), width.into());
    graph.insert("draft_source".into(), "MTP".into());   // <-- unconditional
}

What the PR does on the producing side. ignition/preparation/execution.py:32 adds draft_source: int = 1 to GraphSignature; lines 102-108 validate it and enforce the copy-only invariants (confidence_width == 0, no speculative_prefix_limits, speculative graph kind); lines 316-319 emit it into the manifest together with draft_tokens/verify_tokens. The PR description states these graphs carry draft_source metadata 1 = MTP, 2 = COPY_DRAFT, and the wire enum matches: helios/proto/runtime_core.proto:854 (NO_DRAFT = 0; MTP = 1; COPY_DRAFT = 2), field declared at runtime_core.proto:842.

Two consumers, only one updated.

Why it matters — the graphs are then pruned at load. helios/src/runtime_core/serving.rs:58-63 (not opened) faithfully decodes the wire enum back (1 → Mtp, 2 → Copy), so the loss happens entirely on the write side and is invisible downstream. In helios/src/runtime_core/selection.rs:

A wide copy graph arriving with draft_source = 1 fails copy_wide, and then the ordinary MTP branch at lines 291-293 rejects it because graph.draft_tokens.is_some_and(|depth| depth <= drafts as u32) is false — the whole point of those graphs is depth > base_mtp_drafts (e.g. W=16/W=24 with 15/23 drafts versus 7 MTP drafts). So the graph is removed from the catalog and the wide copy-verify feature — the headline of commit 9caba2c7 — never runs on any core produced through export. The failure is silent: there is no diagnostic distinguishing "core was built without copy graphs" from "core's copy graphs were relabelled and pruned", which will make the limitation in the PR body ("copy-only wide graph (W=16/W=24) GPU export/replay … not benchmarked") very hard to interpret for anyone who tries it on live hardware.

Fix: preserve the field. Either pass the incoming JSON value through (graph.get("draft_source")), or derive it explicitly: emit "COPY_DRAFT" when the manifest said 2, "MTP" for a speculative graph with no field, and reject unknown values the way python.rs:230 does. Add a unit test that round-trips an execution manifest containing draft_source = 2 through binding::execution and asserts wire::Execution.graphs[i].draft_source == DraftSource::COPY_DRAFT as i32; that is also what would settle this empirically (the Rust test suite was not run in this review).

2. Should fix — silent coercion bypasses the copy-only contract

Where: same line, heliopause/src/export/binding.rs:200-201.

heliopause/src/python.rs:225-233 treats an unknown draft_source as a hard error (Some(_) => return Err(... "unsupported graph draft_source")); binding.rs treats every value as MTP. The field is load-bearing for validation as well as selection:

So the coercion does not just drop a feature; it also lets an invalid copy graph through manifest validation, and the two readers now disagree about the same artifact (in-process accepts and validates 2, the exported core says 1). Fixing Finding 1 fixes this too, provided the export path also rejects out-of-range values rather than mapping them to MTP.

3. Nit — divergent encodings, no regression test

binding.rs:201 writes a prost_reflect enum name ("MTP"); python.rs:225-233 extracts an integer from the Python dict. Both are legal for their own reader, but nothing ties them together and there is no test that exercises draft_source through binding::execution — the tests added by the PR cover the Python side (tests/preparation/test_execution.py (not opened), tests/preparation/test_packed_speculative_contract.py (not opened)) and the load side (helios/src/runtime_core/selection.rs around lines 1896-1937, helios/src/model/tests.rs (not opened), helios/src/scheduler/tests.rs (not opened)), not the export conversion. Prefer one encoding for both readers, and add the round-trip test noted above.


Candidates checked and dropped

These were on my research list; they are not defects, verified in context this session:

Settled from code (behaviour note, not a defect) — SAM across preempt / re-admission

The earlier open question — whether the new per-request suffix automaton double-feeds tokens after a preempt/re-admit — resolves negatively:

Therefore no token is indexed twice and propose() cannot emit a self-duplicating continuation. Two consequences worth knowing (not defects): features that depended on the dynamic output side (recency tie-break MatchSource::Output, default_min_match_len freshness, boundary_overlap straddling) degrade to prompt-only behaviour for the remainder of a re-admitted request, and earlier output beyond max_prompt_tokens = 131_072 (helios/src/scheduler/sam.rs:22 (not opened)) is dropped. A preempt→readmit test comparing propose() against the in-module brute-force oracle (helios/src/scheduler/sam.rs (not opened) tests module) would be the right guard, since nothing in the suite exercises this path.

Coverage and what I could not verify