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
- Blocking (wiring): the wide copy-verify feature is dead on every exported core.
heliopause/src/export/binding.rs:201unconditionally setsdraft_source = "MTP", overwriting the value the producer now emits, and that function is the only route from the Python manifest to a wireExecution. Everydraft_source = 2graph is decoded as MTP at load and pruned silently. - Should fix (design): a second proposal-source dimension (
GraphDescriptor::draft_source) duplicates the existingspeculative_proposal_source, is decoded in four separate places, and makes scheduler cost semantics depend non-locally on which other graphs a core contains. - Should fix (scope): four independent outcomes in one PR against
AGENTS.md:198, with combined-stack evidence that cannot be attributed or bisected. - Should fix (docs): two documents state the opposite of the new behaviour —
docs/cli-design.md:200-201says--history-drafts"does not change the graphs", anddocs/mtp-design.md:22-40still describes the shared ring as the mechanism. - 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:
- Producer —
ignition/preparation/execution.py:316-319writesdraft_source=signature.draft_sourcefor every graph with a draft depth (GraphSignature.draft_sourceat:32, validated at:102-108, default 1 = MTP, 2 = COPY_DRAFT). - Clobber — the only route that turns that JSON into a wire
Executionisheliopause/src/export/capture.rs:3158(super::binding::execution(execution, &allocations)→output.index.ranks[0].execution), and insidebinding::execution(binding.rs:136) line 201 runsgraph.insert("draft_source".into(), "MTP".into())for every speculative / mixed-speculative graph, unconditionally, after the producer's value is already in the map.verify_tokenson line 200 is legitimately derived fromtoken_capacity;draft_sourceis overwritten, not derived.maincontains the identical line, so this PR added a producer of the value 2 without teaching the exporter about it. - Loader —
helios/src/runtime_core/serving.rs:58-63maps 1 →ProposalSource::Mtp, 2 →Copy. - Selection —
helios/src/runtime_core/selection.rs:277-298:copy_widerequiresgraph.draft_source == 2(:280), so it is never true. The ordinary speculative branch then requiresgraph.draft_source == source(1) anddraft_tokens <= drafts(:291-292); copy-only wide graphs declare depth 23 (> drafts 7), so they are dropped.retained_widths(:382-391) then publishes widths that no remaining graph implements unlessretain_wide_copyis set — which it is not, becausesource == 1on the MTP branch. - Contract checks —
helios/src/execution/manifest.rs:845-846andhelios/src/model/catalog.rs:123-131both testdraft_source == Some(Copy), so the copy-only contract validation can never fire on an exported core either. - Why it passes CI — the in-process path reads the Python dict directly (
heliopause/src/python.rs:225-233,Some(2) => Copy), and every CPU test constructsGraphDescriptorby hand (helios/src/model/tests.rs:1861-2075(not opened),helios/src/scheduler/tests.rs:4120-4300,selection.rs:1896). Nothing round-trips the field throughbinding::execution; the existing test atbinding.rs:1431-1449never setsdraft_source.
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:
cost.rs:190-208refresh_packed_durationscomputeshas_mtpas an existence scan over all entries; if any MTP packed shape exists (measured or not) every copy packed shape is skipped. Sopacked_round_duration(batch, width)(:210-213) returnsNonefor a measured copy shape in a mixed catalog, andspeculative_duration(rounds.rs:559-568,policy.rs:775) silently loses the copy cost rather than choosing the cheaper of the two.cost.rs:50-58Keycarries no source field, sois_copy_only_step(:223-232) has to look the step's key back up in the table to infer it.cost.rs:151-161prepared()rejects duplicate shapes, so an MTP graph and a copy graph with identical(batch, tokens, prefill, packed, drafts)cannot coexist at all — an accidental restriction created by the missing dimension in the key.rounds.rs:755-902is a second, near-duplicate candidate loop guarded byproposal_source == Mtp && shape.draft_source == Copy && width > 1, with its own gatebase_mtp_drafts + 3(:766) andcurve[position]indexing, duplicating the ordinary loop above it.selection.rs:184, 277-298, 382-396bypass the draft-depth, fixed-width and verification-budget filters for copy graphs, so oneretainpredicate answers two different questions.model/catalog.rs:93-131adds copy-only contract checks keyed off the same field, in a file whose stated role is shape validation.
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").
docs/cli-design.md:200-201: "--history-draftsenables 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-184computesretain_wide_copyfrom history + no fixed width,:277-298retains or prunesdraft_source == 2graphs,:375-380prunes kernels,:382-396rewritesspeculative_widths(the new testwide_copy_graphs_retain_only_when_history_drafts_enabledasserts[1,6,16,24]vs[1,6]). The table row at:741likewise describes only shared decoded-history continuation, not the per-request SAM or the graph-set effect.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:26says it "requires speculative graphs that declare copy-token inputs, which only theqwen3.8-flashMTP 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 byRequestScheduler::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:359listsdraft_sourcein a field table but never explainsCOPY_DRAFTor wide copy-verify.docs/scheduling-runtime-design.mdis updated only for funded refresh (the diff touches:407-500); it documents neitherdraft_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 newhelios/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
helios/src/scheduler/refresh.rs:95-99—pub fn idle(&mut self) {}is now an empty method whose doc comment explains that it does nothing; it is still called fromscheduler.rsand frompolicy_tests.rs:2637 (not opened),2696,2701. Delete the method and its call sites so "idle changes nothing" is a property of the code rather than a no-op function to maintain and reason about.- ~150 lines of SAM API with no production caller —
propose_conditional_continuations(sam.rs:1118-1189, whose doc references a "2-deep pipelined execution" that does not exist in the tree),propose_for_context(:1070-1110),MatchSource/MatchProposal::source,PromptSAM::build,push_slice,from_shared_prompt, and accessors used only by tests.AGENTS.md:188rejects speculative extension points; trim to whatproposeneeds or name the caller. - Evidence gaps the PR itself discloses — copy-only wide graphs (W=16/W=24) were never exported or replayed on a GPU, and cost refresh was never observed across a live power-limit transition; every wide-copy test is a CPU fixture. Given B1, the feature has never run on the path it claims. One load-and-serve of an exported W=8 core plus one core carrying a
draft_source = 2graph would settle bothAGENTS.md:434compatibility and the wiring defect. - Preempt → readmit is untested for SAM state —
helios/src/server/runtime.rs:2068-2110re-admits with generated text appended to the prompt and admission rebuilds the SAM fromspec.prompt(scheduler.rs:1849-1852), whileresume_decoded_sequence(scheduler.rs:1212-1235) pushes only intodecoded_history, neversam. Not proven a defect — the text is back in the prompt, so SAM re-indexes it — but no test covers it.
Positive: the funded-refresh commit is clean
Commit 1b0db227 is correctly scoped and architecturally sound and needs no change from this lens:
cost.rs:31-38addsobserved_compute_duration_ns/timing_refresh_duration_ns, excluding measuredReadinessIntervals::wait_nsfrom timing-refresh credit whileobserved_duration_ns(:21-28) keeps raw physical time for acceptance learning, with awall_nsfallback when GPU timing is absent (refresh.rs:71-93). The two bounds (P <= 0.002/0.998 * O + Dfor timing refresh,P <= 0.01/0.99 * O + Dfor acceptance) remain preserved.refresh.rs:95-99retaining earned credit and negative debt across idle is sound precisely because idle adds neither term.refresh.rs:101-105abortstill discards positive credit.cost.rs:284-293refresh_orderreplaces the nanosecond timestamp with a two-tier(bool, u64)key, andselect_plan'scompare_refresh(policy.rs:1333-1338,1369-1372) ranks by zero-duration expected value — this fixes the real "probe the older/smaller shape first" defect.
Open questions for maintainers
- Q1: Was the wide copy-verify path approved in advance?
docs/design-review.mdprinciple 1 requires prior explicit approval for a new captured-graph operation family, and this PR adds a graph-level source enum, four new copy input buffers and a copy-specific contract. Nothing in the description records such approval. - Q2: Is
cost.rs:190-208'shas_mtpmeant as "copy shapes only compete when the core contains no MTP packed shape"? No comment states it and no test asserts mixed-catalog cost semantics. - Q3: Can commits 2–4's live numbers be reproduced without commit 1? Not determinable from the repository.
What I could not verify
- No CI on head
14019718; the reported 619 / 1,710 test counts, the 120 randomized SAM oracle trials and the SAM microbenchmark were not independently executed here. - All live 4× RTX PRO 6000 numbers are unreproducible in this environment; I could only establish that they depend on several commits at once.
- The Python catalog generation was read only where
draft_sourceplumbing crosses it; I did not audit the rest ofignition/preparation.