Subtraction and simplicity report · NVIDIA/hyperflare-inference #660

Raw Markdown for agents: https://autobot.eidonix.com/p/5741f381-e397-4694-b884-0ebb9febbacb.md

Subtraction, Simplicity & Conventions review — PR #660 (helios/scheduler: budget interior conversation-anchor splits)

Head reviewed: cf744dffef8d (tree 0a77b1c0), 12 files, +887/−151; helios/src/scheduler/checkpoints.rs +751/−87 (~+35 net production LOC).

Key findings

  1. The production diff is lean and should be accepted as-is. No new flags, no config knob, no env var, no unsafe, no ABI change. anchor_split_affordable (checkpoints.rs:96-98), split_overhead_ns (:434-446) and anchor_split_ns (:448-467) each have two real callers and replace rather than shadow the old anchor_split_is_zero_cost. Nothing to subtract here. All subtractable material is in the test fixtures and in helios/README.md.
  2. (high) Dead policy block in a new test — delete 6 lines. checkpoints.rs:4362-4380: the test configures fraction 0.5, then overwrites it with 0.279 before any admission, so the first configure_policy can never affect behaviour.
  3. (high) helios/README.md:372-390 re-states the normative rule instead of delegating, duplicating docs/core-design.md:1439-1457 nearly verbatim; the same commit already does it right in docs/scheduling-runtime-design.md:614-621.
  4. (high) tests::permissive_checkpoint_costs (tests.rs:163-184) is over-parameterized: its Option<&[usize]> knob exists only so two call sites can install the identical catalog one line later, and its configure_policy step is the reason prefill_to_publication_boundary cannot simply call it.
  5. (medium) Four verbatim copies of the same stepped prefill cost fixture in the six new default-fraction tests (checkpoints.rs:4369-4372, and the openings at :4508, :4623, :4686-4692).
  6. (medium, only production-side wart) The budgeted_anchor latch tuple and its identity predicate are open-coded at two match sites and three write sites (checkpoints.rs:477-482, :634, :636-640, :643-644, :893-903). This PR broadens that latch to every fraction, so it now deserves a name and a matches method.

S1 (high) — Delete the dead checkpoint_extra_work_fraction: 0.5 block

