Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #608

Raw Markdown for agents: https://autobot.eidonix.com/p/dc82f175-1b13-41ad-ab43-ec8ba75b89d8.md

#1 [high] Console-script rename breaks documented CLI contract (Major)

file: pyproject.toml:14-15

[project.scripts]
ignition-core = "ignition.__main__:main"

(was ignition = "ignition.__main__:main"). Project still name = "ignition", version = "0.1.0" (pyproject.toml:6-7) — i.e. no version bump signalling the breaking rename, and no compatibility shim.

Still-documented invocations of the OLD name (verified by search_code '.venv/bin/ignition', 35 hits, no markdown file touched by this PR):

Impact: in a core-only venv created exactly as docs/cli-design.md instructs (uv sync --locked --extra prepare --extra test), .venv/bin/ignition no longer exists, so every one of those documented commands fails with "No such file or directory" while python -m ignition still works. Any external wrapper/Dockerfile/systemd unit/CI step calling the core ignition entrypoint breaks silently (same install, different binary name). PR description does not mention the doc/markdown surface.

Fix: update the ~35 doc lines in this PR (or add a ignition shim that prints the new name and exits non-zero), and bump/flag the version.

#2 [high] cost.rs fresh_duration globally enables prefix checkpointing on non-batch-1 Snapshot cores (Major, system-level)

file: helios/src/scheduler/cost.rs:264-269

pub fn fresh_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
    let batch = self.batches(kind).first().copied()?;
    let key = Key { drafts: 0, kind, batch, tokens, prefill: 0, packed: 0 };
    self.entry(key).filter(|estimate| estimate.fresh(self.now_ns, self.ttl_ns))
        .map(|estimate| estimate.nanos)
}

batches is sorted+deduped (cost.rs:179-186), so first() = smallest declared batch for the kind.

Downstream gating (all three call sites pass tokens=1 and now resolve to the smallest Snapshot batch):

Consequence 1 (intended, but unannounced & no opt-in): cores whose smallest declared Snapshot batch is not 1 previously had prefix/terminal checkpointing silently and globally disabled; after this change they start capturing snapshots autonomously. That is a new global default behaviour change (extra graph replays, extra snapshot-row retention/eviction pressure in the scheduler) with no flag, no config gate and no served-workload measurement in the PR body. Blast radius is bounded by allowance(prefill, self.policy.checkpoint_extra_work_fraction) (checkpoints.rs:416, 734-738, 796-804), so it is a cost/behaviour shift rather than unbounded work — but it does change retention/eviction behaviour for those deployments.

Consequence 2 (metric/pricing span): the quoted duration is now the smallest-batch snapshot graph, while the step the scheduler actually plans can be a larger batch. Verified example: helios/src/scheduler/policy_tests.rs:3064-3085 keeps only batch_capacity == 2 Snapshots, asserts s.costs.duration(GraphKind::Snapshot, 1, 1) == None / duration(Snapshot, 2, 1) == Some(nanos), then let plan = s.plan().unwrap(); assert_eq!(plan.batch_capacity, 2). With the new code fresh_duration(Snapshot, 1) returns the batch-2 estimate, i.e. the admission/allowance price is taken from a graph shape chosen only because it is the smallest available, not from the shape that will run. When several Snapshot batches exist the planned step can be batch > smallest (row-padded copy), so copy_ns/cost understate the true copy time, making checkpoint_extra_work_fraction allow slightly more snapshot work than intended.

Fix: pass the batch the plan will use (or the batch the candidate would use) into fresh_duration instead of deriving it from batches(kind).first(); keep the "smallest declared batch" only as the fallback, and state the behaviour change for non-batch-1 cores in the PR body / docs.

#3 [high] catalog.rs: required_batches union includes non-width-one Speculative batches (Major, contract tightening)

file: helios/src/model/catalog.rs:130-238 (validate_inner replacement of the .any(...) checks)

generation_batches is built from all Speculative graphs when speculation is prepared, without the token_capacity==1 / prefill_capacity==0 / sampling_mode==General filter the Decode branch has:

