Review — PR #540: helios: cost-refresh recovery, prompt+output SAM copy-drafts, calibrated wide copy-verify
Reviewed at head 14019718 on base main f377dc85: 25 files, +3,968 / −119. Nothing in the PR body or code tried to direct this review; the only instruction-shaped text was the PR's own claims about its behaviour, which were checked against the code.
Key findings
- Blocker — the wide copy-verify feature is dead on the core-export path.
heliopause/src/export/binding.rs:201writesdraft_source = "MTP"unconditionally for every speculative graph, overwriting the value the Python producer now emits, on the only manifest→wire route (heliopause/src/export/capture.rs:3158(not opened)). Every exported core re-imports its copy graphs as MTP graphs with a draft depth beyond the learneddrafts, andhelios/src/runtime_core/selection.rs:277-298prunes them. Because the same field gates the copy-only contract checks, the coercion also lets an invalid copy graph through validation. - Should fix — documents that own the changed semantics state the opposite (
docs/cli-design.md:200-201,741,docs/mtp-design.md:22-40,359,docs/scheduling-theory.md:577-579,714-729,helios/manifest.md:29-53,docs/scheduling-runtime-design.md:6-12,249-254,396-399). - Should fix —
draft_sourcehas a second authority and is missing from prepared-shape identity (cost::Keyatcost.rs:50-58, the shape filter inmodel/catalog.rs:279-293(not opened)), which creates a hard "prepared graphs require unique shapes" rejection for MTP + copy at one geometry and a non-local cost effect (has_mtp,cost.rs:190-208). - Should fix — four calibrated constants steer scheduling with no derivation (
speculation.rs:15-21,rounds.rs:766), and the one constant that is argued (sam.rs:22, 3→6) is argued from a single prompt. - Should fix — evidence: the SAM build cost is reported as a microbenchmark although it runs synchronously at admission (
scheduler.rs:1849-1852), the four bundled outcomes cannot be attributed, and there is no test that loads an already-exported core. - Subtract — ~500–600 of the +3,968 added lines are removable with no behaviour change (duplicated cohort loop, dead SAM API, duplicated match helper, emptied
idle, three-way enum decoding, overlapping end-to-end tests). - Positive — commit
1b0db227(funded-refresh recovery) is well scoped, correct and mergeable on its own today, and the rewritten refresh prose indocs/scheduling-runtime-design.md:425-496matches it exactly.
Blockers
B1. The export path overwrites draft_source, so copy-only wide graphs never survive export — heliopause/src/export/binding.rs:201
Finding. Inside binding::execution (binding.rs:136) line 201 runs graph.insert("draft_source".into(), "MTP".into()) for every speculative / mixed-speculative graph, after the producer's value is already in the map:
// 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 overwrite
}
verify_tokens on line 200 is legitimately derived from token_capacity; draft_source is overwritten. main contains the identical line, so this PR added a producer of the value 2 without teaching the exporter about it.
Verified chain:
- Producer —
ignition/preparation/execution.py:32addsdraft_source: int = 1toGraphSignature,:102-108validates it and enforces the copy-only invariants (confidence_width == 0, nospeculative_prefix_limits, speculative graph kind), and:316-319emits it into the manifest. The wire enum already exists and matches:helios/proto/runtime_core.proto:854(not opened) (NO_DRAFT = 0; MTP = 1; COPY_DRAFT = 2), field declared atruntime_core.proto:842(not opened). - Clobber — the only route that turns that JSON into a wire
Executionisheliopause/src/export/capture.rs:3158(not opened) (super::binding::execution(execution, &allocations)→output.index.ranks[0].execution);binding.rsregistersexport_captureat line 105, and the export entry point isignition/preparation/runtime_core.py:140(not opened). - Loader —
helios/src/runtime_core/serving.rs:58-63(not opened) faithfully decodes the wire enum back (1 → Mtp,2 → Copy), so the loss is entirely on the write side and invisible downstream. - Selection —
helios/src/runtime_core/selection.rs::184let retain_wide_copy = source == 1 && history_enabled && fixed.is_none();;:277-283copy_widerequiresgraph.draft_source == 2anddraft_tokens > drafts. A wide copy graph arriving as1failscopy_wide, and the ordinary MTP branch at:291-293rejects it becausedraft_tokens <= draftsis false — the whole point of those graphs is depth> base_mtp_drafts(e.g.W=16/W=24with 15/23 drafts versus 7 MTP drafts). The graph is removed from the catalog and its kernels are never loaded. - Contract checks —
helios/src/execution/manifest.rs:845-846(not opened) (draft_source == Copy && confidence_width != 0→ "speculative B/D/W/P geometry is invalid") andhelios/src/model/catalog.rs:93-131(not opened) both 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(not opened),Some(2) => Copy, withSome(_) => Err), and every CPU test constructsGraphDescriptorby hand (helios/src/model/tests.rs:1861-2075,helios/src/scheduler/tests.rs:4107-4340,selection.rs:1876-1940). Nothing round-trips the field throughbinding::execution; the nearest binding tests (binding.rs:1348,:1431) never setdraft_source.
Requested change. Preserve the field instead of coercing it: derive the enum name (1 => "MTP", 2 => "COPY_DRAFT", absent => "MTP" so cores exported before the field existed keep loading per AGENTS.md:434 (not opened), anything else => invalid(...) the way python.rs:230 (not opened) already does). Add one binding::execution round-trip test asserting wire::Execution.graphs[i].draft_source == DraftSource::COPY_DRAFT as i32. Prefer one encoding for both readers (binding.rs:201 writes a prost_reflect name string; python.rs:225-233 (not opened) reads an integer).
Why. The headline feature of commit 9caba2c7 has never run on the path it claims, and the failure is silent: nothing distinguishes "core was built without copy graphs" from "core's copy graphs were relabelled and pruned". That makes the limitation the PR itself discloses ("copy-only wide graph W=16/W=24 GPU export/replay … not benchmarked") very hard for anyone to interpret on live hardware. The compatibility direction also argues against the current code: AGENTS.md:434 (not opened) requires existing cores to keep loading without re-export, and a hard-coded "MTP" is only accidentally compatible because it discards information. This is exactly the persisted-artifact compatibility surface the charter's "Supported matrix & compatibility — verify that existing data, artifacts, and exported cores still load" obligation names.
What would settle it: load-and-serve an exported core containing a draft_source = 2 graph and check describe/selection retains it; impossible from the current suite.
Should Fix
S1. Three documents state the opposite of the new behaviour — docs/cli-design.md:200-201,741, docs/mtp-design.md:22-29
docs/cli-design.md:200-201 reads: "--history-drafts enables host history tracking and feeds continuations into the captured graphs' history inputs; it does not change the graphs." :741 repeats the narrower claim; docs/mtp-design.md:22-28 says "Both settings use the same captured MTP graphs and buffers."
At this head the flag is a load-time graph selector: helios/src/runtime_core/selection.rs:277-298 computes copy_wide = retain_wide_copy && graph.kind == "speculative" && graph.draft_source == 2 && graph.token_capacity > 1 && graph.confidence_width == 0 && graph.draft_tokens > drafts, keeps those graphs only when retain_wide_copy is set, requires copy_wide for them to survive the width / fixed-width / mtp_verification_token_budget filters, then prunes kernels (:375-380) and rewrites speculative_widths (:382-396). The behaviour is pinned by the new test wide_copy_graphs_retain_only_when_history_drafts_enabled, which asserts [1,6,16,24] with the flag and [1,6] without.
Change: state that --history-drafts selects copy-only wide speculative graphs when the core provides them, that they are pruned when the flag is off, that it remains a no-op on cores without them; amend the :741 row and mtp-design.md:22-28 to match.
Why: AGENTS.md:52-56 (not opened),165-166 makes every repository document a present-state specification and inaccurate documentation a rejection item; repo-prose/SKILL.md:26-29 (not opened) says to replace stale claims rather than layer new ones on top. These two files are where an operator learns what a launch flag costs in GPU memory and what core it needs — and it now selects a different graph set, hence a different footprint.
S2. Fill the documents that own the changed semantics (one short section each; no new files)
docs/mtp-design.md:31-40still specifies history drafting as the shared 65,536-token ring with eight/four-token indexes returning "up to seven" continuations,:26says it "requires speculative graphs that declare copy-token inputs, which only theqwen3.8-flashMTP graphs do", and:359listsdraft_sourcein a field table without ever explainingCOPY_DRAFTor wide copy-verify. The primary source is now the per-request prompt+output suffix automaton (helios/src/scheduler/sam.rs), 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 (:1144-1148); the new bounds are undocumented (min_match_len = 6atsam.rs:22, 131,072-token prompt and output caps at:25,28, 512-token boundary overlap at:32), and prompt tokens are indexed — which the ring paragraph explicitly denies.docs/scheduling-runtime-design.md:6-12enumerates the modules implementing the documented design and omitssam.rs; the document specifies the copy-proposal mechanismsam.rsimplements (:39-41), so a reader following its own pointer cannot reach the implementation.docs/scheduling-runtime-design.md:249-254describes only the first dominance pass ("all capacities at least as large as an alternative, with at least one strictly larger").helios/src/scheduler/policy.rs:221-254adds a second rejection pass: for a GPU-allocated ragged speculative candidate, discard it when another speculative shape hasother.batch >= lanes,other.batch < candidate.batch, equal capacity anddraft_tokens, andother.packed_token_capacity >= neededwhereneeded = min(sum(lane lengths), candidate.packed_token_capacity). The survivor can have a strictly smallerpacked_token_capacity, so the paragraph's description no longer holds — and this is the rule that produces the PR's headlinemax_b == Cresult.docs/scheduling-runtime-design.md:396-399states Helios "takes the minimum positive measured duration across matching shapes and returns zero only when every matching shape is unmeasured".helios/src/scheduler/cost.rs:190-208now computeshas_mtpand skips every copy-source shape whenever any MTP packed shape exists, regardless of measured duration.docs/scheduling-theory.md:577-579("Idle earns no credit and discards positive credit while retaining debt. Consequently, separate busy bursts shorter than 245 ms cannot fund a probe at the default settings") contradictsrefresh.rs:95-99and the updatedscheduling-runtime-design.md:437-438,465-469;:714-721("orders alternatives by the later of their last valid completion and last attempted dispatch") no longer describescost.rs:287-296.:704-712claimsretained-refreshmodels Helios whilescripts/scheduling_sim/learning_policy.py:671(not opened) still doesself.credit_ms = min(0.0, self.credit_ms)inidle()— and the 2,495 ms funding bound the PR's Result section cites is argued from the superseded rule.helios/manifest.md:29-53documents the Pythongraphs[]dictionary field by field and omitsdraft_source, whichheliopause/src/python.rs:225-233(not opened) now reads andexecution.py:102-108validates. A manifest writer following this spec cannot declare a copy-only graph.
Why: AGENTS.md:52-60 (not opened) requires designed behaviour to be stated as a specification, AGENTS.md:231 (not opened) points scheduling-policy changes at scheduling-runtime-design.md and scheduling-theory.md, and docs/design-review.md:12 (not opened) asks for the evidence to be reported honestly. The freshness commit's own prose (scheduling-runtime-design.md:425-496) was updated correctly, which makes these omissions stand out.
S3. One authority for the proposal source, and make it part of prepared-shape identity — cost.rs:50-58,151-161,190-244; model/catalog.rs:279-293 (not opened); manifest.rs:190-192 (not opened)
GraphDescriptor::draft_source (helios/src/execution/manifest.rs:190-192 (not opened)) is a second proposal-source dimension duplicating ModelConfig::speculative_proposal_source (helios/src/model.rs:113 (not opened)) and RequestScheduler::proposal_source (scheduler.rs:1044-1050), and it is now decoded by four hand-written ladders (see N4). Two concrete consequences:
(a) Mixed cores cannot load at one geometry. helios/src/model/catalog.rs:279-293 (not opened) filters candidate graphs on kind, batch, token, prefill, packed, drafts, sampling_mode — not draft_source — and returns Err("ambiguous prepared model graph capacity") when two graphs match. cost::Key { drafts, kind, batch, tokens, prefill, packed } (cost.rs:50-58) likewise has no source term and ActionCosts::prepared returns Err("prepared graphs require unique shapes") on a duplicate key (cost.rs:151-161). The PR stores the source on the value side (Estimate.draft_source, PackedRoundShape::draft_source) and re-derives it in is_copy_only_step (cost.rs:223-232) and max_mtp_draft_tokens (:234-244). The collision is reachable as soon as a companion recipe PR captures a wide copy graph at an MTP width (execution.py:87-92 defaults draft_tokens = width - 1). The precedent is already in this PR: selection.rs:250-251 includes draft_source in the serving-variant tuple.
(b) Cost semantics depend non-locally on which other graphs a core contains. cost.rs:190-208 refresh_packed_durations computes has_mtp as an existence scan over all entries; if any MTP packed shape exists (measured or not) every copy packed shape is skipped, so packed_round_duration(batch, width) (:210-213) returns None for a measured copy shape and speculative_duration (rounds.rs:559-568, policy.rs:775) silently loses the copy cost rather than choosing the cheaper of the two.
Secondary: rounds.rs:755-902 is a second, near-duplicate candidate loop guarded by proposal_source == Mtp && shape.draft_source == Copy && width > 1, with its own gate (base_mtp_drafts + 3 at :766) and curve[position] indexing; selection.rs:184,277-298,382-396 bypass the draft-depth, fixed-width and verification-budget filters for copy graphs so one retain predicate answers two questions; model/catalog.rs:93-131 (not opened) adds contract checks keyed off the same field in a file whose stated role is shape validation.
Change: keep the 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; add draft_source to cost::Key and to the select_shape_with_drafts filter (which then lets Estimate.draft_source, PackedRoundShape::draft_source and the inference be dropped, not maintained in parallel); split the packed-duration table into MTP-verify and copy-verify tables so a measured copy shape is never masked; fold the copy candidate loop into the ordinary one (see Subtract #2). Then selection.rs needs no copy_wide bypass.
Why: docs/design-review.md:16 (not opened) 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:176-181 (not opened) (flags, enums and optional paths cannot bypass boundaries), AGENTS.md:188 (not opened) ("Reject unsupported abstractions and churn"). Compounding factor: because of B1 this code has never run on its target path; all fixtures are hand-built descriptors.
S4. Four calibrated constants steer scheduling with no stated derivation — speculation.rs:15-21, rounds.rs:766, sam.rs:22
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 from 3) all steer scheduling decisions. Only the 6 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 speculation.rs:139 derives a confidence bound from 20.0f64.ln() with no explanation. Separately, WIDE_COPY_MIN_MATCH_LEN = 6 (speculation.rs:18) duplicates sam::DEFAULT_MIN_MATCH_LEN = 6 while gating the same lanes at rounds.rs:776; the gate is meaningful only because the two happen to be equal, and sam.rs:1287 asserts DEFAULT_MIN_MATCH_LEN == 6.
Change: give the derivation for each beside the new copy section in docs/scheduling-runtime-design.md, or promote the policy-relevant ones to named PolicyConfig fields with documented defaults; have rounds.rs refer to one constant.
Why: charter "Be explicit and pin everything. No magic defaults… Benchmarks, tests, or feature flags don't override architectural rules"; AGENTS.md:187 (not opened),446-456 (one home per setting).
S5. Evidence: the SAM build cost is reported without its serving-path consequence, and the bundled numbers cannot be attributed
helios/src/scheduler.rs:1849-1852 builds PromptOutputSAM::new(&spec.prompt) synchronously inside admission whenever decoded_history is enabled, before the request is registered — on the serving thread for every --history-drafts request. The description reports "PromptSAM::build takes 0.80 ms (0.37 MiB), 2.72 ms (1.27 MiB), and 13.05 ms (4.52 MiB)" as a CPU release microbenchmark and separately reports only +0.25 ms/rd scheduler overhead, which measures steady state, not admission. Neither the admission-time placement nor the per-live-request memory is disclosed.
The four commits are independent outcomes (AGENTS.md:198 (not opened), docs/design-review.md:125 (not opened) principle 15): (1) 1b0db227 funded-refresh recovery; (2) 450012d1 a new 1,606-line sam.rs plus admission wiring; (3) 9caba2c7 wide copy-verify graphs; (4) 14019718 padding dominance in shared policy plus DEFAULT_MIN_MATCH_LEN 3→6. Commit 4 changes behaviour for every speculation user while 2–3 affect only cores carrying copy inputs, and the headline live numbers ("+12.9% tok/s", "3.078 → 3.650 emitted tokens/round") are combined-stack, so the max_b == C result cannot be attributed to commit 4 alone. Commit 1 is a self-contained defect fix with real CPU evidence and could merge today.
Also missing: one load-and-serve of an already-exported core (would have caught B1 and settles AGENTS.md:434 (not opened) compatibility), and one preempt→readmit SAM test. On the latter, the code reading is reassuring but untested: Worker::park (helios/src/server/runtime.rs:2068-2088 (not opened)) extends the prompt with generated text, re-admission calls resume_decoded_sequence (:1550-1553 → scheduler.rs:1211-1223, which touches only decoded_sequence), and admission rebuilds the SAM from spec.prompt (scheduler.rs:1849-1852) with push_token fed only from record_decoded_token (scheduler.rs:1227-1238) and the post-completion loop (:3010-3021) — so no token is indexed twice, but output-recency tie-breaks and boundary_overlap degrade for the remainder of a re-admitted request.
Change: state that the build runs synchronously at admission and that no admission-latency measurement exists; report per-commit live measurements (or split the PR); add the exported-core load test and the preempt→readmit SAM test.
Why: AGENTS.md:96-102 (not opened) requires limitations attached to a claimed result; repo-prose/SKILL.md:35-37 (not opened) requires disclosing missing measurements; the charter asks for real evidence and the smallest footprint in shared code.
S6. The Python producer accepts a copy graph the Rust loader refuses — ignition/preparation/execution.py:102-108 vs helios/src/runtime_core/selection.rs:278-283
execution.py validates draft_source in (1, 2) and the copy-only invariants without restricting the graph kind, so it accepts draft_source = 2 on kind == "mixed"; selection.rs:278-283 requires kind == "speculative" for copy_wide, so such a core loses the graph at load. Change: reject 2 on non-speculative kinds in the producer, matching the loader. Why: the two boundaries must agree about what a valid core is; AGENTS.md:434 (not opened) compatibility and the charter's artifact obligation both point at producer-side validation as the cheaper fix.
Subtract / Simplify
Could remove ~500–600 of the +3,968 added lines (~13–15%), none of it behaviour. Per-file diff sizes behind this: tests policy_tests.rs (not opened) +504, scheduler/tests.rs +583, model/tests.rs +324; production sam.rs +1,606 (of which ~370 are its own tests and benchmark), rounds.rs +194, scheduler.rs +180, cost.rs +120, policy.rs +119, selection.rs +109, speculation.rs +103.
- ~150–250 test lines: three end-to-end tests re-prove the same SAM→pack path.
helios/src/model/tests.rs:846-953(history_draft_packing_forwards_per_request_prompt_sam_continuations, 108 lines) and:1861-2075(wide_copy_verify_catalog_packs_23_sam_tokens_and_preserves_legacy_w8_cores, 215 lines) do the same walk twice — build a scheduler with history drafts, run Init→Prefill→Decode emitting a token that completes a ≥6-token suffix, plan a speculative step, pack inputs, assert oncopy_token_ids/copy_token_count. The wide test also re-asserts legacyW=8retention already owned byruntime_core/selection.rs:1876-1940and W=24 selection already owned byscheduler/tests.rs:4107-4340;scheduler/tests.rs:1995-2127mostly re-provessam.rs's ownprompt_only_match_succeeds_with_zero_prior_output,output_overrides_prompt_recency_on_tieandshared_prompt_sam_isolates_per_request_outputs_and_bounds_states, with only ~30 lines of genuinely scheduler-specific coverage (admission,enable_history_drafts,status == 3). Keep the wide test andselection.rs, keep one packing test, trim the scheduler test to admission + isolation. Every fibre stays covered once. - ~112 lines: the copy-only round search duplicates the ordinary one.
helios/src/scheduler/rounds.rs:755-903vs:905-1060: identical prefix ranking (:791-800vs:929-956), identical per-lanebase/full(:808-816vs:965-976), the samefor ordering in 0..3loop withselect_nth_unstable_by+sort_unstable_by(:818-838vs:981-992), the samefrontier.clear()/host_lengths/lane_terms/mask |= 1 << slot(:839-867vs:993-1012), the same(count_ones, Reverse(mask))tie-break (:868-875vs:1040-1045), and the sameexpectedrecompute plusCandidateconstruction (:878-902vs:1048-1059). The real differences are the curve source (wide_copy_curvevspowered_curve), the availability gate (:769-790), and the absence ofhost_ranking/surplus_table(the copy block silently omits the:1031-1037surplus factor).:801-806also re-implements the existinghost_prefix_ranking(rounds.rs:492-513). One loop parameterised on a per-slot curve provider plus the gate collapsescurves/copy_curves(:747-748) to one array. The copy block's third ordering (full / copy_limits[slot],:826) is already the main loop's third ordering, so nothing is lost. Precedent in the same function:rank_prefixes,fixed_round_candidate,host_prefix_ranking, andwide_copy_curve/expected_copy_tokensitself (:541-557) are all factored as "one loop plus a closure". - ~150 lines of SAM API with no production caller. Production uses exactly
PromptOutputSAM::new(scheduler.rs:1852),propose(:1128,1179),push_token(:1234,3016) andMatchProposal::into_padded_i64(:1151). Test-only:propose_for_context(sam.rs:1070-1110),propose_conditional_continuations(:1118-1189, 78 lines whose only reference is its own test at:1491-1514),MatchSource(:64-69) andMatchProposal::source(:80-81),PromptSAM::build(:283),push_slice(:1023),from_shared_prompt(:935) — the only way to actually share the prompt SAM, while production builds a fresh private automaton per request — plusis_empty,tokens,config,prompt_len,output_len, andLiveRequest::sam()(scheduler.rs:383-385).SamConfig's four fields are allDEFAULT_*in production, sowith_configcan be#[cfg(test)]andnewcan read the constants. Before deleting, re-point the randomized oracle (sam.rs:1400-1469) atpropose, so the survivingwalk_context/resolve_matchmachinery keeps brute-force coverage. Keep the#[ignore]microbenchmark accessors (memory_bytes,dynamic_memory_bytes,state_count,transition_count) — the PR's result table cites that benchmark and nothing else reads SAM memory. Also correctsam.rs:9-13, which claimsArcsharing across requests that no production path performs.AGENTS.md:188-193(not opened) rejects extension points added without a concrete requirement. - ~75 lines: one helper, one deletion, one parser.
- ~40 lines —
helios/src/scheduler.rs:1112-1159and:1163-1205are the same algorithm twice: the same three-way clampmaximum.min(completion_token_capacity - 1).min(speculation::COPY_DRAFT_CAPACITY), the same early exit, the samerequest(handle)lookup, the same SAM truncation at the first out-of-vocabulary token, the samelookup_with_match_len, the same "ring wins only on a strictly longer match". They have already drifted: the proposal path takes the(None, Some(...))arm unconditionally (:1154-1156) while the stats path filters.filter(|&(count, _)| count > 0)(:1194), so the wide-copy gate atrounds.rs:774-776and the packing path atpacking.rs:402(not opened) disagree today about whether a zero-count matched span counts. Keeprequest_copy_match_statsas the primitive returning(count, match_len)plus winning tokens and implementrequest_history_proposal_with_match_lenon top of it (paddingproposeoutput is O(1) amortized);request_history_proposal(:1102-1109) is a 6-line pass-through whose callers use only(tokens, count). Thedecoded_history.rs:162-183(not opened)lookup-over-lookup_with_match_lenwrapper in this same PR is the pattern. - ~20 lines —
helios/src/scheduler/refresh.rs:95-99is nowpub fn idle(&mut self) {}under an 8-line doc comment; delete it and theself.refresh.idle()line inscheduler.rs:1277-1283(keeping thesubmissionsguard the server needs atserver/runtime.rs:1184(not opened), or renaming itassert_idle), and drop the eleven.idle().unwrap()assertions (policy_tests.rs:2610 (not opened),2626,2638,2689,2699,2730,2751,3685,6102,6108,6153). Retention across idle is now the absence of mutation, i.e. the default;abort(:101-105) still holds the only copy of the clamping. Updatedocs/scheduling-runtime-design.md:438. - ~15 lines — one
ProposalSource::from_wire(i32) -> Result<Option<Self>>/as_str()beside the existingparse(speculation.rs:30-38) replaces three ladders:runtime_core/serving.rs:58-63(not opened),heliopause/src/python.rs:225-233(not opened) (which alone keeps the absent-key default) andruntime_core/selection.rs:144-148(which compares raw numbers at:149,169,197instead of enums).GraphKind::try_from(manifest.rs:123-145(not opened)),Dtype::try_from(:50-68) andSamplingMode::try_from(:109-121) are the house pattern, and the wire enum already providestry_from/as_str_name.
- ~40 lines —
- Nit bundle, ~55 lines (see Nits 2–4 and the items in Nits not counted above): the subsumed
manifest.rs:844-846(not opened) copy check, the three copies of the identical.any(|(a, b)| *a > b)early-out inpolicy.rs:158,166,175withshort()/long()built twice, thepolicy.rs:221-254prune_paddingscan that re-testsdominates_padding_with's new first branch (:143-165), the triplicated "idle retains earned credit" sentence (scheduling-runtime-design.md:431,481,refresh.rs:95-98), the duplicated6, and the third restatement of the copy-only rule inexecution.py:102-108.
Deliberately not subtracted — do not re-add these:
Candidate.expected(policy.rs:86-95; set atrounds.rs:724-733,896,1052,policy.rs:1096,1295,1479).rateis expected-per-ns minus age price;expectedis the zero-duration counterfactualcompare_refreshranks by (policy.rs:1332-1338). One lens proposed dropping it; that is wrong — the duplicate accumulator plumbing is the nit, not the field.- The
MutableEdges/RootedLctmachinery insam.rs(~600 lines): no equivalent exists in the repository, it is the price of O(log M) recency updates, and the#[ignore]microbenchmark reads it. draft_sourceonGraphDescriptoritself: required by cost/serving/selection (it needs to reachcost::Key, not disappear); only the duplicate decoding and the missing key dimension are findings.- The four behaviours: each maps to a stated gap with a measurement.
LiveRequest.sam/copy_calibration(scheduler.rs:265-266) — pushed on both commit paths, read on both proposal paths androunds.rs:774; no orphan field.
Nits
- PR description and title. The title names three outcomes and omits commit
14019718, which produced the headlinemax_b == Cand+12.9%results. The description says the bundle "preserves four atomic commits rebased cleanly" without stating which commits depend on which;AGENTS.md:194-199(not opened) asks for one coherent outcome, and if these must stay together, say why they cannot land separately. (Both are prose-only; the substantive evidence point is S5.) refresh_orderlost its contract comment.cost.rs:287-296now returns(bool, u64)—(true, attempt_ns)= "attempted while stale with no valid observation" — with no doc comment; the meaning lives only indocs/scheduling-runtime-design.md:435-441, while neighbouring helpers state theirs in one line (cost.rs:40-41,110-113,282-285).- The test oracle is not independent of production.
sam.rs:1236-1273brute_force_oraclereturns the productionMatchProposaland re-derivesbuild_proposal(sam.rs:1191-1227) — the samecount = max_draft_len.min(n - 1 - endpos)bound and the sameendpos >= prompt_lensource selection — so the 120-trial comparison re-checks the code against a mirrored copy. Precedent: theoracleatdecoded_history.rs:228-252(not opened) returns the same plain(Vec<i64>, usize)the productionlookupreturns. - Copy-only validation and the
6threshold each written more than once.manifest.rs:844-846(not opened) rejectsdraft_source == Copy && confidence_width != 0;model/catalog.rs:123-131(not opened) rejects the same condition plusSpeculativePrefixLimitand runs on load, so the manifest clause is subsumed — andexecution.py:102-108restates the rule a third time. Separately,WIDE_COPY_MIN_MATCH_LEN(speculation.rs:18) duplicatesDEFAULT_MIN_MATCH_LEN(sam.rs:22) (see S4). - False definite reference in a new doc comment.
sam.rs:1112-1117justifiespropose_conditional_continuationsas "a building block for conditional copy lookup tables in 2-deep pipelined execution". No such mechanism exists in the tree —rounds.rsplans one round at a time and the function's only reference is its own test (sam.rs:1491-1514).repo-prose/SKILL.md:17-19(not opened) forbids definite references without an introduced referent; delete the method (Subtract #3) or name the caller. wide_copy_curve'selsearm is unreachable and re-derives an owned prior.rounds.rs:541-553recomputesWIDE_COPY_PRIOR_RATE.powi(depth + 1)althoughCopyCalibration::curveowns exactly that prior (speculation.rs:100-151,None => priorat:145,optimisticat:122-123), andcopy_calibrationis set together withdecoded_history(scheduler.rs:1849-1856) whilerounds.rs:759requiresdecoded_history. Take&CopyCalibrationorexpectit.
Verified positives
- Commit
1b0db227is clean and mergeable on its own.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); both bounds (P <= 0.002/0.998 * O + Dtiming,P <= 0.01/0.99 * O + Dacceptance) are preserved.refresh.rs:101-105abortstill discards positive credit.cost.rs:284-296refresh_orderreplaces the nanosecond timestamp with a two-tier key andcompare_refresh(policy.rs:1333-1338,1369-1372) ranks by zero-duration expected value — this fixes the real "probe the older/smaller shape first" defect.docs/scheduling-runtime-design.md:425-496matches it exactly. - The rewrite of padding dominance replaced the exact-equality branch rather than layering on it, and the new tests drive it through
prune_padding/plan(real behaviour, not internals). - No Protobuf wire change was needed:
runtime_core.proto:854(not opened) already carriesNO_DRAFT = 0; MTP = 1; COPY_DRAFT = 2, so existing cores keep their default. selection.rs:244-246already rejects out-of-rangedraft_sourceand non-zero values on non-speculative graphs, and:250-251already includes the field in the duplicate-variant tuple — the precedent for thecost::Keyfix.- SPDX header and the second copyright line in
sam.rs:1-5matchspeculation.rs:1-5;wide_copy_curve/expected_copy_tokensmirrorpowered_curve/expected_speculative_tokens; the per-shape copy-curve cache (rounds.rs:747-748,794-795) follows the documented "lane forecasts stay fixed while shapes compete" cache. - No
#[allow(dead_code)]and no new env-var or feature-flag fallbacks were added. - The description satisfies the four-question order, labels the combined-stack numbers as combined, separates component from service measurements, names the untested hardware/models and the copy-only wide-graph GPU gap as limitations, and carries a correct
Discord:line. Prose-only items are folded into Nits 1. - Two candidate defects were investigated and dropped, so they should not be re-raised: (a)
refresh_ordertier-0 ordering is not catalog order —best_order < orderis never true within tier 0, socompare_refreshscans all tier-0 targets and picks the maximum, and the break fires only on the tier transition; (b)refresh_packed_durations'has_mtpguard cannot mis-select a duration for a fixed-width MTP round, because copy graphs are pruned when a fixed width is retained (selection.rs:184,293) and skipped during candidate generation (rounds.rs:755-764). - Also not attributable to this PR (present in the since-last-turn diff but from base commits): prefill natural-fit discovery (
policy.rs, baseba35da3f/ #538) and thejoint_tuningproto removal plusdocs/preparation-development.md(not opened) edit (basef377dc85).
Open questions
- Was the wide copy-verify path approved in advance?
docs/design-review.md(not opened) principle 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. - Should
mtp-design.mdorscheduling-runtime-design.mdown the wide-copy description? One must, becausecli-design.md:200-201currently states the opposite. - 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; the fix in S3 assumes the masking is accidental. - Is the admission-time SAM build a visible serving stall? Only a live
--history-draftsrun with a ~128K-token prompt can settle it; CPU microbenchmark magnitudes cannot. - Is
propose_conditional_continuationsthe front half of an unlanded PR? Its doc names a "2-deep pipelined execution" that the description does not mention. If a follow-up exists (sibling #542, recipes #48/#49), naming it converts Subtract #3 from "delete" to "land with its consumer". - Does anything intend to read SAM
memory_bytes? No metric, dashboard field or endpoint references it; if per-request SAM memory accounting is planned, it belongs with that change. - Was the
learning_policy.py:671(not opened) divergence intended? The simulator retains the pre-PR idle rule whiledocs/scheduling-theory.md:704-712claims it models Helios. - Can commits 2–4's live numbers be reproduced without commit 1? Not determinable from the repository.
- Is
history_proposalmeant to stay as a public API for an out-of-tree consumer? Its only remaining callers are tests (scheduler/tests.rs:1956,1970-1991,2069,server/runtime/phase_tests.rs:583 (not opened),1835); a one-line reply settles whether to delete it or keep it.
What I could not verify
- B1 and S1–S3 are established by code reading only. No CI runs on head
14019718, no GPU is available here, and the Rust and Python suites were not executed. The requestedbinding::executionround-trip test is what turns B1 into an observed failure. - All live 4× RTX PRO 6000 numbers, the 619 / 1,710 test counts, the 120 randomized SAM oracle trials and the SAM microbenchmark were not independently reproduced; I could only establish that the headline numbers depend on several commits at once.
helios/src/model/packing.rs(not opened) andhelios/src/server/dashboard/scheduler.rs(not opened) were cited from cross-references (tree-wide search forhistory_proposal) rather than read in full; downstream crates (flare/,flare-cli/) were not opened, so thepubSAM surface was checked only across this repository.- Whether
catalog::select_shape_with_draftsandActionCosts::preparedreally reject an MTP + copy pair at identical B/D/W/P: the code says yes (nodraft_sourceterm, explicit duplicate errors) and the new test atmodel/tests.rs:1861-2075uses distinct geometries, so it does not exercise it. One graph pair plusInputs::newwould confirm whether S3(a) is a hard load failure. - The Python catalog generation was read only where
draft_sourceplumbing crosses it; the rest ofignition/preparationwas not audited.