Subtractive report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/23a3782d-749f-4583-acbf-f81930645e9a.md

Subtraction review of PR #540 — "Retain bounded timing-refresh credit across idle and exclude readiness wait" (head 982a9ce3, 10 files, +647/−47)

Key findings. The production change is already minimal: two small helpers (cost::observed_compute_duration_ns, cost::timing_refresh_duration_ns), two one-line call changes in RefreshState::complete, deleting RefreshState::idle, and the simulator flag the testing hierarchy requires. There is nothing to cut there. The weight is in tests and docs: about 140 of the 647 added lines (~22%) are removable, and almost all of it is duplicating tests that already existed or that this PR itself adds twice. No blocker; six findings, ranked by lines saved below.


1. Should fix — ~60 lines: the new cost.rs unit test re-proves two policy tests case for case

helios/src/scheduler/cost.rs:443-502 — compute_refresh_duration_excludes_readiness_wait_and_charges_positive_on_zero_compute builds ReadinessIntervals with wait_ns = 255_000 and asserts: isolated gpu 400 ms/wall 410 ms → Some(155_000) / 155_000; queued → Some(145_000) / 145_000; no GPU timing, wall 100 ms → None / 100_000; gpu 200 < wait 255 with wall 260 → None / 260_000; same with wall 0 → None / 200_000; gpu == wait == 255 → None / 255_000.

Every one of those cases is already asserted through the real ledger by tests this same PR adds:

What goes: the whole cost.rs:443-502 test. Replaces it: nothing. Both helpers stay exercised end to end via refresh.rs:74 and refresh.rs:87; the policy tests assert strictly more (they prove the ledger effect, not just the arithmetic). Nothing asserted in cost.rs is left unasserted. Saves ~58 lines and one duplicate readiness-timestamp fixture.

2. Should fix — ~35 lines: large_prefill_engine re-implements the existing engine_with_terminal_prefill

helios/src/scheduler/policy_tests.rs:5812-5878 is a 67-line copy of helios/src/scheduler/policy_tests.rs:4364-4406: same RequestScheduler::new + SchedulerCapabilities block (vision disabled, completion_token_capacity: 16, vocabulary: 1024, empty completion_inputs/speculative_allocations), same prefill_graphs/terminal_prefill_graphs calls, same duration_graphs(1) + retain(kind != Prefill …), same two GraphDescriptor push loops (identical fields, batch_capacity: 1, packed_token_capacity: 0, prefill_capacity: 0, input_bindings: vec![]), same measured_graph_durations.

The only real differences are the limits (131_072 sequence / 8192 chunk / 1 slot vs engine(1, false)'s 8192/512) and the duration formulas (10*MS/12*MS vs (cap/64+1)*MS/(cap/64+4)*MS).

What goes: the second builder. Replaces it: parameterize engine_with_terminal_prefill with (prefill_capacities, terminal_capacities, prefill_ns, terminal_ns) and keep one body; the new tests call it. Note the loop bodies are already parameterized in the existing helper (for &capacity in &[64usize, 128, 256, 512]), so the merge is mechanical. Saves ~35 lines.

3. Should fix — ~35 lines: the new Python CLI test repeats the partial_blocks test clause for clause

tests/test_scheduling_learning_experiments.py:746-790 (test_retain_idle_credit_cli_option_is_boolean_and_excluded_from_validation_overrides, 45 lines) asserts exactly the same five things as tests/test_scheduling_learning_experiments.py:492-509 (test_partial_block_uncertainty_is_explicit_and_keeps_default_ids) and :579-585 (test_validation_rejects_partial_block_override):

  1. default is False,
  2. flag ⇒ True and id.endswith(":<flag>=True"),
  3. pytest.raises(ValueError, match="sweeps are numeric") on --sweep <flag>=0,1,
  4. for value in (None, 0, 1, "true"): pytest.raises(ValueError, match="boolean") on the dataclass field,
  5. main(["--preset", "validate", "--configs", …, "--<flag>"]) ⇒ SystemExit code 2.

What goes: the separate function. Replaces it: add ("--partial-blocks", "partial_blocks") / ("--retain-idle-credit", "retain_idle_credit") as a parametrized case of the existing structure. Saves ~35 of the 47 added lines: the behaviour tested is identical, only the flag name differs.

4. Nit — ~12 lines: RequestScheduler::idle is now a precondition assertion its only caller already guarantees

helios/src/scheduler.rs:1158-1168. Since this PR folded RefreshState::idle's body into RefreshState::abort (helios/src/scheduler/refresh.rs:95-99), RequestScheduler::idle no longer touches any ledger; it only does if !self.submissions.is_empty() { return Err("idle requires no submitted execution") }. Its one production caller, helios/src/server/runtime.rs:1184, sits in the else of if executor.outstanding() > 0 (line 1177), i.e. only when nothing is in flight, and submissions entries are removed only in complete_inner (scheduler.rs:2656) and clear (:3061) — so the error branch is unreachable from production.

What goes: idle() and the call at runtime.rs:1184, plus its 10 test call sites (policy_tests.rs:2466, 2497, 2552, 2562, 2593, 2614, 5909, 5952, 6041) and the assert!(s.idle().is_err()) at :2483, which tests only the removed precondition. Keep RefreshState::abort and the release_after_shutdown call (scheduler.rs:3062) — that is the real "discard positive credit, keep debt" site. Saving is modest in production lines because the call sites are test-only, but it removes a 3-line doc comment that restates the PR description and an API that now validates nothing.

5. Nit — ~10 lines: timing_refresh_duration_ns is a one-call-site wrapper

helios/src/scheduler/cost.rs:47-57: six lines of doc plus a three-line body over observed_compute_duration_ns, with exactly one call site, helios/src/scheduler/refresh.rs:87. Inline it:

self.credit_ns -= cost::observed_compute_duration_ns(timing)
    .or_else(|| cost::observed_duration_ns(timing))
    .unwrap_or(timing.wall_ns) as f64;

observed_compute_duration_ns (cost.rs:31-45) keeps its doc, which already states the guard and the ActionCosts::observe mirroring — the wrapper's doc repeats the same two facts. Saves ~10 lines. (Keeping observed_compute_duration_ns separate is right: ActionCosts::observe at cost.rs:330-337 uses saturating_sub, which is the zero-charge hazard this PR removes, so they cannot share code.)

6. Nit — ~15 lines: both new doc facts are stated two to three times each

Keep one statement per fact per document (the scheduling-runtime-design.md:434-474 "Funded timing refresh" paragraph and the scheduling-runtime-design.md:496-499 summary sentence carry everything the four restatements say). Saves ~15 lines with no loss of a rule, constant or cross-reference.


Left behind by this change (not a subtraction — must be fixed in the same PR)

helios/README.md:437 still reads "Another refresh waits for full credit. Idle discards positive credit and preserves debt." This PR does the opposite (helios/src/scheduler/refresh.rs:95-99, docs/scheduling-runtime-design.md:443-444), so the PR makes its own repo's README wrong. One sentence edit; I flag it as a defect rather than a cut because leaving it costs a reader more than it saves.

Deliberately kept (verified, not findings)

Size accounting

Added 647 / removed 47 across 10 files (policy_tests.rs +394, cost.rs +89, learning*/tests +102, docs +45, refresh.rs/scheduler.rs +17/−11). Confirmed removable: 58 + 35 + 35 + 12 + 10 + 15 = ~165 gross, ~140 honest after keeping one doc statement per fact. Verdict: make it smaller first — but only in tests and docs; the production diff is minimal and should be merged as-is.

Open questions / not found