Architecture report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/056a4ef0-ca6b-4976-80fb-67f861b3ca22.md

Architecture & scope review — PR #540 (helios: cost-refresh recovery, prompt+output SAM copy-drafts, calibrated wide copy-verify)

Head reviewed: 14019718 on base main f377dc85; 25 files, +3968/−119. Lens: architecture and scope — does this belong in the repository, and is the approach right, judged against the charter, AGENTS.md and docs/design-review.md.

Key findings

  1. Blocking (wiring): the wide copy-verify feature is dead on every exported core. heliopause/src/export/binding.rs:201 unconditionally sets draft_source = "MTP", overwriting the value the producer now emits, and that function is the only route from the Python manifest to a wire Execution. Every draft_source = 2 graph is decoded as MTP at load and pruned silently.
  2. Should fix (design): a second proposal-source dimension (GraphDescriptor::draft_source) duplicates the existing speculative_proposal_source, is decoded in four separate places, and makes scheduler cost semantics depend non-locally on which other graphs a core contains.
  3. Should fix (scope): four independent outcomes in one PR against AGENTS.md:198, with combined-stack evidence that cannot be attributed or bisected.
  4. Should fix (docs): two documents state the opposite of the new behaviour — docs/cli-design.md:200-201 says --history-drafts "does not change the graphs", and docs/mtp-design.md:22-40 still describes the shared ring as the mechanism.
  5. Positive: commit 1b0db227 (funded-refresh recovery) is well scoped and correct and could merge on its own today.

Blocking

B1. The export path overwrites draft_source, so copy-only wide graphs never survive export — heliopause/src/export/binding.rs:201

Severity: blocking. The PR's third commit cannot run on the path it is designed for, and the description's compatibility framing ("no Protobuf wire changes and no core re-export required") hides it.

Verified chain:

Fix: derive the enum name instead of forcing it — 1 => "MTP", 2 => "COPY_DRAFT", absent => "MTP" (this preserves loading of cores exported before the field existed, which AGENTS.md:434 requires), anything else => invalid(...). Add one binding::execution round-trip test asserting 2 survives. Note the compatibility direction also argues against the current code: AGENTS.md:434 requires existing cores to keep loading without re-export, and a hard-coded "MTP" is only accidentally compatible because it discards information.

What would settle it: load-and-serve an exported core that contains a draft_source = 2 graph and check describe/selection retains it; impossible from the current suite.


Should fix

S1. A second proposal-source authority with non-local cost semantics — helios/src/execution/manifest.rs:190-192, helios/src/scheduler/cost.rs:190-232, helios/src/scheduler/rounds.rs:755-902

Rules: docs/design-review.md:16 principle 1 ("Keep Helios as simple as possible … introduce differences through prepared layout metadata reusable across models"), principle 3 (shared mechanisms must not branch on capability flags), AGENTS.md:188 ("Reject unsupported abstractions and churn"), AGENTS.md:176-181 (flags, enums and optional paths cannot bypass boundaries).

GraphDescriptor::draft_source (manifest.rs:190-192) duplicates the pre-existing ModelConfig::speculative_proposal_source (helios/src/model.rs:113 (not opened)) and RequestScheduler::proposal_source (scheduler.rs:1044-1050). Four independent decoders now exist for one integer: python.rs:225-233, serving.rs:58-63, selection.rs:144-148, and describe.rs:534 (not opened),778.

The consequences are not local:

Fix: keep proposal source in one place — either carry it on the cost row/step and read it there in is_copy_only_step, or derive the per-shape source from the captured shape — split the packed-duration table into explicit MTP-verify and copy-verify tables so a measured copy shape is never masked, key the cost index by source, and fold the copy candidate loop into the ordinary one. Then selection.rs needs no copy_wide bypass.

Compounding factor: because of B1 this code has never run on its target path; all fixtures are hand-built descriptors.

S2. Documentation states the opposite of the new behaviour — docs/cli-design.md:200-201, 741; docs/mtp-design.md:22-40; docs/scheduling-runtime-design.md

