Review of PR #540 — helios: cost-refresh recovery, prompt+output SAM copy-drafts, and calibrated wide copy-verify
Head e5a69669. Lens: correctness (callers, configurations, state transitions, compatibility with persisted artifacts).
Verdict: no blocking issues; one should-fix and one nit.
Key findings
- Should fix — the scheduler capability tables omit
draft_source, so an MTP graph and a copy graph at identical B/D/W/P are conflated bygpu_prefix_allocation. This PR deliberately allows such coexistence (cost.rs:170-174, testunmeasured_mtp_and_measured_copy_coexist_at_identical_shape_and_preserve_packed_durationatcost.rs:531-586), so the omission contradicts the design the PR introduces. - Nit —
ActionCosts::packed_round_durationreturnsNonewheredocs/scheduling-runtime-design.md(not opened) promisesSome(0), because its fallback arm tests "the MTP table is entirely empty" rather than "no MTP covering shape". - Verified fixed — the prior export-path blocker (
heliopause/src/export/binding.rsoverwritingdraft_sourcewithMTP) is gone; copy cores can now round-trip. - Verified non-defects — preempt/re-admit SAM state,
RefreshState::idleremoval,refresh_ordertwo-tier ordering, packing source tie-breaks,ProposalSource::from_wiresharing.
Prior blocker verified fixed: exported cores preserve draft_source
heliopause/src/export/binding.rs:201-216 now derives the wire enum from the manifest field — None | 0 | 1 | "MTP" → MTP, 2 | "COPY_DRAFT" → COPY_DRAFT, anything else → Err(invalid("unsupported graph draft_source")) — and rejects COPY_DRAFT on a graph whose kind != "speculative" (including mixed). This matches the producer check at ignition/preparation/execution.py:102-108 (draft_source must be 1/2, 2 only on speculative graphs) and the load-time reader at helios/src/runtime_core/selection.rs:244-247 (![1, 2].contains(&graph.draft_source) for speculative graphs, graph.draft_source != 0 rejected otherwise). The round-trip test execution_preserves_mtp_and_copy_draft_source_and_rejects_unknown (binding.rs:1467-1510) covers 0, 1, 2, unknown integers, unknown strings and mixed+copy.
This is the charter's compatibility standard ("verify that existing data, artifacts, and exported cores still load"): a W=8-only core without copy graphs still exports and loads unchanged, and a core that does carry copy graphs now survives the copy_wide retention at selection.rs:277-298.
Should fix — capability tables omit draft_source, conflating identical-shape MTP and copy graphs
helios/src/model.rs:358-360pushes(graph.kind, batch_capacity, draft_tokens, token_capacity, packed_token_capacity, prefill_capacity)intocapabilities.completion_inputs, andhelios/src/model.rs:369-370pushes(batch_capacity, draft_tokens, token_capacity, packed_token_capacity, allocation)intocapabilities.speculative_allocations. Neither tuple carriesdraft_source.- This PR makes identical-shape coexistence a supported configuration:
helios/src/scheduler/cost.rs:170-174only rejects duplicateKeys includingdraft_source, andcost.rs:531-586asserts an unmeasured MTP entry and a measured copy entry coexist atB1/D7/W8/P8and keep separate packed durations.Selectionlikewise dedupes ondraft_source(selection.rs:299-312) and the depth-collapse key includes it (selection.rs:301-312). - Copy-only graphs cannot be GPU-allocated:
helios/src/model/catalog.rs:123-131rejects a copy-only speculative graph that declaresconfidence_width != 0or anySpeculativePrefixLimitinput, andselection.rs:236-237,282requiresconfidence_width == 0for retained wide copy graphs — soscheduler_capabilities_with_manifeststamps themPrefixAllocation::Host(model.rs:363-368). - Consequence A (pricing):
gpu_prefix_allocation(batch, drafts, width, packed)(helios/src/scheduler/rounds.rs:443-446) scans without a source, so an MTP graph at(B, D, W, P)with GPU prefix limits makes an identically shaped copy graph look GPU-allocated. Thenprefix_lengths_with_values(rounds.rs:475-491) takes thegpubranch and prices the copy step withspeculative_curve(MTP acceptance,rounds.rs:415-436) instead of the copy curve, andRequestScheduler::commit(helios/src/scheduler.rs:2496-2500) feeds those lengths intoexpected_tokens(scheduler.rs:2503-2515) for a copy-only step (is_copy_only_step,scheduler.rs:1196-1199), so copy-survival expectations are computed from the MTP profile the PR deliberately isolates elsewhere (scheduler.rs:2786-2800excludes copy-only completions from MTP population and calibration). - Consequence B (hard error):
complete_with_survival(helios/src/scheduler.rs:2595-2598) rejects completion with"speculative round completion requires its terminal confidence sidecar"whenever the submission is speculative withdraft_tokens > 0andgpu_prefix_allocationis true. A copy-only step has no confidence sidecar by construction (it is required to haveconfidence_width == 0), so under an MTP GPU-allocated graph at the same geometry the copy round would be refused outright byhelios/src/server/runtime.rs:1688-1699(which takes thecomplete_with_survivalbranch whencompletion.proposal_confidenceisNone). No shipped core is known to export that pair today, which is why this is not blocking, but it becomes a request-failing path the moment one does — and the PR advertises exactly that configuration. - Fix: add
draft_sourceto both tuples athelios/src/model.rs:358-370(and to thespeculative_allocationstype athelios/src/scheduler.rs:108), thread it throughgpu_prefix_allocation,rounds.rs:937(the per-shape packing site) andscheduler.rs:2496/2596, and passstep.draft_source/shape.draft_sourceat each call site. Notegraph.draft_sourceisOption<ProposalSource>onGraphDescriptor; the existingcost::canonical_draft_source(cost.rs:50) already normalizes it for non-speculative kinds and can be reused so the key matchesKey::prepared(cost.rs:159-173). - What would settle it: a load test with an MTP graph and a copy graph at identical
B/D/W/P, GPU allocation on the MTP graph, asserting (a) the copy step is not reported GPU-allocated and (b) a copy-only completion without a confidence sidecar succeeds. Current tests buildspeculative_allocationsby hand with the 5-tuple (policy_tests.rs:2952(not opened),3655-3704,4487), so the shape of the table is only exercised throughmodel.rs.
Nit — packed_round_duration returns None where the docs promise Some(0)
helios/src/scheduler/cost.rs:237-252: with copy holding an unmeasured covering shape (Some(0)), MTP holding no covering shape, and the MTP table non-empty at any other batch or width, the arm at :244-249 fails (it requires every MTP row to be all-None) and the match falls through to None. docs/scheduling-runtime-design.md (not opened) describes the combined lookup as returning zero "only when covering shapes exist without a positive measurement". The practical effect is confined to missing normalization evidence, since the consumer filters > 0 (helios/src/scheduler/service.rs:158), but the predicate should be "an MTP covering shape exists", i.e. (None, Some(0)) if mtp_covering.is_none().
Confirmed non-defects (checked in context)
- Preempt / re-admit SAM has no double-feed.
PromptOutputSAMis built at admission fromspec.prompt(scheduler.rs:1843-1846);server/runtime.rs:1550-1553and the park path extendincoming.prompt.tokenswith generated tokens before re-admission, so the rebuilt SAM covers prompt+history exactly once, and only the ring handle is carried across.push_tokenis fed fromrecord_decoded_token(scheduler.rs:1217-1228) and from the post-completion event loop (scheduler.rs:3007-3012), each guarded bydecoded_history.is_some(), which is the same predicate that gates SAM construction. Covered bypreempted_request_reindexes_generated_history_into_sam_on_readmission. Residual limitation: output history beyond the 131,072-token trailing cap is not reindexed, which is the documented cap behaviour. RefreshState::idleremoval (scheduler.rs:1264-1273;refresh.rsnow exposesabortonly) matchesdocs/scheduling-theory.md(not opened)'s statement that Helios retains bounded earned credit through idle and discards positive credit only on abort.refresh_ordertwo-tier ordering (policy.rs:1359-1393) still selects the highest zero-duration expected value among unattempted stale shapes, matching the PR body; the(bool, u64)key's second tier keeps structural tie-breakers deterministic.BoundGraph::matches_step(model/packing.rs:40-53) applies thedraft_sourcetie-break consistently for bothsemantics(:302) andpack_step(:389).ProposalSourcewire handling is unified:heliopause/src/python.rs:225-233(not opened) andhelios/src/runtime_core/serving.rs:55-58(not opened) both go throughProposalSource::from_wire(scheduler/speculation.rs:55-62(not opened)), andheliopause/src/export/binding.rs:201-216matches it.is_copy_only_stepnow reads the step (scheduler.rs:1196-1199) rather than inferring from the cost table, andcommitguards it withself.proposal_source == Mtp(scheduler.rs:2501-2502) so a copy-source core is unaffected.
Coverage and limits
Read in context: helios/src/scheduler.rs (admission/SAM, request_history_proposal, record_decoded_token, commit, complete_with_survival, post-completion loop), scheduler/{cost,refresh,policy,rounds,speculation,packing,service}.rs, helios/src/model.rs:320-374, model/{catalog,packing}.rs, runtime_core/selection.rs:130-320, runtime_core/serving.rs (not opened), server/runtime.rs (completion/plan/park paths), heliopause/src/{export/binding,python}.rs, ignition/preparation/execution.py, and the four touched design docs.
Not run: the Rust suites (cargo test with runtime-core,server and default features), the Python preparation tests, the SAM release microbenchmark, and any live GPU path including flare run, power-limit cost-refresh transitions, wide copy-verify export/replay and SM121/GB10. Both findings are from code reading. The capability-key finding needs the load test described above to be closed; the nit is provable from cost.rs:244-249 alone but harmless in current consumers.
Open questions
- Does any planned recipe actually export an MTP speculative graph with GPU prefix limits at the same
(batch, drafts, width, packed)as a copy graph? If not, the should-fix is latent; if yes, Consequence B is a hard completion failure and should be treated as blocking before shipping that recipe. - The PR body states per-commit GPU A/B, wide copy-verify export/replay (
W=16/W=24) and power-limit refresh transitions were not run on hardware; nothing in the code contradicts the described behaviour, but the copy-only cohort selection inrounds.rs:880-936(gate at:905onWIDE_COPY_MIN_MATCH_LENand:911on beating the MTP depth) has only unit-level coverage in this tree.