helios/src/scheduler/checkpoints.rs:4361-4380, test default_fraction_anchor_guard_revocation_preserves_charged_anchor_split:

    fn default_fraction_anchor_guard_revocation_preserves_charged_anchor_split() {
        let mut scheduler = super::super::tests::scheduler(1, 128, 16);
        scheduler
            .configure_policy(PolicyConfig {
                checkpoint_extra_work_fraction: 0.5,
                ..Default::default()
            })
            .unwrap();
        for (tokens, nanos) in [(128, 100), (256, 110), (512, 200)] {
            measure(&mut scheduler, GraphKind::Prefill, tokens, nanos);
        }
        measure(&mut scheduler, GraphKind::Snapshot, 1, 1);
        // Boundaries [768, 896]: anchor 896 has split_ns=110, message 768 has split_ns=0, copy=1,
        // prompt end 1024 is excluded by setting fraction so only 896+768 fit (allowance=111 -> 0.279).
        scheduler
            .configure_policy(PolicyConfig {
                checkpoint_extra_work_fraction: 0.279,
                ..Default::default()
            })
            .unwrap();

No admit, plan, measurement or selection occurs between the two configure_policy calls, and no test-body read of the policy exists — 0.5 at :4365 is unreachable configuration. Remove :4363-4368 (the six lines of the first configure_policy call) and keep the 0.279 call at :4375-4380, whose comment already carries the derivation (allowance=111 -> 0.279). The test's assertions are unaffected. This looks like a leftover from an intermediate version where the test first asserted a 0.5-fraction outcome.

S2 (high) — Collapse helios/README.md back to a summary that delegates

helios/README.md:372-390:

Checkpoint selection takes the last eligible message boundary as the candidate
conversation anchor, using the prompt end when no message boundary is eligible.
An interior message boundary before the prompt end is retained as the anchor only
when its predicted prefill split fits the request-local work allowance of
`scheduler_checkpoint_extra_work_fraction` times estimated uncached prefill work
(defaulting to 0.05, and reducing to exact zero split cost at 0.0); otherwise the
zero-split prompt end serves as the anchor. A retained interior anchor charges its
predicted split work against that shared allowance while keeping its anchor
snapshot copy uncharged.
...
Unmeasured prefill costs or unknown or stale snapshot-copy costs exclude extras while
preserving best-effort anchor retention under a nonzero fraction (falling back to
the prompt end when the fraction is zero). There is no capture-count cap or
per-request share of snapshot rows.

This is a second normative copy of docs/core-design.md:1439-1446 (retention predicate and allowance) and :1450-1457 (charged split, uncharged anchor copy, unknown-cost arms). Two normative copies drift; this PR is itself the proof (it had to edit both, plus docs/cli-design.md:696-710). The commit already establishes the correct pattern one file over — docs/scheduling-runtime-design.md:614-621 reduces the same rule to a summary that links [exact endpoint capture](core-design.md#exact-endpoint-capture).

Replace README.md:374-386 with two sentences, e.g. "An interior message boundary before the prompt end is kept as the conversation anchor only when its predicted prefill split fits the scheduler_checkpoint_extra_work_fraction allowance, charged against the same shared allowance as optional captures; otherwise, and whenever prefill cost is unknown at fraction 0.0, the zero-split prompt end is the anchor." Then rely on the link already present at :390 (See [checkpoint ownership](../docs/core-design.md#exact-endpoint-capture)), which the README can make the single pointer for the retention/charging details. Net: one normative copy, two summaries.

S3 (high) — Make permissive_checkpoint_costs non-optional and split its policy step

helios/src/scheduler/tests.rs:161-184:

pub(super) const STANDARD_PREFILL_CAPACITIES: &[usize] = &[64, 128, 256, 512];

pub(super) fn permissive_checkpoint_costs(
    scheduler: &mut RequestScheduler,
    active: usize,
    prefill_capacities: Option<&[usize]>,
) {
    if let Some(capacities) = prefill_capacities {
        scheduler.prefill_graphs(capacities).unwrap();
    }
    let mut graphs = duration_graphs(active);
    for g in &mut graphs {
        if g.kind == GraphKind::Prefill {
            g.estimated_duration_ns = 100_000 + g.token_capacity as u64;
        }
    }
    scheduler.measured_graph_durations(&graphs).unwrap();
    scheduler
        .configure_policy(PolicyConfig {
            checkpoint_extra_work_fraction: 1.0,
            ..Default::default()
        })
        .unwrap();
}

There are exactly three call sites, and all three want the same catalog:

So None and Some(STANDARD_PREFILL_CAPACITIES) are functionally the same intent; the Option (tests.rs:166) buys nothing and costs two extra prefill_graphs lines plus a branch. Drop the prefill_capacities parameter and always call scheduler.prefill_graphs(STANDARD_PREFILL_CAPACITIES) at the top, deleting the two follow-up calls at boundary_tests.rs:427-428 and :559-560. (Note prefill_graphs only sets the selectable catalog — scheduler.rs:786-802 — it does not filter what measured_graph_durations accepts, so installing it early is safe.)

Second, unrelated concern fused into the helper: prefill_to_publication_boundary (tests.rs:3328-3330) wants only the permissive policy, on a host_scheduler whose graph list it does not need rewritten:

fn prefill_to_publication_boundary(tokens: usize, boundary: usize) -> (RequestScheduler, RequestHandle) {
    let mut scheduler = host_scheduler(1, 8, 4);
    permissive_checkpoint_costs(&mut scheduler, 1, Some(STANDARD_PREFILL_CAPACITIES));

Here host_scheduler already ran measured_graph_durations(&duration_graphs(active)) (tests.rs:152-154), and the helper immediately re-runs it over an almost identical list with only Prefill durations rewritten (duration_graphs_for_batches already emits Prefill for every capacity 64..=8192, tests.rs:217-234), so the builder's measurement is discarded at every call site. Split the policy write into a two-line permissive_checkpoint_fraction(scheduler) (or just inline the configure_policy at :3328-3330), leaving permissive_checkpoint_costs for the cases that genuinely need rewritten costs. That removes one redundant measurement per call site and the Option.

S4 (medium) — One shared stepped-cost fixture instead of four copies

helios/src/scheduler/checkpoints.rs:4369-4372 (verified verbatim):

        for (tokens, nanos) in [(128, 100), (256, 110), (512, 200)] {
            measure(&mut scheduler, GraphKind::Prefill, tokens, nanos);
        }
        measure(&mut scheduler, GraphKind::Snapshot, 1, 1);

The same loop with the same (128,100), (256,110), (512,200) table opens the other new tests too — at :4508 (anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget), :4623 (zero_split_interior_anchor_retained_when_extra_spent_exceeds_available) and :4686-4692 (request_anchor_endpoint_matches_selection_with_spent_budget_and_no_latch) — with only the Snapshot duration varying between sites (I verified the :4369-4372 instance directly and the other three openings from my reading notes; the varying snapshot value is itself the smell). The module already has the right shape for this next door: linear_costs (checkpoints.rs:1151-1161).

Add one fn stepped_costs(scheduler: &mut RequestScheduler, snapshot_ns: u64) beside linear_costs and call it at all four sites. All assertions survive; four copies of the cost table and their repeated "110 ns split / 90 ns extra" arithmetic comments collapse to one documented table.

S5 (medium) — Name the budgeted_anchor latch

helios/src/scheduler/checkpoints.rs:477-482 (and again at :636-640, same shape):

        if let Some((latched_raw, latched_prompt, chosen)) = request.checkpoints.budgeted_anchor
            && latched_raw == raw_anchor
            && latched_prompt == request.prompt_tokens

with the write side repeated at :634, :643-644 and promote_request_anchor (:893-903; the field is declared at :28). A 3-tuple latch whose identity predicate is open-coded at two decision sites is the one place in this PR where a small abstraction is missing rather than excessive — and this PR is what broadens the latch from zero-fraction-only to every fraction, so the duplication now sits on the hot selection path.

Give it a name: either struct BudgetedAnchor { raw: usize, prompt: usize, chosen: usize } with fn matches(&self, raw: usize, prompt: usize) -> Option<usize> on CheckpointAccounting, or a two-line free function budgeted_anchor_matches(latched, raw_anchor, prompt_tokens) -> Option<usize>. Both match sites become if let Some(chosen) = ...matches(raw_anchor, request.prompt_tokens). Two of the three write sites also lose their tuple construction. (Line numbers here are from my reading notes on cf744dff; the shape was stable across the head, but re-confirm offsets before applying.)


Checked and deliberately not suggested

Conventions check (structural only)

Against the repo AGENTS.md constraints this PR is clean: no new flag, config knob or env var; no per-model branch; and the budget change tightens rather than relaxes a guarantee, so no invariant is weakened. The only convention-adjacent issue is documentary duplication (S2) — one rule now stated normatively in docs/core-design.md and again at length in helios/README.md. Dossier item 2's loss of phase-level default-0.05 coverage (phase_tests.rs:1542-1546) is a coverage matter for the test lens, not a structural convention violation.

Verdict

Production code: lean, idiomatic, nothing to remove — I would merge as-is on this lens. Five small deletions/consolidations are worth doing, of which S1 (6 dead lines), S2 (a duplicated normative paragraph) and S3 (a pointless Option plus a redundant measurement) are the substantive ones.

Open questions / could not verify