Simplicity scratchpad · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/6774831c-b9f2-408f-993b-74921089904b.md

#1 [high] should fix: RefreshState::idle is an empty function that callers still route through

helios/src/scheduler/refresh.rs:95-99 — pub fn idle(&mut self) {} with a 5-line doc comment explaining that it does nothing. Its only caller is RequestScheduler::idle (helios/src/scheduler.rs:1277-1283), which still validates submissions.is_empty() then calls the no-op; server calls it at helios/src/server/runtime.rs:1184.

Smaller version: delete RefreshState::idle entirely. RequestScheduler::idle collapses to the empty-submissions check (or is renamed to assert_idle). abort already contains the exact discard logic that idle used to share (refresh.rs:101-105, inlined by this PR), so nothing is lost. ~6 lines of dead API plus a doc paragraph that describes a call that has no effect.

Tests also lean on the no-op: helios/src/scheduler/policy_tests.rs:2689, 2699, 2730, 2751, 5714-5765 call s.idle().unwrap() and then assert credit is unchanged — the assertion holds whether or not idle exists, so those lines now only assert that a validator accepts an empty queue.

Docs: docs/scheduling-runtime-design.md:430-433 says "Idle retains earned credit and negative debt; abort discards positive credit and preserves debt" — with an empty idle the only remaining difference is the active flag, which the prose does not mention.

#2 [high] should fix: sam.rs ships large API surface no production caller uses

helios/src/scheduler/sam.rs (new, 1606 lines). Production uses only: PromptOutputSAM::new (scheduler.rs:1852), propose (scheduler.rs:1128, 1179), push_token (scheduler.rs:1232, 3016), MatchProposal::into_padded_i64 (scheduler.rs:1151), plus match_len/tokens.

Test-only or unconsumed:

Smaller version: keep push_token, propose, new/from_shared_prompt, into_padded_i64, and the internal builders; drop propose_for_context, propose_conditional_continuations, MatchSource/source, PromptSAM::build, and the accessor block (keep whatever the retained tests need). That removes roughly 150 lines of code plus ~6 tests that only exercise them (sam.rs:1313-1324 source assertions, 1492-1514, 1517-1541). It also removes the MatchSource/endpos public surface from a module declared pub mod sam (scheduler.rs:23), i.e. from Helios' external API.

#3 [high] Research summary

Reviewed PR #540 through the simplicity lens (what can be deleted), against AGENTS.md, docs/design-review.md and the charter, reading every changed hunk in context and following callers (scheduler.rs, rounds.rs, policy.rs, packing.rs, server/runtime.rs, selection.rs, catalog.rs, planning.py (not opened) side).

Two findings are on the scratchpad:

  1. should fix — RefreshState::idle is an empty function (refresh.rs:95-99). The PR emptied it and wrote a five-line doc comment saying it does nothing; RequestScheduler::idle (scheduler.rs:1277) still validates the queue then calls it, and server/runtime.rs:1184 still calls that. Delete the method (and collapse/rename the scheduler wrapper); abort already carries the discard logic the old body shared. Several policy tests now only assert that a validator accepts an empty queue.

  2. should fix — sam.rs ships a large test-only API surface. propose_conditional_continuations (sam.rs:1118-1189) and propose_for_context (1070-1110) have no production caller and no planned 2-deep consumer exists; MatchSource/source is only read by tests; PromptSAM::build and the accessor block (state_count, transition_count, memory_bytes, dynamic_memory_bytes, prompt_sam, config, prompt_len, push_slice) are test/benchmark-only. Deleting them removes ~150 lines plus the tests that only exercise them, and shrinks the pub mod sam surface.

Two more observations I did not get onto the scratchpad in time, both nits from the same lens: ExecutionManifest/catalog/serving/python.rs each repeat the same 0=>None, 1=>Mtp, 2=>Copy decoding (serving.rs:55-64 and python.rs:223-232 could share one conversion), and request_copy_match_stats (scheduler.rs:1163-1205) is a near-duplicate of request_history_proposal_with_match_len (1112-1159) — one of the two could be expressed in terms of the other to avoid two copies of the SAM-vs-shared-history arbitration rule drifting apart.

#6 [high] should fix: history_proposal became test-only in this PR — public scheduler entry point with no production caller

Verified at head 1401971.

RequestScheduler::history_proposal (helios/src/scheduler.rs:1094-1097, pub fn) had exactly two production callers before this PR: helios/src/model/packing.rs and helios/src/server/runtime.rs:2146. Both were switched in this PR to request_history_proposal (packing.rs:402, server/runtime.rs:2143-2150).

