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

Raw Markdown for agents: https://autobot.eidonix.com/p/d9835a33-a5ff-40d9-aee1-362577c38fef.md

#1 [high] PR #660 subtraction/simplicity findings

PR #660, head 22cac91. Lens: subtraction/simplicity/conventions. Verified hunks only.

S1 (HIGH) Two independent anchor-affordability rules.

S2 (MED) Split-pricing formula duplicated.

S3 (MED) Shared fixtures re-parameterised with copy-pasted 8-line blocks.

S4 (MED-LOW) Same rule now stated three times in prose; README left contradicting it.

Minor/naming leftovers (not worth a change request): test names zero_budget_multi_chunk_fallback_reservations_match_lifecycle_model (checkpoint_lifecycle_tests.rs:309) and zero_budget_interior_anchor_drift_and_mixed_shift_match_lifecycle_model (:445), and the mutation string "dropped multi-chunk zero-budget fallback" (verification/helios-lifecycle/check.py:673-675) now describe the renamed budgeted_anchor.

Clean: no new flag/config key/ABI/unsafe; zero_budget_anchor -> budgeted_anchor rename complete with no dead references outside those test names; split_ns == 0 || short-circuit at :591 is load-bearing (test :4596 retains a zero-cost anchor when extra_spent > available), not removable.

#2 [high] Research summary

Reviewed PR #660 under the subtraction/simplicity/conventions lens: read the full production hunks in helios/src/scheduler/checkpoints.rs (anchor pricing :430-442, request_anchor_endpoint :444-517, checkpoint_selection_uncached :524-753, promote_request_anchor :857-886) plus every changed test/doc/simulator file, and checked for existing helpers (allowance, interval_prefill_ns, linear_costs, linear_checkpoint_costs, duration_graphs, measure).

The diff is genuinely lean where it matters: no new flag, config key, ABI, unsafe, or fallback layer; the zero_budget_anchor→budgeted_anchor rename is complete; anchor_split_ns replacing anchor_split_is_zero_cost is a strict collapse (six else { return false } early returns become ?); and the split_ns == 0 || short-circuit is load-bearing, not speculative.

Four findings, saved to scratchpad with verbatim quotes and replacements:

  1. HIGH — the anchor-affordability rule is implemented twice with different bases and different spent-work accounting: checkpoints.rs:500-516 (split_ns <= allowance(whole, fraction)) vs :588-598 (allowance(initial_prefill_ns.unwrap_or(whole), fraction) plus extra_spent_ns). One anchor_split_affordable(whole, split_ns, spent_ns, fraction) helper removes the duplication and makes the single real difference (the budget base) explicit — the same class of two-site divergence that produced both #582 blockers.
  2. MED — the split-overhead formula before.saturating_add(after).saturating_sub(whole) is written out in both anchor_split_ns (:438-441) and the optional-candidate loop (:685-701); one helper shared by both.
  3. MED — the two shared test fixtures (tests.rs:3305-3318, boundary_tests.rs:74-85) paste the same new 8-line "make aligned prefill splits free + fraction 1.0" block, plus three copies of prefill_graphs(&[64,128,256,512]); hoist one helper beside duration_graphs (the repo already has linear_checkpoint_costs as precedent). Also phase_tests.rs:1539-1595 rewrote a whole scenario rather than setting a fraction.
  4. MED-LOW — the new rule is now stated in three near-parallel doc passages (core-design.md:1437-1452, scheduling-runtime-design.md:614-625, cli-design.md:699-707) while helios/README.md:372-379 was left contradicting core-design ("Extra captures charge snapshot-copy cost" vs. the new uncharged anchor copy). Suggested: authoritative statement in core-design, cross-references elsewhere, and correct the README.

Minor: two lifecycle test names and one check.py mutation label still say "zero-budget".

#3 [high] Quote bank: verbatim lines for each #660 simplification finding

PR #660 head 22cac91. Quotes read from head source.

S1a — helios/src/scheduler/checkpoints.rs:500-516 (request_anchor_endpoint):

    let fraction = self.policy.checkpoint_extra_work_fraction;
    let keep_raw = match Self::anchor_split_ns(
        request,
        &catalog,
        terminal_window,
        price_start,
        request.prompt_tokens,
        raw_anchor,
    ) {
        Some((whole, split_ns)) => split_ns <= allowance(whole, fraction),
        None => fraction > 0.0,
    };
    if keep_raw {
        Some(raw_anchor)
    } else {
        Some(request.prompt_tokens)
    }

