Subtractive report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/c05d8e43-ce79-4d07-8db4-6ccffda460c5.md

Key findings

The four behaviours are argued and measured; the volume is not. At head 14019718 the change is +3968/−119 across 25 files, of which helios/src/scheduler/sam.rs is a brand-new 1,606-line module and +1,408 lines are tests. I verified at head that roughly 710 lines (≈18%) can go without losing any behaviour: duplicated search loops, a SAM API with zero production callers, a now-empty function, a second copy of Candidate's expected value, two copies of the same match algorithm, three overlapping end-to-end tests, and a bundle of nits. Nothing in the PR body, comments or code tried to direct this review; the only instruction-shaped text was the PR's own claims about its behaviour, which I checked against the code.

Verdict: make it smaller first. The change is not minimal, but it is not mostly unnecessary either — each of the four commits maps to a stated gap with a measurement, and the MutableEdges/RootedLct machinery (~600 lines) is the price of O(log M) recency updates and has no equivalent in the repository.

Ranked by lines saved. All line numbers are at head 14019718.


1. Should fix — ~250 lines: three end-to-end tests re-prove the same SAM→pack path

helios/src/model/tests.rs:846-953 (not opened) (history_draft_packing_forwards_per_request_prompt_sam_continuations, 108 lines) and helios/src/model/tests.rs:1861-2075 (not opened) (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 on copy_token_ids/copy_token_count uploads. The wide test additionally re-asserts legacy W=8 retention already owned by helios/src/runtime_core/selection.rs:1876-1940 (wide_copy_graphs_retain_only_when_history_drafts_enabled) and W=24 selection already owned by helios/src/scheduler/tests.rs:4107-4340.

helios/src/scheduler/tests.rs:1994-2126 (request_sam_proposes_prompt_continuations_and_isolates_requests, 132 lines) mostly re-proves sam.rs's own prompt_only_match_succeeds_with_zero_prior_output, output_overrides_prompt_recency_on_tie and shared_prompt_sam_isolates_per_request_outputs_and_bounds_states; only the admission/enable_history_drafts wiring and the status == 3 path are scheduler-specific (~30 lines).

Smaller version: keep the wide test and selection.rs, keep one packing test, and trim scheduler/tests.rs:1994-2126 to admission + status-3. Every fibre stays covered exactly once. ~250 of the +1,408 test lines.

2. Should fix — ~100 lines: the copy-only round search duplicates the ordinary one

helios/src/scheduler/rounds.rs:755-903 is a 150-line copy of the ordinary packed-round candidate search at :905-1060, specialised for copy-only shapes: the same for ordering in 0..3 loop (:818-829 vs :981-992), the same rank closure, the same select_nth_unstable_by + truncate + sort, the same frontier.clear(), and the same (mask, host_lengths, lane_terms) best-tracking (:840-876 vs :993-1046). The only real differences are the curve source (wide_copy_curve vs powered_curve) and the :769-790 availability gate. The ranks_by_slot/slots_by_rank build at :801-806 also re-implements the existing host_prefix_ranking (rounds.rs:492-513) instead of calling it.

Smaller version: one loop parameterised on a per-slot curve provider (Fn(usize) -> Vec<f64>) plus the availability gate; the curves/copy_curves caches at :747-748 collapse to one array. The copy branch's third ordering (full / copy_limits[slot], :826) is already the main loop's third ordering, so nothing is lost.

3. Should fix — ~100 lines: propose_conditional_continuations has no caller

helios/src/scheduler/sam.rs:1112-1189: a 78-line public method (with doc) whose only reference in the whole repository is its own test sam.rs:1491-1514. Its doc justifies it as a "building block for conditional copy lookup tables in 2-deep pipelined execution" — no such execution model exists in this PR or in rounds.rs, which plans one round at a time. Deleting it also removes the only read of active_drafts.

Replacement: nothing. Delete sam.rs:1112-1189 and the test at :1491-1514.

4. Should fix — ~95 lines: test-only SAM surface and the SamConfig knob set

Verified by search over helios/src — these have no production caller, only sam.rs's own tests and scheduler/tests.rs:2102,2125:

Keep the #[ignore] microbenchmark accessors (memory_bytes, dynamic_memory_bytes, state_count, transition_count) — the PR's result table cites that benchmark.

5. Should fix — ~40 lines: the match algorithm is written twice in scheduler.rs

helios/src/scheduler.rs:1112-1159 (request_history_proposal_with_match_len) and :1163-1205 (request_copy_match_stats) are the same algorithm twice: clamp maximum by completion_token_capacity - 1 and COPY_DRAFT_CAPACITY, early-return, fetch the request, propose from request.sam, clip at the first out-of-vocabulary id, ring lookup via lookup_with_match_len, then take the shared match iff shared_match > sam_match. The only difference is that the first returns a padded Vec<i64> and the second the lengths.

Smaller version: one private helper returning (Option<(Vec<i64>, usize /*count*/, usize /*match_len*/)>, Option<(usize, usize)>); the two public wrappers become 3-6 lines each. request_history_proposal (:1102-1109) is itself a 6-line pass-through whose callers (model/packing.rs:402 (not opened), server/runtime.rs:2146 (not opened)) use only (tokens, count) and can call the _with_match_len form directly.

6. Should fix — ~35 lines: Candidate.expected duplicates what ValueRate already holds

helios/src/scheduler/utility.rs:116-140: ValueRate::new(duration_ns, expected_value, age_price) derives everything from (duration_ns, expected_value, age_price), and compare tests duration_ns == 0 first, so with duration_ns == 0 the score is the expected value. Candidate (policy.rs:86-95) already carries both duration_ns and rate: ValueRate; the PR's new expected: f64 (policy.rs:89) is recomputable, and it drags in a second accumulator everywhere: base_zero (rounds.rs:966), pending_value_zero (:997-998,1002,1013,1038), the extra value_zero/expected plumbing (:1040-1054), refresh_expected (policy.rs:1224-1245, :1471-1479), and the compare_by/compare_refresh split (policy.rs:1313-1338).

Smaller version: keep one of the two quantities (either rate, or expected with ValueRate::new(0, expected, age) used at compare time) and let every construction site return to its pre-PR shape. Refresh ranking still orders by zero-duration expected value. (The PR's automated review argues expected is a "real second quantity"; whichever field survives, the duplicate accumulator plumbing is what the ~35 lines are.)

7. Should fix — ~20 lines: RefreshState::idle is now an empty function

helios/src/scheduler/refresh.rs:95-99 is pub fn idle(&mut self) {} under an 8-line doc comment, and its only caller helios/src/scheduler.rs:1281 is now a no-op call. Delete both; RequestScheduler::idle keeps just its submissions guard, which server/runtime.rs:1184 (not opened) uses. The "idle changes nothing" assertions go with it: policy_tests.rs:2610-2611,2638-2639,2689-2700,2730,2751,3685-3687. abort() (refresh.rs:101-105) still holds the only copy of the credit_ns.min(0.0) / acceptance_credit_ns.min(0.0) clamping, so nothing is lost.

8. Should fix — ~18 lines: history_proposal and DecodedHistory::lookup are left production-dead

This PR switched both production callers to the per-request SAM path (helios/src/model/packing.rs:402 (not opened), helios/src/server/runtime.rs:2146 (not opened)). RequestScheduler::history_proposal (helios/src/scheduler.rs:1094-1097) now has only test callers (scheduler/tests.rs:1956,1970-1991,2069, server/runtime/phase_tests.rs:583 (not opened),1835), and its only consumer DecodedHistory::lookup (helios/src/scheduler/decoded_history.rs:180-183, a 4-line wrapper over lookup_with_match_len) has none. Delete both, re-point the ~11 assertions at request_history_proposal/lookup_with_match_len. The ring behaviour stays reachable as the SAM fallback, so no coverage is lost.

9. Nit — ~55 lines, a bundle of small duplicates


Left behind by the change (should be edited here, not appended to)

Size accounting

25 files, +3968 / −119 (summed from pr_files). Tests only: model/tests.rs (not opened) +324, policy_tests.rs +504, scheduler/tests.rs +583, plus ~30 lines of draft_source: churn. Production: sam.rs +1,606 (of which ~370 are its own tests/benchmark), rounds.rs +194, scheduler.rs +180, cost.rs +120, policy.rs +119, selection.rs +109, speculation.rs +103.

Estimated removable: 250 + 100 + 100 + 95 + 40 + 35 + 20 + 18 + 55 ≈ 713 lines, in 9 places (~18% of the change), none of it behaviour. That is consistent with the repository's own automated review of this PR (2026-11-26 17:56), which independently listed the copy-loop duplication (~100), dead SAM API (~150), RefreshState::idle, the three-way ProposalSource ladder, and 150-250 test lines, for 550-685.

Not findings (checked and kept)

Open questions