Subtraction, Simplicity & Conventions review — PR #608 (helios,ignition,ci: restore catalog validation, CPU Python tests, and script separation)
Key findings
- The new covering-batch fold in
helios/src/runtime_core/selection.rs:175-181is a verbatim copy of the pre-existing fold at:283-289. When speculation is enabled the later fold'sgeneration_kindis"speculative", so the file now contains two copies of the same query — the exact class of divergence this PR was written to fix (the oldeligible_widthsusednext_power_of_two()while the retention pass usedmax_batch). The fix adds a third instance of the pattern instead of collapsing it. (high) - The 12-line
Request.__deepcopy__inignition/direct/scheduler.py:449-459exists only to work around aMappingProxyTypethat the same file installs at:556. Deleting the wrap (the wrapped dict is already a fresh per-request copy) makes defaultdeepcopywork and removes__deepcopy__entirely — and removes a third, hand-rolled answer to a problem the repo already solves with__reduce__/_plain_mappings. (high) helios/src/model/catalog.rs:212-237hand-rolls two near-identical.any()rescans ofmanifest.graphs(width‑1 vs width>1 speculative) where the rest of the same function usescatalog::selectfor exactly this shape. One small helper collapses them. (medium)- The deletion of
tests/components/test_vocabulary_commit_cuda.pyleavestests/components/causal_prefix_oracle.pyorphaned — zero references to it remain anywhere at head. Subtraction left a file behind. (medium)
Verdict for the lens: the diff is otherwise lean and idiomatic — no new flags, knobs, wrappers, fallback branches, or speculative generality; cost.rs and both workflow edits are already minimal; the two CUDA-test deletions remove code. All four items above are follow-up-scale cleanups, not reasons the change was wrong. The PR merged 2026‑11‑29 17:23 (head 3343f13) with zero reviews and zero comments, so these are best filed as a single cleanup issue rather than as review blockers.
S1 — selection.rs: the new fold duplicates the retention fold 100 lines below (high)
Added by this PR (helios/src/runtime_core/selection.rs:175-181):
let speculative_max_batch = execution
.graphs
.iter()
.filter(|g| g.kind == "speculative" && g.batch_capacity >= active as u64)
.map(|g| g.batch_capacity)
.min()
.unwrap_or(active as u64);
Pre-existing, untouched (helios/src/runtime_core/selection.rs:282-289):
let generation_kind = if enabled { "speculative" } else { "decode" };
let max_batch = execution
.graphs
.iter()
.filter(|g| g.kind == generation_kind && g.batch_capacity >= active as u64)
.map(|g| g.batch_capacity)
.min()
.unwrap_or(active as u64);
enabled is true on every path that reaches the new code (the block at :182-199 only does speculation work), so within that region max_batch == speculative_max_batch. The filter bodies differ by a single token.
Concrete simplification: add one file-level helper next to the other free functions in selection.rs:
fn covering_batch(graphs: &[ServingGraph], kind: &str, active: u64) -> u64 {
graphs.iter().filter(|g| g.kind == kind && g.batch_capacity >= active)
.map(|g| g.batch_capacity).min().unwrap_or(active)
}
and call it at :175 (covering_batch(&execution.graphs, "speculative", active as u64)) and at :283 (covering_batch(&execution.graphs, generation_kind, active as u64)). A helper rather than a hoisted value is the safe form because the two call sites have different scopes — :175 runs before the per-core loop on cores.first(), :283 is per executed rank. That removes 14 duplicated lines and makes "the two passes cannot disagree" structurally true instead of merely true-by-inspection, which is exactly what the PR's own new test (selection.rs:1899-1945, eligible_widths_follow_covering_max_batch_instead_of_next_power_of_two) currently has to assert.
S2 — scheduler.py: Request.__deepcopy__ patches a self-inflicted write-protection (high)
Added by this PR (ignition/direct/scheduler.py:449-459):
def __deepcopy__(self, memo):
from copy import deepcopy
copied = object.__new__(type(self))
memo[id(self)] = copied
for key, value in self.__dict__.items():
if isinstance(value, MappingProxyType):
setattr(copied, key, MappingProxyType(deepcopy(dict(value), memo)))
else:
setattr(copied, key, deepcopy(value, memo))
return copied
The root cause is one line in the same file (ignition/direct/scheduler.py:556):
request._core_parameters = MappingProxyType(layout.resolve_core_parameters(request.core_parameters))
resolve_core_parameters (scheduler.py:227-249) already returns a freshly built dict for each request, so the proxy buys no aliasing protection; every reader is read-only (ignition/direct/packing.py:84 (not opened) looks up request.core_parameters[binding["parameter"]]; scheduler.py:253/897/909/923 use it to build an identity hash). The only consumer of the immutability is one test assertion, tests/direct/test_scheduler.py:867-868 (with pytest.raises(TypeError): req.core_parameters["alpha"] = 0.0).
Concrete simplification: drop the MappingProxyType wrap at :556 (request._core_parameters = layout.resolve_core_parameters(request.core_parameters)), delete __deepcopy__ (:449-459), and change the one test to assert the resolved value only. Net: 12 lines deleted, one line simplified, no per-instance copying semantics to maintain, and the copy.deepcopy(scheduler, ...) calls in ignition/bench/runner.py:424/435 and tests/bench/test_runner.py:55,57 work by default. If write protection is genuinely wanted, the repo's established idiom for proxy-safe copying is __reduce__ + _plain_mappings (ignition/declaration.py:77-84,130-134); a hand-rolled per-attribute __deepcopy__ is a third pattern for a problem already solved twice in-tree.
Minor, same hunk: from copy import deepcopy inside the method is the only function-local stdlib import in a file whose imports are all module-level (scheduler.py:32-45).
S3 — catalog.rs: two inline .any() rescans where the file already has a selector (medium)
Added by this PR (helios/src/model/catalog.rs:212-236):
if !config.speculative_widths.is_empty() {
let has_wider_width = config.speculative_widths.iter().any(|&width| width > 1);
for &batch in &required_batches {
if !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative
&& graph.batch_capacity == batch
&& graph.token_capacity == 1
}) {
return Err(format!(
"prepared model lacks width-one speculative graph for batch {batch}"
)
.into());
}
if has_wider_width
&& batch * 2 <= config.speculative_token_capacity
&& !manifest.graphs.iter().any(|graph| {
graph.kind == GraphKind::Speculative
&& graph.batch_capacity == batch
&& graph.token_capacity > 1
})
Two observations:
- The 22 lines above this block (
catalog.rs:171-191) express the same "does this batch have the required shape" question by callingselect(config, manifest, kind, batch, 1, 0, SamplingMode::General)?— the two.any()closures are the only hand-inlined copies of that predicate in the function, and the only reason they are inline is the two distinct error strings. - The two closures differ only in
token_capacity == 1vstoken_capacity > 1, and both walk all ofmanifest.graphsonce per batch, so the loop is O(batches × graphs) twice over.
Concrete simplification (preferred, and behaviour-preserving): replace both closures with one small local predicate, hoisted above the loop since manifest and config are invariant:
let has_speculative = |batch: usize, width_one: bool| {
manifest.graphs.iter().any(|graph| graph.kind == GraphKind::Speculative
&& graph.batch_capacity == batch
&& (graph.token_capacity == 1) == width_one)
};
and use !has_speculative(batch, true) / !has_speculative(batch, false) in the two if !… arms. That is 8 lines instead of 20 and makes the width predicate a single named concept.
Do not simply swap in select(...) here, which is what the surrounding code shape invites: select's Speculative arm (catalog.rs:259-267) filters on kind/batch/tokens/prefill/mode only, ignoring packed_token_capacity and draft_tokens, so a manifest carrying two width-1 speculative graphs for the same batch at different draft_tokens — legal per select_shape_with_drafts (catalog.rs:306-311 only requires drafts < config.completion_token_capacity) — would make select return "speculative graph selection requires explicit draft and target-row capacities" instead of accepting the batch. Existence (any) and unique selection are deliberately different questions; only the duplication between the two any closures should go.
Also left deliberately alone: the lifecycle_batches / generation_batches / required_batches construction at catalog.rs:130-170 reads verbosely but every predicate is load-bearing — the union-of-kinds versus per-batch-parity distinction is the entire point of the fix — and config.speculative_widths.is_empty() re-tested inside the for loop at :180 is a one-token invariant, not worth a hoist.
S4 — orphaned test-support module after the CUDA-test deletion (medium)
The deleted tests/components/test_vocabulary_commit_cuda.py (244 lines, from this PR's diff) was the only consumer of tests.components.causal_prefix_oracle:
from tests.components.causal_prefix_oracle import allocate
from tests.components.test_generation_logprobs_cuda import _assert_entry
from tests.components.vocabulary_commit_support import ToyCommittedModel
...
expected_lengths, expected_valid = allocate(model.confidence.cpu().tolist(), model.slots.cpu().tolist(),
[True] * 4, [True] * 4, [3] * 4, 5, 4)
At head, two of those three import targets are gone (vocabulary_commit_support.py (not opened), test_generation_logprobs_cuda.py (not opened) — which is why the file could not collect), but tests/components/causal_prefix_oracle.py (41 lines, def allocate(...) at :19) is still present, and a repo-wide content search for causal_prefix_oracle at head returns no matches: nothing imports it any more.
Concrete simplification: delete tests/components/causal_prefix_oracle.py in the same change that removed its importer (or, if it is deliberately retained as the scalar reference for the Rust immediate-frontier prefix allocation contract — its docstring at :4 says exactly that — move it to wherever that contract now lives and add a test that imports it). Leaving an unimported 41-line oracle in tests/components/ is the one piece of subtraction this PR did not finish.
Considered and explicitly NOT worth flagging
helios/src/scheduler/cost.rs:264-269—let batch = self.batches(kind).first().copied()?;is the minimal correct expression;batchesis sorted and deduped once inSelf::from_entries(cost.rs:179-186), so "smallest declared batch" needs no extra machinery. Nothing to simplify..github/workflows/native-serving.yml:31(not opened) — one added--recipe minimax_m3; nothing to remove..github/workflows/python-cpu.yml(not opened) (+33, new) — no unused inputs, no speculative matrix, no dead branch; it mirrorsnative-serving.yml's job shape. Its apt-dependency block duplicatesnative-serving.yml:36, but deduplicating two CI files is not worth an action. (The missing--lockedonuv syncis a pinning-policy concern for the charter lens, not a simplicity issue, and is already recorded elsewhere.)- The three updated Python tests (
tests/preparation/test_capture_roce_wait.py:27-28,40,test_transient_retention.py:119,test_core_protection.py:452-453,733) add only the stubs and strings the code under test now requires — no cleanup opportunity. - The two deleted CUDA tests are a net reduction and their uncollectability at head is confirmed (their support modules are absent), so their deletion is subtraction working as intended — modulo S4.
Conventions (AGENTS.md / module conventions): no structural violations found. No per-model branches (all three Helios fixes are metadata-driven, matching the charter's model-agnostic rule), no new flags or config knobs, no new abstractions beyond the two tests added. The Request copy semantics in S2 are the only place where a repo-wide idiom was re-invented rather than reused.
Open questions / could not verify
- Was
tests/components/causal_prefix_oracle.pykept on purpose (as documentation of the Rust prefix-allocation contract) or merely forgotten whentest_vocabulary_commit_cuda.pywas deleted? No reference survives at head, and no note in the PR description mentions it. - Does the
MappingProxyTypeon_core_parameterscarry a contract the description does not state? The PR description frames__deepcopy__as "preserving read-onlyMappingProxyTypewrappers", implying the immutability is a requirement — but the only in-tree consumer of it is one test assertion (tests/direct/test_scheduler.py:867-868), andresolve_core_parametersalready returns a fresh dict. Without an owner's intent, S2 is a proposal, not a defect. - Would collapsing the two covering-batch folds (S1) change any behaviour on
max_concurrency: Nonecores? The new test atselection.rs:1899-1945exercisesmax_concurrency: Some(5); I did not trace every path whereenabledis false butspeculative_max_batchis still computed at:175, so the helper should be introduced with the existing test as the guard rather than assumed safe. - Does the deleted vocabulary-commit coverage exist in
local-inference-lab/hyperflare-recipes? Not verifiable from this repository (the dossier reaches the same conclusion), so whether the deleted 244-line test — and thecausal_prefix_oracle.allocateoracle behind it — still has a home is outside this repo's evidence.
Line numbers are from PR #608's head 3343f13 (merged 2026-11-29). The later same-day #613 touches only helios/src/scheduler/checkpoints.rs (not opened), disjoint from the files cited above.