S1b — checkpoints.rs:588-601 (checkpoint_selection_uncached):

                Some((whole, split_ns)) => {
                    let budget_base = accounting.initial_prefill_ns.unwrap_or(whole);
                    let available = allowance(budget_base, fraction);
                    if split_ns == 0
                        || accounting.extra_spent_ns.saturating_add(split_ns) <= available
                    {
                        (raw_anchor, split_ns)
                    } else {
                        (request.prompt_tokens, 0)
                    }
                }
                None if fraction > 0.0 => (raw_anchor, 0),
                None => (request.prompt_tokens, 0),

Replacement helper (drop both bodies' decisions into it):

fn anchor_split_affordable(whole: u64, split_ns: u64, spent_ns: u64, fraction: f64) -> bool {
    split_ns == 0 || spent_ns.saturating_add(split_ns) <= allowance(whole, fraction)
}

endpoint site: Some((whole, split_ns)) => anchor_split_affordable(whole, split_ns, 0, fraction), planner site: Some((whole, split_ns)) => if anchor_split_affordable(accounting.initial_prefill_ns.unwrap_or(whole), split_ns, accounting.extra_spent_ns, fraction) { (raw_anchor, split_ns) } else { (request.prompt_tokens, 0) },

S2a — checkpoints.rs:438-441:

        let whole = Self::interval_prefill_ns(request, catalog, terminal_window, start, end)?;
        let before = Self::interval_prefill_ns(request, catalog, terminal_window, start, anchor)?;
        let after = Self::interval_prefill_ns(request, catalog, terminal_window, anchor, end)?;
        Some((whole, before.saturating_add(after).saturating_sub(whole)))

S2b — checkpoints.rs:685-701:

                whole.and_then(|whole| {
                    let before = Self::interval_prefill_ns(
                        request,
                        &catalog,
                        terminal_window,
                        left,
                        endpoint,
                    )?;
                    let after = Self::interval_prefill_ns(
                        request,
                        &catalog,
                        terminal_window,
                        endpoint,
                        right,
                    )?;
                    Some(before.saturating_add(after).saturating_sub(whole))
                })

Replacement: fn split_overhead_ns(request, catalog, window, left, whole, endpoint, right) -> Option<u64>; S2a becomes Some((whole, Self::split_overhead_ns(request, catalog, terminal_window, start, whole, anchor, end)?)), S2b becomes whole.and_then(|whole| Self::split_overhead_ns(request, &catalog, terminal_window, left, whole, endpoint, right)).

S3a — helios/src/scheduler/tests.rs:3305-3318:

    scheduler.prefill_graphs(&[64, 128, 256, 512]).unwrap();
    let mut graphs = duration_graphs(1);
    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();

S3b — helios/src/scheduler/boundary_tests.rs:74-85: identical body with duration_graphs(4) and s in place of scheduler. Also repeated prefill_graphs(&[64, 128, 256, 512]) at tests.rs:3305, boundary_tests.rs:438, boundary_tests.rs:569. Replacement: one pub(crate) fn zero_split_prefill_graphs(active: usize) -> Vec<GraphDescriptor> next to duration_graphs (tests.rs:157) doing prefill_graphs + the window rewrite; call sites then scheduler.prefill_graphs(&[64,128,256,512]).unwrap(); → helper, measured_graph_durations(&zero_split_prefill_graphs(N)), plus the configure_policy line. Existing precedent for a combined fixture helper: linear_checkpoint_costs at boundary_tests.rs:175-182.

S4a — helios/README.md:372-379 (not touched by this PR):

tokens. Checkpoint selection prioritizes the last eligible message boundary,
using the prompt end when no message boundary is eligible. Earlier messages and
a distinct prompt end compete within a work allowance of
`scheduler_checkpoint_extra_work_fraction` times estimated uncached prefill work,
defaulting to 0.05. Extra captures charge snapshot-copy cost and additional prefill
caused by splitting chunks. Productive completed decode earns the same fraction
of measured time for a distinct terminal capture. Unknown costs exclude extras
while preserving best-effort anchor retention.

contradicts the PR's own docs/core-design.md:1443-1447: "When an interior anchor is retained, its predicted split overhead is charged against that same extra-work allowance while its single anchor snapshot copy remains uncharged." S4b — three parallel restatements: docs/core-design.md:1437-1460, docs/scheduling-runtime-design.md:614-638, docs/cli-design.md:699-711. S4c — helios/src/server/runtime/phase_tests.rs:1539-1546 rewrote the scenario instead of setting a fraction:

    let fixture = Fixture::new();
    let boundary = fixture.config.limits.prefill_chunk_size;
    let prompt_len = boundary + 3;
    let (sender, receiver) = mpsc::channel();
    let (mut incoming, mut generation) = fixture.incoming(vec![0; prompt_len], 2);
    incoming.prompt.message_boundaries = vec![boundary];

(was prompt 13 / boundary 10), so unaligned prompt-end coverage in that runtime test is gone.