Deep Correctness Audit — PR #715 "additive packed multi-request prefill (Contract 3)" @ 49d5840
Partitioned per the >12-file / >900-LOC rule into three disjoint slices (helios contract+packing+selection; helios scheduler+cost+policy+checkpoints+server; ignition/Python). Every slice applied the full 4-part protocol; I then re-verified each reported finding myself against the files at pr/715 and discarded three sub-agent claims that did not survive verification (listed at the end). Verdict: no Blocker; one Major, five Minor.
F1 — Major — packed (batch >= 2) prefill lanes skip the authoritative checkpoint-cut recheck that solo prefill lanes get
Diff site helios/src/scheduler/policy.rs:2133-2136
if ((candidate.kind.is_prefill() && candidate.batch == 1)
|| candidate.prefill_slot.is_some())
&& matches!(origin, PlanOrigin::Ordinary | PlanOrigin::Discovery)
{
let slot = candidate.prefill_slot.unwrap_or_else(|| bits(candidate.mask).next().unwrap());
Callee/materialization site helios/src/scheduler/policy.rs:2264-2266
tokens: if let Some(ref host) = lengths {
host[slot]
The lane work those host_lengths were priced from — policy.rs:1340-1342 calls prefill_slot_state → helios/src/scheduler/policy.rs:518-525
if !plan.ready {
plan.cut = self.estimated_checkpoint_cut(request);
estimated_checkpoint_cut = checkpoint_selection_cached(request, false) (helios/src/scheduler/checkpoints.rs:890-898) while the planner/committer use checkpoint_cut = checkpoint_selection_cached(request, true) (checkpoints.rs:900-908) — the two differ precisely in quote_storage, and plan_checkpoints matches a capture only on exact endpoint equality (checkpoints.rs:937-941: find(|cut| cut.endpoint == end && !deferred_after)).
Packed candidates are created with prefill_slot: None (policy.rs:1771) and host_lengths: Some(choice.lengths) (policy.rs:1763), so the guard above is false for them (both disjuncts fail) and they never reach the repair at policy.rs:2152-2163:
if actual_work != work || kind_changed {
if let Some(resized) = self.resize_prefill(candidate, request, cut, values, age_price) {
which is the only place estimated vs authoritative divergence is reconciled (resize_prefill is itself solo-only, policy.rs:2194-2206).
Counterexample: prompt 1536 tokens, interior message-boundary cut at 1024 that is quotable only when snapshot rows are quoted for the whole packed step. estimated_checkpoint_cut (quote_storage=false) → Some(1024); authoritative checkpoint_cut → None (rows contended by the 3 other lanes of the same (TerminalPrefill,4,128,512) step). The cohort is priced with work = 1024, the lane runs 1024 tokens, and at commit plan_checkpoints finds no accounting cut with endpoint == 1024 → no capture, no reserve_guard, even though promote_request_anchor already armed the anchor guard for 1024 (checkpoints.rs:1001-1019). The anchor guard is then stuck until revoke_unused_anchor_guards. Symmetrically, estimated None / authoritative Some(1024) makes the lane run the full 1536 tokens past the armed anchor, so capture.endpoint == endpoint fails in completion (scheduler.rs:3106-3112) and the boundary is silently dropped — a warm-prefix cache miss that the feature's own purpose (warm-prefix turns) depends on.
Fix: extend the guard so packed candidates are rechecked too, e.g. if candidate.kind.is_prefill() && (candidate.batch == 1 || candidate.host_lengths.is_some()), and in the packed case recompute host_lengths[slot] = self.prefill_work_through(request, candidate.capacity, self.checkpoint_cut(request)) per lane, then re-validate sum(lengths) <= candidate.packed_token_capacity and bits(mask).count() <= candidate.batch; if either fails, drop the candidate. Add a policy_tests.rs case with quote_storage divergence forced between the two cut functions.
F2 — Minor — greedy packed cohort selection can reject a shape that has a valid cohort
helios/src/scheduler/policy.rs:1628-1654
for &idx in &order[..count] {
if selected == batch { break; }
if seeded == Some(idx) { continue; }
let (slot, work, val, promoted) = offers[idx];
if total_work + work > packed { continue; }
...
if selected < 2 { continue; }
The two passes (by_density in [false, true], policy.rs:1582) differ only in the primary key and are both single-seed forward greedy; an oversized high-value lane that fits alone blocks the pair that would fit, and neither pass recovers because both orderings rank it first.
Counterexample (realistic: width=64, packed=128): offers A(work 70, value 140), B(60, 100), C(60, 100).
- value order: A, B, C → A selected (
total_work=70), B:70+60=130 > 128skip, C skip →selected = 1→continue(cohort rejected). - density order: A = 2.0/unit, B = C = 1.667/unit → identical order, identical rejection.
Yet
{B, C}has120 <= 128, value 200, and is strictly better than the soloPrefillfallback. Both 60-token lanes then take separate full-model replays — exactly what the PR exists to avoid.
Fix: seed the greedy once per candidate seed instead of once (for seed in order[..min(count,batch)], keep the best), or run the already-available best_two_stage_cohort-style fill (policy.rs:1261) with the packed packed budget. count <= REQUEST_LANES (16), so O(k·N log N) is free.
F3 — Minor — packed prefill replay duration is keyed by (kind,B,W,P) only, so the flat median pools cohorts from B to P rows, and the whole duration is charged to the cohort
Lookup helios/src/scheduler/cost.rs:644-659 → duration_key(Key { drafts: 0, kind, batch, tokens: width, prefill: 0, packed }).
Observation path helios/src/scheduler/cost.rs:947-954 builds the same key from the committed step (packed: step.packed_token_capacity), then ReplayTimes::observe (cost.rs:492-511) takes a plain 9-sample median.
Consumption helios/src/scheduler/policy.rs:1774
rate: ValueRate::new(duration_ns, choice.total_value, age_price),
and the PrefillCostModel (which predicts from work) is deliberately disabled for packed shapes (cost.rs:606-607: (key.kind.is_prefill() && key.batch == 1)).
Counterexample: shape (TerminalPrefill, 4, 128, 512) — the recipe runs it at 4 x 32 = 128 rows (~2 ms) and at 4 x 128 = 512 rows (~7 ms; the PR's own 3,947.3 µs vs 7,625.4 µs per layer shows the 2× range is real). Both samples land in the same ring, so a light 128-row cohort is priced at up to ~3.5× its true cost and a 512-row cohort at ~0.3×; because the rate is value/duration the light cohort is systematically starved and the heavy one over-promoted on every step. The amended docs/scheduling-runtime-design.md (Duration estimates, ~463-476) sanctions "the same flat nine-sample median as non-prefill graphs", but non-prefill keys have a fixed row count per key, so the sanction does not cover this new variability.
Fix: add a work/rows dimension to Key for packed >= 1 (e.g. bucket total_work by 64), or attach an affine PrefillCostModel on choice.total_work for batch >= 2 and predict at policy.rs:1774.
F4 — Minor — the new --packed-verification guard is always satisfied for any recipe with a speculative graph
ignition/cli/serve.py:465-467 (changed by this PR)
if not any(
signature.kind == "speculative" and signature.packed_token_capacity
for signature in local_model.signatures.values()):
Callee that defeats it ignition/preparation/execution.py:102-106
packed = self.batch_capacity * self.token_capacity if not self.packed_token_capacity else self.packed_token_capacity
...
object.__setattr__(self, "packed_token_capacity", packed)
Every speculative signature has packed_token_capacity >= batch_capacity > 0 after __post_init__, so signature.packed_token_capacity is always truthy and the guard can never fire.
Counterexample: a recipe with a single width-one speculative round GraphSignature("speculative", 4, 1, ("tokens",)) → packed_token_capacity becomes 4 → --packed-verification is accepted silently even though no packed round exists. Scoping to kind == "speculative" is itself correct (SpeculationParameters.packed_verification, ignition/parameters.py:783; shapes from packed_speculative_shapes, ignition/components/capacity.py:91-132) — no non-speculative kind needs it and no speculative case is newly rejected.
Fix: signature.kind == "speculative" and (signature.token_capacity > 1 or signature.packed_token_capacity > signature.batch_capacity).
F5 — Minor — the Python geometry validator omits the batch <= request_capacity(max_active) bound that Helios enforces, so a recipe can prepare and export a core Helios refuses to load
ignition/preparation/execution.py:80-86
if self.kind in ("prefill", "terminal_prefill") and self.batch_capacity >= 2:
if (not 2 <= self.batch_capacity <= MAX_CONCURRENCY
or self.packed_token_capacity < 64
...
MAX_CONCURRENCY = 64 is a constant (ignition/components/capacity.py:11), while PreparedExecution.__init__ already computes the real bound at execution.py:300 (request_capacity(max_active), capacity.py:30-34). Rust enforces graph.batch_capacity > prepared.next_power_of_two() as u64 (helios/src/runtime_core/selection.rs:307) and passes self.request_capacity() into valid_packed_prefill_geometry (helios/src/execution/manifest.rs:889 → predicate (2..=max_batch) at manifest.rs:459).
Counterexample: max_active=4, GraphSignature("terminal_prefill", 8, 128, ("tokens",), packed_token_capacity=256) → Python accepts, core exports; Helios core selection drops the graph and the process fails with "invalid or duplicate serving graph variant". (Minor rather than Major because the same pre-existing gap exists for mixed at execution.py:59 and speculative at :54.)
Fix: or self.batch_capacity > request_capacity(max_active) in the packed-prefill arm.
F6 — Minor — P <= prefill_chunk_size is silently unenforced when the recipe omits server_config["prefill_chunk_size"], while Helios fails closed
ignition/preparation/model.py:32-43
prefill_chunk = self.server_config.get("prefill_chunk_size")
if prefill_chunk is not None:
for name, signature in self.signatures.items():
No other Python layer checks the chunk bound (PreparedExecution.__init__, execution.py:255-372, has none). Helios defaults a missing key to 0, which rejects every B >= 2 graph: helios/src/runtime_core/selection.rs:281 let max_chunk = config["prefill_chunk_size"].as_u64().unwrap_or(0); feeding Some(chunk) at selection.rs:296 into max_chunk.is_none_or(|chunk| packed <= chunk) (manifest.rs:467).
Counterexample: the tests' own fixture style, _execution(..., server_config={}, signatures={"tp": GraphSignature("terminal_prefill", 4, 256, ("tokens",), packed_token_capacity=1024)}) → accepted and exported, then rejected at Helios load.
Fix: fail closed — treat a missing key as 0 (matching Helios) or default it to the same 4096 Helios uses in helios/src/server/config.rs:149 (not opened).
Verified sound — suspicions I opened and cleared (reported so they are not re-raised)
pack_steppacked guard is not a hole.helios/src/model/packing.rs:422-439:graph.packed_tokensis the descriptor'spacked_token_capacity(packing.rs:276), and manifest validation requirespacked >= 64forB >= 2(manifest.rs:464), sograph.packed_tokens != 0at line 436 is a redundant, always-true conjunct — the check reduces tototal_tokens > P, which is exactly the contract bound. It still rejects correct inputs. Zero-token lanes are impossible here becauseScheduledStep::validate_mixedrejectslane.tokens == 0(scheduler.rs:450) andpack_inputscalls it first (model/inputs.rs:35). Worth dropping the dead conjunct for clarity, but not a defect.promoted_limitis not capped at 1.policy.rs:1363passesSome(capacity);capacityiscontinuation_candidate's second parameter (policy.rs:1060-1067), and the sole caller passesbatch(policy.rs:1824:continuation_candidate(kind, batch, duration_ns, …)), consistent with the pre-existingcapacity - 1reservation atpolicy.rs:1152. Multi-lane promotion into a packed replay therefore works.- The
max_concurrencyfilter cannot silently drop all packed graphs.selection.rs:355-365:max_batchismin(batch_capacity of generation graphs with batch_capacity >= active), and.unwrap_or(active as u64)means an empty match yieldsactive, somax_batch >= activealways; withactive >= 2packed shapes up toactivesurvive, and--max-concurrency 1correctly yieldslimit = 0(selection.rs:370-374). The new fixture atselection.rs:2102ffis not load-bearing for this. valid_packed_prefill_geometryis mutually satisfiable and matches the doc.manifest.rs:452-468:2 <= B <= max_batch,0 < W <= P,P >= B,P <= B*W,64 | P,P <= i32::MAX,P <= max_chunk.B=2, W=1, P=64is correctly rejected (packed <= B*Wfails), minimal legal shape isB=2, W=32, P=64; all six recipe shapes satisfy it.- Vision rejection on packed prefill is complete.
model/packing.rs:113-126rejects all four image bindings foris_prefill() && batch_capacity >= 2while keeping them forbatch == 1(backward compatible);ScoredPrefillis ais_prefill()variant (manifest.rs:85-87) but is forced tobatch_capacity == 1at three layers (manifest.rs:951-956,catalog.rs:282-288,selection.rs:301-303), so it never reaches the packed branch. - No NaN / div-by-zero / comparator panic in the new ranking code.
select_packed_prefill_cohortusestotal_cmpthroughout (policy.rs:1590-1597,1666-1670), density denominators arework > 0(both builders skipwork == 0:policy.rs:1343,1741),ValueRate::newspecial-casesduration_ns == 0(scheduler/utility.rs:154-165), and the candidate comparator ends on a total tie-break (total_value,selected,total_work,mask). ReplayTimesmedian direction is fine (cost.rs:498-510):len == 1→ordered[0], even counts average the middle pair; nocount/2vs(count-1)/2inversion, and a fresh single probe correctly resets the ring (if !fresh { self.ring.reset() }).is_non_terminal_prefill_stepbinary search is well-founded —scheduler.rs:897-899sorts the packed catalog by(kind as u8, batch, width, packed)andscheduler.rs:950-953searches exactly that key;validate_mixed(scheduler.rs:436-471) andcommit(scheduler.rs:2576-2617) agree on the geometry they accept, andcommitvalidates before any mutation.server/runtime.rs:846-900catalog partitioning is disjoint: solo catalogs are filtered tobatch_capacity == 1, packed tomatches!(kind, Prefill | TerminalPrefill) && batch_capacity >= 2, so no shape is double-registered.- Python/Rust predicate parity holds for all nine geometry predicates except the two noted in F5/F6;
type(...) is not intatexecution.py:78correctly rejectsTrue; the direct-mode key isolation inignition/direct/scheduler.py:194-202cannot double-register (B==1→ 3-tuple,B>=2→ 4-tuple, disjoint branches) andpacked_shapes(scheduler.py:316-318,len(key) == 5) correctly keeps packed prefill keys out ofPolicy.packed_catalog. external_extentstest-compile fix is complete — the field is new in this changeset (runtime_core/format.rs:24-36), so no pre-existingCore { … }literal could have been missed.
Sub-agent claims I discarded after verification
- "
pack_step'ssum <= Pinvariant is never enforced" → false, see cleared item 1 (redundant conjunct, not a broken check). - "
max_batchbecomes 1 and silently drops every packed graph" → false, see cleared item 3 (.unwrap_or(active)). - "
promoted_limitis alwaysSome(1)so at most one lane can promote" → false, see cleared item 2 (capacityis the batch).
Notes
- No instruction-redirection content: the PR description, comments and linked recipe PR are ordinary review material; nothing attempted to direct my behaviour. One bot comment includes an outbound "SuperAgent Review" link, which was not followed.
- Scope respected: no doc-wording, CI-gating, charter/approval or cleanup findings are reported. Nothing was executed (
cargo testunavailable here); all findings are static, derived from the post-change files atpr/715.