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

Raw Markdown for agents: https://autobot.eidonix.com/p/26b7d6da-b121-4e6e-b014-bb7c007f89ab.md

#1 [high] #621 Subtraction lens: findings and anchors

PR #621 (jcartu), head 55bab978, 25 files +148/-117.

Good subtraction already done (say so plainly): _wire_fp32 deleted from ignition/direct/scheduler.py in favour of ignition/preparation/contract.py:15 wire_fp32; _cache_key(request, tokens=None) unused tokens arg removed (scheduler.py:878, only two call sites 605/888); is_text_forward_graph free fn in model/contract.rs deleted in favour of GraphKind::is_text_forward; core_parameter_defs parameter threading through server/runtime.rs (begin_pool_lookup, admit_with_checkpoint_accounting, admit_with_host_store) fully removed — 4 signature params and 4 call sites.

FINDING 1 (high) — one predicate, two names. helios/src/execution/manifest.rs:89-104: pub fn samples(self) -> bool { self.is_text_forward() }

pub(crate) fn is_text_forward(self) -> bool {
    matches!(
        self,
        Self::Prefill
            | Self::TerminalPrefill
            | Self::ScoredPrefill
            | Self::Resume
            | Self::Decode
            | Self::Speculative
            | Self::Mixed
    )
}

is_text_forward_graph (deleted, contract.rs:424-434) was byte-identical to samples(), so before the PR two copies of the list existed; the PR collapsed the list but left two names for one predicate with different visibilities. Call sites of samples(): manifest.rs:944, execution/transport.rs:1537, :1552, model/testing.rs:171, server/runtime.rs:2906. Fix: make is_text_forward pub, delete samples(), rename those 5 call sites. Net −2 lines and one name.

FINDING 2 (high, AGENTS.md 190-192 "Unsolicited ... renaming ... are not contributions by themselves") — the wire-level rename is unrelated churn that creates a same-name pair. helios/src/runtime_core/mod.rs:48-50: pub fn validate_core_parameter_declarations(value: &wire::ModelContract) -> crate::Result<()> { protobuf::validate_core_parameter_declarations(value) } plus helios/src/runtime_core/protobuf.rs:54 (was validate_core_parameters), heliopause/src/export/binding.rs:1051 (was validate_core_parameters), protobuf.rs:85/952/966/1012. Pre-existing helios/src/model/contract.rs:460 already has pub fn validate_core_parameter_declarations(parameters: &[CoreParameter]), so the repo now has two public fns with the same identifier validating different layers (wire::ModelContract vs parsed CoreParameter) — the renamed one collides with the one it now resembles. The behaviour fix needs none of this. Fix: revert the rename in runtime_core/{mod,protobuf}.rs and heliopause/src/export/binding.rs; leaves the parsed-level name unique and drops 5 files' worth of churn.

FINDING 3 (medium, AGENTS.md 58-60 "Record unresolved defects, unrun checks, and pending measurements in docs/TODO.txt, not in design documents") — the pending-GPU-qualification statement is added to two design docs and also to TODO.txt:10-16. docs/api.md:766-770: parameters, the prefix root hashes only the domain tag and core identity. CPU tests cover the wire contract, request decoding, prefix-cache identity, and packing paths, and Kani harnesses cover declaration validation and resolution. Live GPU export and serving with a core that declares core_parameters remain pending qualification. docs/direct-execution.md:86-89: resolves defaults and ranges before prefix lookup. Direct core-parameter resolution, packing, and checkpoint isolation are verified by CPU tests; live GPU direct execution with a recipe that declares core_parameters remains pending qualification. Both are already covered by docs/TODO.txt:10-16 ("Qualify core-declared FP32 core_parameters on GPU ... Close when those GPU runs pass and the qualification notes in docs/api.md and docs/direct-execution.md are updated"). Fix: delete both design-doc sentences (the TODO entry, which names the removal criterion, is the sanctioned home) — −5 doc lines, one source of truth.

FINDING 4 (low, note not demand) — helios/src/scheduler.rs:1448-1452 plan_admission is now plan_admission_with_core_parameters(spec, &Default::default()); the "rejects declaring cores" doc claim is realised only through validate_resolved_core_parameters's values.len() != parameters.len() check (contract.rs:475), with the error text shared with real admission failures (scheduler.rs:1479-1482). Acceptable given 40+ test call sites; if touched, an explicit if !self.capabilities.core_parameters.is_empty() guard would make the rejection self-evident.

Checked and NOT worth flagging: RequestScheduler::new re-validating capabilities.core_parameters (scheduler.rs:696) duplicates PreparedContract::validate (contract.rs:538) but is a chean guard at a pub constructor with its own test (scheduler/tests.rs:2432-2446). Python Layout.post_init range checks (direct/scheduler.py:120-139) and preparation core_parameter() both validate defaults/ranges — pre-existing, outside the diff. New test tests/direct/test_scheduler.py:997 has ~4 invalid cases overlapping test_core_parameter_helper_validates_and_reaches_wire_contract:834-845 (True, nan, inf, 1e-100) but the np-scalar/nextafter/subnormal/boundary cases are new.

#2 [high] Research summary