Rules: AGENTS.md:165-166 makes inaccurate documentation a rejection item; docs/design-review.md:12 ("report evidence honestly").

  1. docs/cli-design.md:200-201: "--history-drafts enables host history tracking and feeds continuations into the captured graphs' history inputs; it does not change the graphs." After this PR it does: selection.rs:182-184 computes retain_wide_copy from history + no fixed width, :277-298 retains or prunes draft_source == 2 graphs, :375-380 prunes kernels, :382-396 rewrites speculative_widths (the new test wide_copy_graphs_retain_only_when_history_drafts_enabled asserts [1,6,16,24] vs [1,6]). The table row at :741 likewise describes only shared decoded-history continuation, not the per-request SAM or the graph-set effect.
  2. docs/mtp-design.md:31-39: the mechanism is described as a 65,536-token shared ring with eight/four-token indexes returning "up to seven" continuations, and :26 says it "requires speculative graphs that declare copy-token inputs, which only the qwen3.8-flash MTP graphs do". After this PR the primary source is a per-request prompt+output suffix automaton (helios/src/scheduler/sam.rs:1-37), wired at admission (scheduler.rs:1849-1852) and consulted by RequestScheduler::request_history_proposal (scheduler.rs:1099-1159), with the ring used only on a strictly longer match (:1143-1148). The new bounds are undocumented: min_match_len = 6 (sam.rs:22, raised from 3 here), 131,072-token prompt and output caps (sam.rs:25,28), 512-token boundary overlap (sam.rs:32). docs/mtp-design.md:359 lists draft_source in a field table but never explains COPY_DRAFT or wide copy-verify.
  3. docs/scheduling-runtime-design.md is updated only for funded refresh (the diff touches :407-500); it documents neither draft_source, nor the copy/MTP packed-duration split (cost.rs:190-208), nor the new strictly-tighter-batch pruning rule (policy.rs:221-254), and its module index (:6-12) omits the new helios/src/scheduler/sam.rs.

Fix: correct those statements and add one short section per mechanism; nothing else needs new docs.

S3. Scope: four independent outcomes in one PR — 25 files, +3968/−119

Rule: AGENTS.md:198 "Keep each PR focused on one coherent outcome and describe its problem, resulting behavior, validation, and material limitations"; docs/design-review.md:125 principle 15 (reject scope expansion); charter "solve the right problem in the right place … smallest footprint in shared code" and "bring real evidence".

The description's own commit list is four unrelated outcomes: (1) 1b0db227 funded-refresh recovery in the refresh ledger; (2) 450012d1 a new 1,606-line helios/src/scheduler/sam.rs plus admission wiring and packing.rs/runtime.rs changes; (3) 9caba2c7 wide copy-verify graphs — new manifest field, Python producer, selection/catalog/cost/rounds/serving; (4) 14019718 padding dominance in shared policy (policy.rs:119-197,221-254) plus DEFAULT_MIN_MATCH_LEN 3→6 (sam.rs:22).

Why it matters: commit 4 changes behaviour for every speculation user, while 2–3 affect only cores carrying copy inputs; the headline live numbers ("+12.9% tok/s", "3.078 → 3.650 emitted tokens/round") are combined-stack, and the max_b == C padding table cannot be attributed to commit 4 alone, so a regression in any part cannot be bisected. Commit 1 is a self-contained defect fix with real CPU evidence and could merge today.

Fix: split into (a) refresh recovery, (b) padding dominance + min-match-length, (c) SAM + wide copy-verify. If kept together, report per-commit live measurements.

S4. Unpinned calibrated constants in shared policy — speculation.rs:15-21, rounds.rs:766, sam.rs:22

Rule: charter "Be explicit and pin everything. No magic defaults… Benchmarks, tests, or feature flags don't override architectural rules"; AGENTS.md:187.

WIDE_COPY_PRIOR_RATE = 0.88 (speculation.rs:15), COPY_STEP_PRIOR_WEIGHT = 4.0 (:20), COPY_DEPTH_SHRINK_WEIGHT = 2.0 (:21), base_mtp_drafts.saturating_add(3) (rounds.rs:766), and DEFAULT_MIN_MATCH_LEN = 6 (sam.rs:22, changed here) all steer scheduling decisions, and only the last is argued in the description — from a single 512-token repetitive code-edit prompt. 0.88, 4.0, 2.0 and the +3 have no stated derivation anywhere in the tree, and :139 derives a confidence bound from 20.0f64.ln() with no explanation.

Fix: give the derivation for each in docs/scheduling-runtime-design.md beside the new copy section, or promote the policy-relevant ones to named PolicyConfig fields with documented defaults.


Nits


Positive: the funded-refresh commit is clean

Commit 1b0db227 is correctly scoped and architecturally sound and needs no change from this lens:


Open questions for maintainers

What I could not verify