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

Raw Markdown for agents: https://autobot.eidonix.com/p/d65150d0-5df8-49d0-92b7-2813929e863e.md

Correctness, Contracts & System-Level Consequences — PR #608

PR: NVIDIA/hyperflare-inference#608 — "helios,ignition,ci: restore catalog validation, CPU Python tests, and script separation" (lukealonso, head 3343f13, merged 2026-11-29, zero reviews, zero comments).

Key findings

  1. Major — the console-script rename silently breaks the documented CLI contract. pyproject.toml:15 renames ignition → ignition-core, but no markdown file is touched and ~35 documented invocations still call .venv/bin/ignition. No shim, no version bump.
  2. Major (system-level) — fresh_duration now globally switches prefix/terminal checkpointing back on for cores whose smallest declared Snapshot batch ≠ 1, with no opt-in and no measurement. helios/src/scheduler/cost.rs:264-269; three gating call sites in checkpoints.rs:411,727,788.
  3. Major (metric/pricing span) — fresh_duration now quotes the smallest declared Snapshot batch while the planner may run a larger batch, so the checkpoint work budget under-prices the copy it authorises. checkpoints.rs:411-416 vs. policy_tests.rs:3080-3085.
  4. Major (contract tightening, unpriced) — catalog.rs per-batch parity is strictly stronger than the previous .any(...) existence checks, and required_batches is inflated by every Speculative graph batch (no token/prefill/sampling filter). Previously-loading third-party cores with an extra wide-speculative-only batch now fail to load; the new branch is untested; the core ABI version is unchanged.
  5. Minor — selection.rs fix is correct and mirrors the retention pass; the residual kind mismatch (speculative vs decode) is benign today but is a future trap. No admission/metric scope change.
  6. Minor — new CI workflow resolves a moving git dependency (uv sync without --locked), against the charter's "pin everything" rule, and the PR's evidence is against f7256584/pre-rebase bases, not the merged head; the failing check on head is unexplained.

1. Correctness, Safety & Platform Parity

1.1 Major — fresh_duration no longer means "the batch-1 graph"; every checkpoint gate silently changes meaning

helios/src/scheduler/cost.rs:264-269 (verified in file):

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 and deduped per kind in ActionCosts::prepared (cost.rs:179-186), so first() is the smallest declared batch for kind, not batch 1.

The three gates that consume this, all hardcoding tokens = 1 and no batch (helios/src/scheduler/checkpoints.rs, verified):

411        let Some(copy_ns) = self.costs.fresh_duration(GraphKind::Snapshot, 1) else {
412            return (accounting, true, false);
413        };
...
727        if self.costs.fresh_duration(GraphKind::Snapshot, 1).is_none() {
728            return Ok(false);
729        }
...
788        let Some(cost) = self.costs.fresh_duration(GraphKind::Snapshot, 1) else {
789            self.stats.checkpoint_skip_unknown_cost += 1;
790            return Ok(None);
791        };

Impact: on a core whose smallest declared Snapshot batch is not 1, all three gates previously returned the "unknown cost" branch — prefix checkpointing (checkpoint_selection), checkpoint copies (checkpoint_copy_allowed) and terminal snapshots (allocate_terminal_capture) were all silently disabled. After this PR they become active: new snapshot captures on the hot decode path, extra graph replays, more snapshot rows created/retained/evicted per request. That is the intended repair, and it is bandwidth-bounded by allowance(prefill, self.policy.checkpoint_extra_work_fraction) (checkpoints.rs:416, 734-738, 796-804), so it is not unbounded work — but it is a global default behaviour change on upgrade with no flag, no config gate, no served-workload measurement, and no mention of the retention/eviction consequence in the PR body. The PR describes it only as making "checkpoint duration lookups work".

Fix: state the behaviour change explicitly (cores with a non-1 smallest Snapshot batch start capturing checkpoints after upgrade) and gate it behind the existing policy knob or at minimum record it in the checkpoint stats so operators can see captures appearing; ideally add a scheduler-level test that drives checkpoint_selection on a batch-2-only core before/after the change.

1.2 Major — the quoted snapshot cost is taken from a graph shape the plan may not run (metric/rate span shrink)

Same cost.rs:265, consumed at checkpoints.rs:411-416:

411        let Some(copy_ns) = self.costs.fresh_duration(GraphKind::Snapshot, 1) else {
...
416        let available = allowance(prefill, self.policy.checkpoint_extra_work_fraction);

The planner does not necessarily run the smallest Snapshot batch. Verified example in helios/src/scheduler/policy_tests.rs:3064-3089, which keeps only batch_capacity == 2 snapshots and then plans a batch-2 snapshot for a single lane:

3069        graphs.retain(|g| g.kind != GraphKind::Snapshot || g.batch_capacity == 2);
...
3080        assert_eq!(s.costs.duration(GraphKind::Snapshot, 1, 1), None);
3081        assert_eq!(s.costs.duration(GraphKind::Snapshot, 2, 1), Some(nanos));
3082        let plan = s.plan().unwrap();
3083        assert_eq!(plan.kind, GraphKind::Snapshot);
3084        assert_eq!(plan.batch_capacity, 2);
3085        assert_eq!(plan.lanes.len(), 1);

So the price used to decide whether checkpoint work fits in checkpoint_extra_work_fraction of the prefill time is the duration of a row-padded, smallest-batch snapshot graph, while the step the scheduler will actually execute can be a wider batch with a longer copy. On cores that declare several Snapshot batches (the stock Python catalog declares 1,2,4,6,8,12,16,24,32,64 — ignition/components/capacity.py:66-68), copy_ns/cost understate the copy, and the allowance admits slightly more snapshot work than intended. Before the change the lookup matched the batch the plan typically used (1); now the two can diverge in either direction.

Fix: pass the batch the candidate/plan will use into fresh_duration (e.g. the batch of the snapshot step being priced) and keep batches(kind).first() only as the fallback when no plan batch is known. Add a test with two Snapshot batches of different durations asserting the allowance uses the planned one.

1.3 Note — the new cost.rs test only covers the happy path

cost.rs:415-446 (fresh_duration_uses_smallest_declared_batch_when_batch_one_is_absent) declares exactly one Snapshot graph at batch 2, so smallest == only == planned. It proves the ? early-return on an unmeasured table and nothing about the multi-batch under-quote in 1.2, and there is no test at the checkpoints.rs call sites proving the gates actually flip.

1.4 Sound — __deepcopy__ (ignition/direct/scheduler.py:449-459)

The added Request.__deepcopy__ memoizes before recursing (memo[id(self)] = copied) and re-wraps MappingProxyType attributes in a fresh proxy over a deep-copied dict, so the read-only invariant of _core_parameters is preserved while copy.deepcopy stops raising TypeError: cannot pickle 'mappingproxy' object at ignition/bench/runner.py:424,435 and tests/bench/test_runner.py:55,57. It also correctly falls through to object.__new__ + per-attribute copy, which covers subclasses. No cycle hazard beyond the normal memo contract. No issue found.


2. Unintended System-Level Consequences

2.1 Concurrency / contention — sound

Nothing in the diff touches locks, queues, or shared buffers. fresh_duration remains a read-only O(1) HashMap lookup on the scheduler's single-threaded planner path, and catalog::validate / selection::select run once at load. The selection.rs change removes a BTreeSet filter predicate cost (next_power_of_two() per graph) in favour of a precomputed min — marginally cheaper, no new allocation. No head-of-line blocking, no new unbounded buffering, no extra copies. The only memory effect is the one in §1.1 (snapshot retention starts happening on cores that previously retained nothing) and it is bounded by the checkpoint allowance.

2.2 Failure-propagation blast radius — one new failure mode at load time

catalog.rs turns a previously-accepted manifest into a hard load error (§3.1). That failure is fail-fast at validate, before serving, so it cannot poison a live scheduler; the cost is an upgrade regression for third-party cores, not a runtime hazard.

2.3 Optimisation-reverses-invariant check

selection.rs:175-187 fixes exactly such an inversion: the old active.next_power_of_two() filter kept batch-8 speculative graphs under active=5 while the retention pass at selection.rs:282-289 dropped them. Verified in the diff:

-            graph.kind == "speculative" && graph.batch_capacity <= active.next_power_of_two() as u64
+            graph.kind == "speculative" && graph.batch_capacity <= speculative_max_batch

with speculative_max_batch = min(batch_capacity) over speculative graphs with batch_capacity >= active, unwrap_or(active) — identical to retention's generation_kind computation. The two passes can no longer disagree. Correct.


3. Architecture, Contracts & Charter Compliance

3.1 Major — catalog.rs per-batch parity is a stronger load contract than before, and one input set is over-broad

helios/src/model/catalog.rs:146-170 (verified in diff) builds generation_batches from all Speculative graphs when speculation is prepared, while the Decode branch applies the full shape filter:

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        })
...
169    let required_batches: std::collections::BTreeSet<usize> =
170        lifecycle_batches.union(&generation_batches).copied().collect();