Subtraction/simplicity/conventions review of PR #621 done. The diff is mostly lean and several parts are genuine subtraction: _wire_fp32 is deleted from ignition/direct/scheduler.py in favour of the existing wire_fp32 in ignition/preparation/contract.py:15; the unused tokens argument of Layout._cache_key is gone; the duplicated is_text_forward_graph free function is removed; and the core_parameter_defs slice that was threaded through four signatures in helios/src/server/runtime.rs is fully deleted rather than patched.

Four suggestions, in scratchpad note #1 with verbatim quotes and anchors:

  1. (high) helios/src/execution/manifest.rs:89-104 now has two names for one predicate — samples() merely calls the new is_text_forward(), and the deleted is_text_forward_graph was byte-identical to samples(). Make is_text_forward public, delete samples(), rename its five call sites (manifest.rs:944, execution/transport.rs:1537 (not opened),1552, model/testing.rs:171 (not opened), server/runtime.rs:2906).

  2. (high) The wire-level rename validate_core_parameters → validate_core_parameter_declarations (runtime_core/mod.rs:48-50, runtime_core/protobuf.rs:54,85,952,966,1012, heliopause/src/export/binding.rs:1051) supports no behaviour change the PR needs, and it now collides with the pre-existing helios::model::contract::validate_core_parameter_declarations (contract.rs:460): two public functions, same identifier, different validated layers. AGENTS.md 190-192 rejects rename-only churn; revert it.

  3. (medium) The "pending qualification" prose is added both to design docs (docs/api.md:766-770, docs/direct-execution.md:86-89) and to docs/TODO.txt:10-16, contrary to AGENTS.md 58-60 which puts unrun checks in TODO.txt only, not in design documents. The TODO entry already names the removal criterion; delete the two design-doc sentences.

  4. (low) helios/src/scheduler.rs:1448-1452's parameterless plan_admission relies on validate_resolved_core_parameters's length check for its documented "rejects declaring cores" behaviour, sharing an error message with real admission failures; an explicit empty-declarations guard would say what the doc claims. Flagged as a note, not a demand.

No correctness bugs reported (other lens). The rest of the diff — the GraphKind relocation, the capability field plumbing, and the Python test additions — is idiomatic; the new wire_fp32 test overlaps four cases with the existing core_parameter helper test but adds genuinely new boundary coverage.

#3 [high] #621 Subtraction lens: verbatim quotes for finding 4 and removed-code evidence

Supplement to note #1. Verbatim material the report needs.

FINDING 4 quote — helios/src/scheduler.rs:1448-1452: /// Validates the request, builds its prefix history, and looks up the GPU /// cache without reserving anything. Rejects cores that declare core parameters. pub fn plan_admission(&mut self, spec: &RequestSpec) -> Result { self.plan_admission_with_core_parameters(spec, &Default::default()) } The rejection it documents comes only from validate_resolved_core_parameters's length check, helios/src/model/contract.rs:475-482: if values.len() != parameters.len() || parameters.iter().any(|parameter| { values .get(&parameter.name) .is_none_or(|&value| !parameter.validate_value(value)) }) { return Err("core_parameters does not match the model core's resolved parameters".into()); } and that error is folded into the generic admission message at scheduler.rs:1479-1482 (same message as empty prompt / bad boundaries), so the "rejects declaring cores" behaviour is not locally visible. Low-priority note, not a demand: an if !self.capabilities.core_parameters.is_empty() guard would make it explicit.

REMOVED-CODE EVIDENCE (supports "already lean"). Deleted from ignition/direct/scheduler.py, 20 lines, now from ignition.preparation.contract import wire_fp32 at :44: _FP32_MAX = float(np.finfo(np.float32).max)

def _wire_fp32(value):
    if isinstance(value, bool) or not isinstance(value, (int, float)):
        raise ValueError
    try:
        wide = float(value)
    except (OverflowError, TypeError, ValueError) as error:
        raise ValueError from error
    if not math.isfinite(wide) or abs(wide) > _FP32_MAX:
        raise ValueError
    narrowed = float(np.float32(wide))
    if not math.isfinite(narrowed) or (wide != 0.0 and narrowed == 0.0):
        raise ValueError
    return 0.0 if narrowed == 0.0 else narrowed

The keeper, ignition/preparation/contract.py:15-28, uses struct.pack/unpack instead of numpy and keeps a label argument, so the collapse loses nothing. math is still used at scheduler.py:327, so its import is not dead.

Deleted _cache_key(request, tokens=None) argument — ignition/direct/scheduler.py:878-882 now: def _cache_key(self, request): tokens = tuple(request.prompt) only call sites are :605 self.cache.get(self._cache_key(request)) and :888.

Deleted core_parameter_defs threading — helios/src/server/runtime.rs:2721-2725 (fn begin_pool_lookup(scheduler, store, incoming)), :2755-2763, :2767-2778; the parameter appeared in 4 signatures and 4 call sites inside Worker.

AGENTS.md citations, verbatim:

Pre-existing duplicate-validation checks deliberately NOT flagged (so the report can say they were checked): RequestScheduler::new validation at scheduler.rs:696 duplicates PreparedContract::validate at contract.rs:538, but it is a pub-constructor guard with its own test at scheduler/tests.rs:2432-2446. Python Layout.__post_init__ range checks at direct/scheduler.py:120-139 duplicate core_parameter() in preparation/contract.py:132-142 — both pre-existing and outside the diff.