Simplicity scratchpad · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/aae6dd6d-797c-4fdf-a693-afc658b69611.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.

#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.