Full caller list after the change (search history_proposal\b): only tests —

So the PR leaves three entry points for the same lookup: the handle-keyed request_history_proposal (prod), the handle-keyed request_copy_match_stats (prod, rounds.rs:775), and the context-keyed history_proposal (dead outside tests), plus DecodedHistory::lookup (helios/src/scheduler/decoded_history.rs:180-183) which now only history_proposal and the decoded_history oracle tests call.

Smaller version: delete the pub fn history_proposal wrapper. Move the ~8 assertions of that test onto request_history_proposal (the test already admits a live request h/next, so it has a handle) — this is also the more faithful test, since the shared-ring assertions it makes are about the fallback path that production reaches through the handle-keyed API. Keep DecodedHistory::lookup as pub(crate) because the ring's own brute-force oracle test (decoded_history.rs:276) is worth keeping.

Why it matters in this lens: history_proposal also bypasses the SAM entirely, so a future caller could silently reintroduce prompt-blind copy drafts; the PR's own claim is that the SAM is now first. Leaving the bypass as public API works against that.

#7 [high] should fix: rounds.rs copy-only candidate loop duplicates the ordinary packed loop (~110 lines)

Verified at head 1401971 (helios/src/scheduler/rounds.rs).

packed_round_candidates now contains two cohort-scoring loops over the same shape table:

The copy block re-implements, statement for statement:

Differences that are real, and all expressible as flags/callbacks: copy lanes are filtered to copy_available (769-787), the copy path has no host_ranking and no surplus_table, and its per-lane curve comes from wide_copy_curve rather than powered_curve. Both paths also carry parallel per-slot memo arrays — curves and copy_curves (rounds.rs:747-748) — used at 794/812/857/881 and 934 respectively.

Smaller version: one loop taking lanes: &[usize] (available or copy_available), a curve: impl Fn(&LiveRequest, bool) -> Vec<f64> provider, and surplus: Option<..>/host_ranking: Option<..>; replace curves/copy_curves with a single [Option<Vec<f64>>; REQUEST_LANES] populated by that provider. Net approximately -110 lines, and the two paths can no longer drift on the cohort tie-break — which is the property the new padding-dominance tests and the wide-copy tests both depend on.

Neither loop is wrong today; this is dedup, not a defect. It is the single largest deletable block in the diff.

#8 [high] should fix: sam.rs documents cross-request sharing that production never does; SamConfig is constants in prod

Verified at head 1401971, extends the sam.rs finding.

The SAM module advertises cross-request sharing that does not exist:

Smaller version: PromptOutputSAM::new(prompt) calls PromptSAM::build_capped(prompt, DEFAULT_MAX_PROMPT_TOKENS) and reads DEFAULT_MIN_MATCH_LEN / DEFAULT_MAX_OUTPUT_TOKENS / DEFAULT_BOUNDARY_OVERLAP directly. Move SamConfig, with_config, from_shared_prompt, config(), prompt_sam() under #[cfg(test)] so the oracle can still vary thresholds and overlap. Then fix the module doc to say the prompt automaton is per-request today (or keep the wording only if a sharing caller lands with it). The Arc<PromptSAM> may then also collapse to a plain PromptSAM if nothing clones PromptOutputSAM — worth one grep before doing it; I did not confirm clone usage.

Total deletable sam.rs surface after this plus entries #2/#6: ~150 lines of API plus the SamConfig indirection.

#10 [high] Report of 2026-11-26, run 2 — final simplicity verdict at head 1401971

Supersedes/extends entry #5 as the current report. Head 1401971, 25 files, +3965/-119.