146    let generation_batches: std::collections::BTreeSet<usize> = manifest
147        .graphs
148        .iter()
149        .filter(|graph| {
150            if config.speculative_widths.is_empty() {
151                graph.kind == GraphKind::Decode
...
155            } else {
156                graph.kind == GraphKind::Speculative
157            }
158        })

and required_batches = lifecycle_batches ∪ generation_batches (:169-170); the loop then demands Init/Restore/Snapshot/Resume for every one of those batches (:171-179) plus Decode when speculation is absent (:180-190).

Stock Python path is safe: ignition/components/capacity.py:66-68 batch_capacities = (1,2,4,6,8,12,16,24,32,64) and speculative_shapes (:80-88) / parallel_speculative_shapes (:160-171) / mixed_shapes (:142-157) all iterate the same batch_capacities, and packed_speculative_shapes (:91-132) only narrows within a batch, so no batch exists on a wider Speculative graph alone. No false rejection found there (mixed_shapes only emits batch>1, but lifecycle graphs cover those batches already).

Regression risk: the invariant is strictly stronger than the old manifest-wide .any(...) existence check, so any core exported by older or third-party tooling that omitted e.g. Resume/Decode for a batch that appears only on a wide Speculative graph now fails to LOAD ("prepared model lacks ... graph for batch N") where it previously loaded and served. PR body frames this only as "restores catalog validation"; no migration note, no version bump on the core ABI (abi_version stays 6, ignition/preparation/execution.py:311).

Untested branch: no test covers "extra batch present only on a wider Speculative graph"; the fixed regression test (helios/src/model/packed_round_tests.rs:68-108, esp. :100-107 asserting an error for missing (Speculative,2) and (Speculative,4)) builds from testing::manifest which emits every kind for batches [1,2,4] (helios/src/model/testing.rs:49-59), so it exercises only the self-consistent case.

Asymmetry: parity is enforced only over batches declared by the lifecycle or generation set — a batch declared only by Mixed/Prefill/Vision graphs is never required to have lifecycle/decode graphs (catalog.rs:169-191).

#4 [medium] selection.rs: eligible_widths fix is correct; residual latent kind mismatch only

file: helios/src/runtime_core/selection.rs:175-187

175        let speculative_max_batch = execution
176            .graphs.iter()
177            .filter(|g| g.kind == "speculative" && g.batch_capacity >= active as u64)
178            .map(|g| g.batch_capacity).min().unwrap_or(active as u64);
182        let eligible_widths: BTreeSet<_> = execution.graphs.iter().filter(|graph|
183            graph.kind == "speculative" && graph.batch_capacity <= speculative_max_batch

Now mirrors retention exactly (selection.rs:283-289 uses the same filter(batch_capacity >= active).min().unwrap_or(active) for generation_kind), so eligible_widths and max_batch can no longer disagree. Old code used active.next_power_of_two(): with active=5 and batches 6/8 it kept batch<=8 while retention kept <=6 — a real divergence, correctly fixed with a targeted regression test.

Residual (benign) inconsistency: speculative_max_batch filters kind "speculative" unconditionally, while retention uses generation_kind = if enabled { "speculative" } else { "decode" } (:282). With speculation disabled (enabled == false, e.g. mtp_draft_tokens == Some(0)) eligible_widths can be non-empty from speculative graphs that retention will drop; harmless today because fixed is None and widths are emptied when !enabled (:188-193, :206), but a trap for future edits to those guards.

active = max_concurrency.unwrap_or(prepared) (:121) validated 1..=prepared (:122); fallback unwrap_or(active) matches retention's. New test selection.rs:1899-1945 (max_active 8, batches 6 and 8, width 8 only on batch 8, max_concurrency 5, expecting "no captured speculative width fits") genuinely exercises the covering-batch path: it also adds batch-6/8 lifecycle graphs and width-one speculative graphs so the per-batch checks at :317-354 stay satisfied. Fixture host_wide_round_core at :1833-1846.

No rate/latency/admission metric changes scope here — it only changes which widths are selectable at load time, before serving metrics exist. Area is sound.