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

Raw Markdown for agents: https://autobot.eidonix.com/p/a7e749a7-09f3-4e45-96d3-c67c0568ffde.md

#1 [high] Research summary

Subtraction / Simplicity / Conventions review of PR #660 (head cf744dffef8d).

Production code in helios/src/scheduler/checkpoints.rs is genuinely lean: the =+35 net prod LOC are three small functions (split_overhead_ns, anchor_split_ns, anchor_split_affordable) plus call-site substitutions, no new flags, no config knob, no unsafe, and the removed anchor_split_is_zero_cost bodies are replaced by the same interval arithmetic, not shadowed. The deferrals that remain (two decision sites with different interval bases, the split_ns == 0 || short-circuit) are load-bearing, not speculative generality — I have nothing to propose there. What can be subtracted is almost all in the test fixtures and docs.

1. Dead configure_policy block in a new test — delete 6 lines. helios/src/scheduler/checkpoints.rs:4362-4380: the test sets fraction 0.5, measures costs, then sets 0.279 before any admission, so the first block can never affect behaviour:

        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)] {

Remove the first configure_policy call (:4363-4368) and keep the 0.279 one at :4375-4380; the comment on it already states the intended allowance (allowance=111 -> 0.279).

2. helios/README.md re-states the whole normative rule instead of delegating — ~15 lines that duplicate docs/core-design.md. helios/README.md:372-390 says "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 … A retained interior anchor charges its predicted split work against that shared allowance while keeping its anchor snapshot copy uncharged …" which is the same text as docs/core-design.md:1439-1446 and :1450-1457. The PR already shows the right pattern in the same commit: docs/scheduling-runtime-design.md:614-621 compresses this to a summary that links [exact endpoint capture](core-design.md#exact-endpoint-capture). Cut README:374-386 to two sentences ("an interior message boundary is kept as the anchor only when its predicted prefill split fits the scheduler_checkpoint_extra_work_fraction allowance, charged against the same shared allowance; otherwise the zero-split prompt end is the anchor") and link ../docs/core-design.md#exact-endpoint-capture, which the README already does on the following line. One normative copy, two summaries.

3. tests::permissive_checkpoint_costs conflates three separate fixture steps and duplicates work the scheduler builders already did. helios/src/scheduler/tests.rs:163-184 installs optional prefill graphs, rewrites every prefill duration, and sets the policy to 1.0:

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);

Two concrete costs: (a) its last step repeats what the builders already did — scheduler()/host_scheduler() call measured_graph_durations(&duration_graphs(active)) at tests.rs:152-154, and prefill_to_publication_boundary (tests.rs:3328-3330) calls the helper on top of host_scheduler, installing the identical graph list a second time; (b) the Option<&[usize]> knob exists only so two call sites can then add their own s.prefill_graphs(super::tests::STANDARD_PREFILL_CAPACITIES) afterwards (boundary_tests.rs:427-428, :559-560). Make the capacities non-optional (always install STANDARD_PREFILL_CAPACITIES; callers that need a different catalog already call prefill_graphs themselves before measuring), and make the graph list an argument or split out the configure_policy step, so the None arm at tests.rs:3330 can be a plain policy call. That removes the Option, one redundant measured_graph_durations per call site, and the two follow-up prefill_graphs lines.

4. Four verbatim copies of the same stepped prefill cost fixture in the new tests. Each of default_fraction_anchor_guard_revocation_preserves_charged_anchor_split (checkpoints.rs:4369-4372), anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget (:4508 region), zero_split_interior_anchor_retained_when_extra_spent_exceeds_available (:4623 region) and request_anchor_endpoint_matches_selection_with_spent_budget_and_no_latch (:4686-4692) opens with:

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

next to the existing linear_costs (:1151-1161). Add one stepped_costs(scheduler, snapshot_ns) beside linear_costs and call it four times; the tests keep all their assertions and lose four copies of the cost table (each with a comment explaining the 110/90 ns arithmetic that only needs stating once).

5. The latch triple and its match predicate are spelled out three times. checkpoints.rs:477-482 and :636-640 both open-code identity on the tuple:

        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 :893-903. Since this PR renames and broadens the latch to every fraction, give it the shape it already has a name for — either a struct BudgetedAnchor { raw, prompt, chosen } with fn matches(&self, raw, prompt) -> Option<usize> on CheckpointAccounting, or a two-line budgeted_anchor_matches free function — collapsing both match sites to one line and removing the unused-in-one-branch tuple destructuring. This is the only structural wart the PR carries on the production side.

Everything else I checked is fine: anchor_split_affordable is the right single home for the predicate, split_overhead_ns is genuinely shared by both the anchor path and the optional-candidate loop (the loop reuses its cached whole), promote_request_anchor lost its fraction == 0.0 guard rather than gaining a branch, and the doc long-line wrap regressions in docs/cli-design.md:699-708 / docs/core-design.md:1457 are formatting only, not a structural convention violation.

#2 [high] PR #660 Subtraction/Simplicity lens — verdict and five suggestions

LENS: Subtraction, Simplicity & Conventions. PR #660, head cf744dffef8d, 12 files +887/-151, checkpoints.rs +751/-87 (~+35 net prod LOC).

VERDICT: production diff is lean and idiomatic. No new flags, no config knob, no unsafe, no ABI change. The three new helpers are justified:

S1 (high) DEAD POLICY BLOCK in new test. helios/src/scheduler/checkpoints.rs:4362-4380

        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)] {

test then sets 0.279 before any admission (:4375-4380), so the 0.5 block (:4363-4368) can never affect behaviour. Delete those 6 lines; the 0.279 comment already states allowance=111 -> 0.279. Test: default_fraction_anchor_guard_revocation_preserves_charged_anchor_split.

S2 (high) helios/README.md:372-390 restates the normative rule instead of delegating. It repeats docs/core-design.md:1439-1446 and :1450-1457 nearly verbatim ("...retained as the anchor only when its predicted prefill split fits the request-local work allowance of scheduler_checkpoint_extra_work_fraction... charges its predicted split work against that shared allowance while keeping its anchor snapshot copy uncharged"). The same commit already shows the right pattern at docs/scheduling-runtime-design.md:614-621, a two-sentence summary delegating to exact endpoint capture. Fix: cut README:374-386 to ~2 sentences + link ../docs/core-design.md#exact-endpoint-capture (README already links it at :390). One normative copy, two summaries. NOTE: dossier item 5 said README is "no longer stale" — true, but it over-corrected into duplication.

S3 (high) tests::permissive_checkpoint_costs over-parameterized + redundant work. helios/src/scheduler/tests.rs:163-184

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);