Should fix (4):

  1. refresh.rs:95-99 — RefreshState::idle is now pub fn idle(&mut self) {} under a 5-line doc; scheduler.rs:1277-1283 wrapper and server/runtime.rs:1184 still route through it. Delete; several policy tests (policy_tests.rs:2689/2699/2730/2751/5714/5720/5765, 3685) only assert the no-op.
  2. sam.rs — test-only surface: propose_for_context (1070-1110), propose_conditional_continuations (1118-1189, doc claims a 2-deep pipelined consumer that does not exist), MatchSource/source (64-82), PromptSAM::build (283), push_slice (1023), accessor block (462-476, 949-984), and now also SamConfig/with_config/from_shared_prompt/config()/prompt_sam() (41-61, 929-955) — production only calls new (scheduler.rs:1852) which uses SamConfig::default(). Module doc (sam.rs:9-13) claims zero-copy Arc sharing across requests that never happens. ~150 lines + tests.
  3. scheduler.rs:1094-1097 history_proposal lost both production callers in this PR (packing.rs:402 and server/runtime.rs:2146 moved to request_history_proposal); now only tests call it (scheduler/tests.rs×8, phase_tests.rs:583/1835). It is also the prompt-blind bypass the PR is replacing. Delete; re-point the test at request_history_proposal.
  4. rounds.rs:755-903 duplicates rounds.rs:925-1060 statement-for-statement (~110 lines) plus the curves/copy_curves twin memo arrays (747-748). One loop with a lane-list argument and a curve provider.

Nits (4): draft_source ladder written 3× (serving.rs:58-63, python.rs:225-233, selection.rs:144-148) though ProposalSource::parse exists; request_copy_match_stats (scheduler.rs:1163-1205) duplicates the arbitration in request_history_proposal_with_match_len (1112-1159) with no test they agree; two 6 match thresholds (speculation.rs:18, sam.rs:22); unreachable else in wide_copy_curve (rounds.rs:545-548).

Rules cited: docs/design-review.md:16 ("Keep Helios as simple as possible"), AGENTS.md:231 (scheduling changes must follow docs/scheduling-runtime-design.md).

Open question for the author: is propose_conditional_continuations the front half of an unlanded PR? Nothing in the tree says.

#11 [high] Research summary

Re-reviewed PR #540 at head 1401971 through the simplicity lens, reading each changed function in its surrounding code and following callers. Four should-fix findings and four nits; no blockers. Full text is scratchpad entry #10 (detail in #1, #2, #4, #6, #7, #8, #9).

Should fix

  1. RefreshState::idle is an empty function (helios/src/scheduler/refresh.rs:95-99) carrying a five-line doc comment that describes behaviour it no longer implements — retention is now the absence of mutation. RequestScheduler::idle (scheduler.rs:1277-1283) still validates the queue and calls it, and server/runtime.rs:1184 still calls that. Delete the method and collapse the wrapper; several policy tests only assert the no-op survives.

  2. sam.rs exports ~150 lines with no production caller: propose_for_context, propose_conditional_continuations (whose doc names a "2-deep pipelined execution" that exists nowhere in the tree), MatchSource/MatchProposal::source, PromptSAM::build, push_slice, the accessor block — and, newly confirmed this pass, the entire SamConfig/with_config/from_shared_prompt layer, since production only calls PromptOutputSAM::new with defaults. The module doc claims zero-copy Arc sharing across requests that never happens; each admission builds a private automaton (scheduler.rs:1849-1852).

  3. New this pass: RequestScheduler::history_proposal (scheduler.rs:1094-1097) lost both of its production callers in this PR — packing.rs:402 (not opened) and server/runtime.rs:2146 were moved to request_history_proposal. It is now reachable only from tests, and it is also the prompt-blind lookup path the PR exists to replace, so leaving it public works against the change. Re-point its test at the handle-keyed API and delete it.

  4. New this pass: rounds.rs:755-903 re-implements rounds.rs:925-1060 statement for statement (~110 lines: prefix ranking, the 3-ordering cohort loop, frontier bookkeeping, the (mask.count_ones(), Reverse(mask)) tie-break, the expected recompute and Candidate construction), with twin per-slot memo arrays at rounds.rs:747-748. One loop with a lane-list argument and a curve provider removes it.

Nits: the 0/1/2 → Option<ProposalSource> ladder written three times though ProposalSource::parse exists; request_copy_match_stats duplicating the arbitration rule of request_history_proposal_with_match_len with no test they agree; two separate 6-token match thresholds (speculation.rs:18, sam.rs:22) whose equality is what makes the second gate meaningful; and an unreachable non-calibrated branch in wide_copy_curve (rounds.rs:545-548).

One question to settle with the author: whether propose_conditional_continuations is the front half of an unlanded follow-up; if so, naming it converts finding 2 from "delete" to "lands with its consumer".

#12 [high] Cleared at head 1401971 — what I checked and found load-bearing (so the report can scope its "no blocking" claim)

Simplicity lens, head 1401971. Areas I read in context and cleared — every path below has a live non-test caller, so the report should say the rest of the diff reads as load-bearing, not merely unexamined:

Cleared-but-not-note-worthy: no over-commented blocks beyond refresh.rs:95-99; no #[allow(dead_code)]; no feature flags or env-var fallbacks added.

Rules cited for the report: docs/design-review.md:16 ("Keep Helios as simple as possible"), AGENTS.md:231 (scheduling changes must follow docs/scheduling-runtime-design.md), AGENTS.md:338 (same simplicity principle, cited via entry #5).

#4 [medium] nit: two duplicated mappings/arbitrations worth collapsing

Two duplicate-logic items seen in the diff but not written up in detail before the time limit:

  1. nit — draft_source decoding is written four times with the same 0 => None, 1 => Mtp, 2 => Copy, _ => error ladder, each with its own error text:

    • helios/src/runtime_core/serving.rs:55-64 (invalid("unknown graph draft source"))
    • heliopause/src/python.rs:223-232 (PyValueError::new_err("unsupported graph draft_source"), plus a default-to-Mtp rule when the key is absent, which the other three do not have)
    • helios/src/execution/manifest.rs:841-850 (validation: copy ⇒ confidence_width == 0)
    • helios/src/runtime_core/selection.rs:144-148 + 166-190 (same ladder again for the speculative_proposal_source config string, now needed in two scopes because the source binding moved above the maximum computation) Smaller version: one ProposalSource::from_wire(u32) -> Result<Option<ProposalSource>> with the absent-key default handled at the one place that needs it (python.rs), like GraphKind::try_from is already used. That is one conversion and one error message instead of four.
  2. nit — helios/src/scheduler.rs:1163-1205 request_copy_match_stats duplicates the arbitration rule of request_history_proposal_with_match_len (1112-1159): both clamp maximum the same way, both return (0/[-1], 0) when decoded_history.is_none(), both truncate the SAM proposal at the first out-of-vocabulary token, and both implement "prefer shared history only when shared_match > sam.match_len". The two differ only in whether a padded upload vector is built. Smaller version: keep request_copy_match_stats as the primitive returning (count, match_len) and have request_history_proposal_with_match_len build the padded vector from the winning source (it needs the tokens anyway, and propose is O(1) amortized). One copy of the tie-break rule, so the invariant the PR description states ("shared ring wins only on a strictly longer match") cannot drift between the packing path and the scheduling path — today they agree, but nothing tests that they do.

Neither is blocking. Both are worth mentioning as deletions, since each removes a parallel path that must otherwise be kept in sync.

#9 [medium] nit: two 6-token match thresholds and a dead wide_copy_curve fallback

Verified at head 1401971. Two small leftovers in the new wide-copy path.

  1. nit — two constants for one threshold. speculation::WIDE_COPY_MIN_MATCH_LEN = 6 (helios/src/scheduler/speculation.rs:18) gates wide copy eligibility at rounds.rs:776 (if match_len < speculation::WIDE_COPY_MIN_MATCH_LEN ... continue), while sam::DEFAULT_MIN_MATCH_LEN = 6 (helios/src/scheduler/sam.rs:22, via SamConfig::default(), sam.rs:56) is the threshold inside propose, so a proposal never reports match_len below it. The second gate is only meaningful because the two are equal by coincidence; sam.rs:1287 even asserts DEFAULT_MIN_MATCH_LEN == 6. Raise the SAM default to 8 and the rounds gate becomes subsumed; lower it to 4 and the rounds gate does all the work. One constant (or rounds.rs referring to DEFAULT_MIN_MATCH_LEN) removes the coincidence; today nothing states the relationship in a comment.

  2. nit — unreachable fallback arm. wide_copy_curve (helios/src/scheduler/rounds.rs:541-553) has an else arm producing a raw geometric prior when request.copy_calibration is None. copy_calibration and decoded_history are both created from the same condition at admission (helios/src/scheduler.rs:1849-1856: .decoded_history.is_some().then(...) twice), and the copy-only block requires self.decoded_history.is_some() (rounds.rs:759) before any curve is taken, so copy_calibration is always Some on that path — and expected_copy_tokens (rounds.rs:555) is only called under is_copy_only_step (scheduler.rs:2507-2518), for graphs the loader only retains with --history-drafts (runtime_core/selection.rs:184 retain_wide_copy). A 3-line expect/unwrap (or taking &CopyCalibration as the argument) says the same thing without an unreachable branch. Note: only tests construct schedulers with copy graphs and no history, so this is inference from the constructors, not something a test currently contradicts.

Both are small; listed as nits, not asked to block.