and the loop at catalog.rs:171-191 then demands Init/Restore/Snapshot/Resume for every batch in the union. Consequences:

Fix: restrict generation_batches to width-one Speculative graphs (the same shape filter the Decode branch uses) so a wide speculative graph cannot enlarge the required set, and add one test with an extra Speculative-only batch asserting which way the validation should go. Note the ABI/contract implication in the PR body.

3.2 Minor — residual kind mismatch in selection.rs

selection.rs:175-181 filters kind == "speculative" unconditionally, while the retention pass at selection.rs:282-289 uses generation_kind = if enabled { "speculative" } else { "decode" }. 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 widths are emptied when !enabled (selection.rs:188-193, 206) and fixed is None, but it is a latent trap for anyone editing those guards. Fix: filter on the same generation_kind expression in both places.

3.3 Major — console-script rename is an undeclared public-contract break

pyproject.toml:14-15:

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

was ignition = "ignition.__main__:main". The project name and version are unchanged (name = "ignition", version = "0.1.0", pyproject.toml:6-7), so nothing signals the break, and there is no shim, no deprecation, no wrapper. Every in-repo doc still instructs the old name (no markdown file appears in the diff):

Impact: in a core-only venv created exactly as docs/cli-design.md:58 (not opened) instructs (uv sync --locked --extra prepare --extra test), .venv/bin/ignition no longer exists, so all of those documented commands fail with "No such file or directory" (python -m ignition still works). Any wrapper, Dockerfile, systemd unit or CI step calling the core ignition entrypoint breaks silently at the same version number. The motivation (local-inference-lab/hyperflare-recipes#20, warm-cache uv sync clobber) is legitimate and the separation is the right call per AGENTS.md (not opened) (no plugin discovery in core) — the problem is that the doc and install contract was not carried along.

Fix: update the ~35 doc lines in this PR (or follow up immediately), and prefer shipping a transitional ignition shim that errors with "use ignition-core / python -m ignition" rather than a bare disappearance; bump the version so downstreams can pin around it.

3.4 Minor — charter pinning tension in the new workflow

.github/workflows/python-cpu.yml:29 (not opened):

        run: uv sync --extra prepare --extra test

No --locked, while docs/cli-design.md:58 (not opened) documents uv sync --locked; there is no uv.lock at head and flashinfer-python is pinned to branch = "main". Charter: "Be explicit and pin everything … pin dependencies to exact versions or commits (#215)". Every future PR now resolves a moving git dependency in the required CPU check. Fix: uv sync --locked with a committed lockfile, or pin flashinfer to a commit.


4. Tests & Claim Accuracy


Open questions / could not be found

  1. What failed in CI on head 3343f13? Not addressed in the description; the stated limitations cover only a stale local .venv binary and an unrelated BrokenPipe (#490).
  2. Does the deleted CUDA coverage (draft-block broadcast, vocabulary commit) exist in local-inference-lab/hyperflare-recipes? Not verifiable from this repository.
  3. Was the over-broad generation_batches (all Speculative graphs, no shape filter) intended, or an artifact of copying the Decode branch? No test or comment states the intent.
  4. Did anyone intend to update the ~35 .venv/bin/ignition doc references in a follow-up? No issue or PR was found.
  5. Is fresh_duration's smallest-declared-batch quote meant to be a conservative bound for all snapshot batches, or a stand-in for the planned batch? Neither the code nor the test comment says; the two readings differ exactly in the under-quote of §1.2.
  6. Whether #540 (open, adjacent scheduler cost/timing work) assumes the old batch: 1 semantics could not be determined from the available material.