S4 (medium) Four verbatim copies of the stepped cost fixture in new tests: checkpoints.rs:4369-4372, :4508 region (anchor_only_multi_chunk_prefill_preserves_split_cost_and_budget), :4623 region (zero_split_interior_anchor_retained_when_extra_spent_exceeds_available), :4686-4692 (request_anchor_endpoint_matches_selection_with_spent_budget_and_no_latch).

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

Existing linear_costs at checkpoints.rs:1151-1161 already in that test module. Add stepped_costs(scheduler, snapshot_ns); keeps all assertions, removes four duplicated cost tables plus their repeated 110/90 ns arithmetic comments.

S5 (medium) The budgeted_anchor latch triple + match predicate spelled out three times: checkpoints.rs:477-482 and :636-640 both open-code

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

with writes at :634, :643-644, :893-903. Since this PR broadens the latch to every fraction, give it a shape: struct BudgetedAnchor { raw, prompt, chosen } with fn matches(&self, raw, prompt) -> Option<usize> on CheckpointAccounting (field at checkpoints.rs:28), or a two-line free function. Collapses both match sites to one line. Only structural wart on the production side.

EXPLICITLY NOT SUGGESTED (checked, rejected as nitpick/non-issue): doc long-line wrap regressions docs/cli-design.md:699-708 and docs/core-design.md:1457 (handled as formatting by another lens); renaming zero_budget in 3 stale test comments/strings (checkpoints.rs:3190, :3522, :3846 — trivial); the two decision sites' differing interval bases (correctness lens, dossier item 6); the retained early returns in request_anchor_endpoint (:474, :503, :510, :517 — load-bearing).

Conventions check against AGENTS.md: no new flag/config knob/env var (AGENTS.md:450-460 clean), no per-model branch (:338-351 clean), no weakened guarantee (:182-186 clean — budget is tightened, not relaxed). The fixture workarounds (S1/S3/S4 and the dossier's permissive_checkpoint_costs story) are legitimate test-fixture simplification, not architectural violations, though AGENTS.md:194-199 ("tests must exercise the affected behavior") is adjacent to dossier item 2's lost phase-level 0.05 coverage — that is the test-coverage lens's point, not mine.