Correctness report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/b3e2a109-5a55-487b-a4f9-9c02d5c3e576.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,98-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 draft depth beyond the learned drafts, and helios/src/runtime_core/selection.rs:277-298 prunes them.
  2. Should fix — the same line silently 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-96 — 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 Progruft enum name string; python.rs:225-233 reads an integer u32 (1/2, 0 = none). Nothing in the test suite round-trips a manifest containing draft_source = 2 through binding::execution, which is why this slipped.
  4. Three other candidates were investigated and dropped as non-defects or unreachable (details in "Candidates checked and dropped"). One remains an open question needing a test (SAM across preempt/re-admit).

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 98-108 validate it and enforce the copy-only invariants (confidence_width == 0, no speculative_prefix_limits); line 319 emits it into the manifest as draft_source=signature.draft_source. The PR description states these graphs carry draft_source metadata 1 = MTP, 2 = COPY_DRAFT.

Two consumers, only one updated.

Why it matters — the graphs are then pruned at load. helios/src/runtime_core/serving.rs:58-63 faithfully decodes the wire enum back (1 → Mtp, 2 → Copy), so the loss happens 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 35ab143a — 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.

Fix: preserve the field. Either pass the incoming JSON value through (graph.get("draft_source")), or derive it explicitly: emit 2 when the manifest said 2, 1 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::CopyDraft as i32 — that is also what would settle this empirically (I could not run the Rust test suite in this review).

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

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

heliopause/src/python.rs:225-233 treats an unknown draft_source as a hard error; 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, 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. Both are legal for their own reader, but nothing ties them together and there is no test in the PR (or found in the tree) that exercises draft_source through binding::execution — the tests added by the PR cover the Python side (tests/preparation/test_execution.py:299-302 (not opened), tests/preparation/test_packed_speculative_contract.py:54 (not opened)) and the load side (helios/src/runtime_core/selection.rs:1896-1937, helios/src/model/tests.rs:1944 (not opened), helios/src/scheduler/tests.rs:4183 (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 list from research; I read them in context this session and they are not defects:

Open question — needs a test, not a code reading

PromptOutputSAM across preempt / re-admission (new helios/src/scheduler.rs, admission builds sam from spec.prompt; tokens pushed in record_decoded_token, complete_inner and the decoded-sequence append path). resume_decoded_sequence restores decoded_sequence but does not rebuild sam. If the readmitted spec.prompt already contains tokens generated before the preempt, they are indexed twice (once in the immutable PromptSAM, once in the dynamic OutputSAM), and request_history_proposal could propose a continuation that repeats text. Because PromptSAM is only a source of proposals, the worst case is wasted verification slots and reduced acceptance, not incorrect committed tokens — but I could not show from code alone whether server/runtime.rs re-admission passes the original or the extended prompt. Settle it with the brute-force oracle already present in the helios/src/scheduler/sam.rs test module: admit, generate more than min_match_len tokens, preempt, readmit, and compare propose() against the oracle.

Coverage and what I could not verify